mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
refactor(string): split utilities by responsibility
This commit is contained in:
@@ -6,7 +6,7 @@ from typing import List, Optional
|
||||
from app.domain.context import Context
|
||||
from app.schemas.types import MediaType, media_type_to_agent
|
||||
from app.foundation.crypto import HashUtils
|
||||
from app.domain.string import StringUtils
|
||||
from app.foundation import size as size_tools
|
||||
from ._music_utils import simplify_music_info
|
||||
|
||||
SEARCH_RESULT_CACHE_FILE = "__search_result__"
|
||||
@@ -150,7 +150,7 @@ def simplify_search_result(
|
||||
if torrent_info:
|
||||
simplified["torrent_info"] = {
|
||||
"title": torrent_info.title,
|
||||
"size": StringUtils.format_size(torrent_info.size),
|
||||
"size": size_tools.format_size(torrent_info.size),
|
||||
"seeders": torrent_info.seeders,
|
||||
"peers": torrent_info.peers,
|
||||
"site_name": torrent_info.site_name,
|
||||
|
||||
@@ -12,7 +12,8 @@ from app.agent.tools.tags import ToolTag
|
||||
from app.chain.storage import StorageChain
|
||||
from app.runtime.log import logger
|
||||
from app.schemas.file import FileItem
|
||||
from app.domain.string import StringUtils
|
||||
from app.foundation import size as size_tools
|
||||
from app.foundation import text as text_tools
|
||||
|
||||
|
||||
DEFAULT_DIRECTORY_PAGE_SIZE = 50
|
||||
@@ -100,7 +101,7 @@ class ListDirectoryTool(MoviePilotTool):
|
||||
file_list.sort(
|
||||
key=lambda x: (
|
||||
0 if x.type == "dir" else 1,
|
||||
StringUtils.natural_sort_key(x.name or ""),
|
||||
text_tools.natural_sort_key(x.name or ""),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -115,7 +116,7 @@ class ListDirectoryTool(MoviePilotTool):
|
||||
]
|
||||
simplified_items = []
|
||||
for item in limited_list:
|
||||
size_str = StringUtils.str_filesize(item.size) if item.size else None
|
||||
size_str = size_tools.format_compact_size(item.size) if item.size else None
|
||||
modify_time_str = None
|
||||
if item.modify_time:
|
||||
try:
|
||||
|
||||
@@ -11,7 +11,7 @@ from app.runtime.events import eventmanager
|
||||
from app.db.oper.site import SiteOper
|
||||
from app.runtime.log import logger
|
||||
from app.schemas.types import EventType
|
||||
from app.domain.string import StringUtils
|
||||
from app.foundation import url as url_tools
|
||||
|
||||
|
||||
class UpdateSiteInput(BaseModel):
|
||||
@@ -141,7 +141,7 @@ class UpdateSiteTool(MoviePilotTool):
|
||||
|
||||
# URL处理(需要校正格式)
|
||||
if url is not None:
|
||||
_scheme, _netloc = StringUtils.get_url_netloc(url)
|
||||
_scheme, _netloc = url_tools.split_netloc(url)
|
||||
site_dict["url"] = f"{_scheme}://{_netloc}/"
|
||||
|
||||
if pri is not None:
|
||||
|
||||
Reference in New Issue
Block a user