mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix:移除Action类静态属性
This commit is contained in:
+12
-17
@@ -26,37 +26,31 @@ class AddDownloadAction(BaseAction):
|
|||||||
添加下载资源
|
添加下载资源
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# 已添加的下载
|
|
||||||
_added_downloads = []
|
|
||||||
_has_error = False
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self.downloadchain = DownloadChain()
|
|
||||||
self.mediachain = MediaChain()
|
|
||||||
self._added_downloads = []
|
self._added_downloads = []
|
||||||
self._has_error = False
|
self._has_error = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def name(cls) -> str: # noqa
|
def name(cls) -> str: # noqa
|
||||||
return "添加下载"
|
return "添加下载"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def description(cls) -> str: # noqa
|
def description(cls) -> str: # noqa
|
||||||
return "根据资源列表添加下载任务"
|
return "根据资源列表添加下载任务"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def data(cls) -> dict: # noqa
|
def data(cls) -> dict: # noqa
|
||||||
return AddDownloadParams().dict()
|
return AddDownloadParams().dict()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def success(self) -> bool:
|
def success(self) -> bool:
|
||||||
return not self._has_error
|
return not self._has_error
|
||||||
|
|
||||||
def execute(self, workflow_id: int, params: dict, context: ActionContext) -> ActionContext:
|
def execute(self, workflow_id: int, params: dict, context: ActionContext) -> ActionContext:
|
||||||
"""
|
"""
|
||||||
将上下文中的torrents添加到下载任务中
|
将上下文中的torrents添加到下载任务中
|
||||||
"""
|
"""
|
||||||
@@ -73,13 +67,13 @@ class AddDownloadAction(BaseAction):
|
|||||||
if not t.meta_info:
|
if not t.meta_info:
|
||||||
t.meta_info = MetaInfo(title=t.torrent_info.title, subtitle=t.torrent_info.description)
|
t.meta_info = MetaInfo(title=t.torrent_info.title, subtitle=t.torrent_info.description)
|
||||||
if not t.media_info:
|
if not t.media_info:
|
||||||
t.media_info = self.mediachain.recognize_media(meta=t.meta_info)
|
t.media_info = MediaChain().recognize_media(meta=t.meta_info)
|
||||||
if not t.media_info:
|
if not t.media_info:
|
||||||
self._has_error = True
|
self._has_error = True
|
||||||
logger.warning(f"{t.torrent_info.title} 未识别到媒体信息,无法下载")
|
logger.warning(f"{t.torrent_info.title} 未识别到媒体信息,无法下载")
|
||||||
continue
|
continue
|
||||||
if params.only_lack:
|
if params.only_lack:
|
||||||
exists_info = self.downloadchain.media_exists(t.media_info)
|
exists_info = DownloadChain().media_exists(t.media_info)
|
||||||
if exists_info:
|
if exists_info:
|
||||||
if t.media_info.type == MediaType.MOVIE:
|
if t.media_info.type == MediaType.MOVIE:
|
||||||
# 电影
|
# 电影
|
||||||
@@ -96,14 +90,15 @@ class AddDownloadAction(BaseAction):
|
|||||||
exists_episodes = exists_seasons.get(t.meta_info.begin_season)
|
exists_episodes = exists_seasons.get(t.meta_info.begin_season)
|
||||||
if exists_episodes:
|
if exists_episodes:
|
||||||
if set(t.meta_info.episode_list).issubset(exists_episodes):
|
if set(t.meta_info.episode_list).issubset(exists_episodes):
|
||||||
logger.warning(f"{t.meta_info.title} 第 {t.meta_info.begin_season} 季第 {t.meta_info.episode_list} 集已存在,跳过")
|
logger.warning(
|
||||||
|
f"{t.meta_info.title} 第 {t.meta_info.begin_season} 季第 {t.meta_info.episode_list} 集已存在,跳过")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
_started = True
|
_started = True
|
||||||
did = self.downloadchain.download_single(context=t,
|
did = DownloadChain().download_single(context=t,
|
||||||
downloader=params.downloader,
|
downloader=params.downloader,
|
||||||
save_path=params.save_path,
|
save_path=params.save_path,
|
||||||
label=params.labels)
|
label=params.labels)
|
||||||
if did:
|
if did:
|
||||||
self._added_downloads.append(did)
|
self._added_downloads.append(did)
|
||||||
# 保存缓存
|
# 保存缓存
|
||||||
|
|||||||
@@ -19,29 +19,24 @@ class AddSubscribeAction(BaseAction):
|
|||||||
添加订阅
|
添加订阅
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_added_subscribes = []
|
|
||||||
_has_error = False
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self.subscribechain = SubscribeChain()
|
|
||||||
self.subscribeoper = SubscribeOper()
|
|
||||||
self._added_subscribes = []
|
self._added_subscribes = []
|
||||||
self._has_error = False
|
self._has_error = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def name(cls) -> str: # noqa
|
def name(cls) -> str: # noqa
|
||||||
return "添加订阅"
|
return "添加订阅"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def description(cls) -> str: # noqa
|
def description(cls) -> str: # noqa
|
||||||
return "根据媒体列表添加订阅"
|
return "根据媒体列表添加订阅"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def data(cls) -> dict: # noqa
|
def data(cls) -> dict: # noqa
|
||||||
return AddSubscribeParams().dict()
|
return AddSubscribeParams().dict()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -63,19 +58,20 @@ class AddSubscribeAction(BaseAction):
|
|||||||
continue
|
continue
|
||||||
mediainfo = MediaInfo()
|
mediainfo = MediaInfo()
|
||||||
mediainfo.from_dict(media.dict())
|
mediainfo.from_dict(media.dict())
|
||||||
if self.subscribechain.exists(mediainfo):
|
subscribechain = SubscribeChain()
|
||||||
|
if subscribechain.exists(mediainfo):
|
||||||
logger.info(f"{media.title} 已存在订阅")
|
logger.info(f"{media.title} 已存在订阅")
|
||||||
continue
|
continue
|
||||||
# 添加订阅
|
# 添加订阅
|
||||||
_started = True
|
_started = True
|
||||||
sid, message = self.subscribechain.add(mtype=mediainfo.type,
|
sid, message = subscribechain.add(mtype=mediainfo.type,
|
||||||
title=mediainfo.title,
|
title=mediainfo.title,
|
||||||
year=mediainfo.year,
|
year=mediainfo.year,
|
||||||
tmdbid=mediainfo.tmdb_id,
|
tmdbid=mediainfo.tmdb_id,
|
||||||
season=mediainfo.season,
|
season=mediainfo.season,
|
||||||
doubanid=mediainfo.douban_id,
|
doubanid=mediainfo.douban_id,
|
||||||
bangumiid=mediainfo.bangumi_id,
|
bangumiid=mediainfo.bangumi_id,
|
||||||
username=settings.SUPERUSER)
|
username=settings.SUPERUSER)
|
||||||
if sid:
|
if sid:
|
||||||
self._added_subscribes.append(sid)
|
self._added_subscribes.append(sid)
|
||||||
# 保存缓存
|
# 保存缓存
|
||||||
@@ -84,7 +80,7 @@ class AddSubscribeAction(BaseAction):
|
|||||||
if self._added_subscribes:
|
if self._added_subscribes:
|
||||||
logger.info(f"已添加 {len(self._added_subscribes)} 个订阅")
|
logger.info(f"已添加 {len(self._added_subscribes)} 个订阅")
|
||||||
for sid in self._added_subscribes:
|
for sid in self._added_subscribes:
|
||||||
context.subscribes.append(self.subscribeoper.get(sid))
|
context.subscribes.append(SubscribeOper().get(sid))
|
||||||
elif _started:
|
elif _started:
|
||||||
self._has_error = True
|
self._has_error = True
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,8 @@ class FetchDownloadsAction(BaseAction):
|
|||||||
获取下载任务
|
获取下载任务
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_downloads = []
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self.chain = ActionChain()
|
|
||||||
self._downloads = []
|
self._downloads = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -51,7 +48,7 @@ class FetchDownloadsAction(BaseAction):
|
|||||||
if global_vars.is_workflow_stopped(workflow_id):
|
if global_vars.is_workflow_stopped(workflow_id):
|
||||||
break
|
break
|
||||||
logger.info(f"获取下载任务 {download.download_id} 状态 ...")
|
logger.info(f"获取下载任务 {download.download_id} 状态 ...")
|
||||||
torrents = self.chain.list_torrents(hashs=[download.download_id])
|
torrents = ActionChain().list_torrents(hashs=[download.download_id])
|
||||||
if not torrents:
|
if not torrents:
|
||||||
download.completed = True
|
download.completed = True
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ class FetchMediasAction(BaseAction):
|
|||||||
获取媒体数据
|
获取媒体数据
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_inner_sources = []
|
|
||||||
_medias = []
|
|
||||||
_has_error = False
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
|
|
||||||
|
|||||||
@@ -29,29 +29,24 @@ class FetchRssAction(BaseAction):
|
|||||||
获取RSS资源列表
|
获取RSS资源列表
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_rss_torrents = []
|
|
||||||
_has_error = False
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self.rsshelper = RssHelper()
|
|
||||||
self.chain = ActionChain()
|
|
||||||
self._rss_torrents = []
|
self._rss_torrents = []
|
||||||
self._has_error = False
|
self._has_error = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def name(cls) -> str: # noqa
|
def name(cls) -> str: # noqa
|
||||||
return "获取RSS资源"
|
return "获取RSS资源"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def description(cls) -> str: # noqa
|
def description(cls) -> str: # noqa
|
||||||
return "订阅RSS地址获取资源"
|
return "订阅RSS地址获取资源"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def data(cls) -> dict: # noqa
|
def data(cls) -> dict: # noqa
|
||||||
return FetchRssParams().dict()
|
return FetchRssParams().dict()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -74,10 +69,10 @@ class FetchRssAction(BaseAction):
|
|||||||
if params.ua:
|
if params.ua:
|
||||||
headers["User-Agent"] = params.ua
|
headers["User-Agent"] = params.ua
|
||||||
|
|
||||||
rss_items = self.rsshelper.parse(url=params.url,
|
rss_items = RssHelper().parse(url=params.url,
|
||||||
proxy=settings.PROXY if params.proxy else None,
|
proxy=settings.PROXY if params.proxy else None,
|
||||||
timeout=params.timeout,
|
timeout=params.timeout,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
if rss_items is None or rss_items is False:
|
if rss_items is None or rss_items is False:
|
||||||
logger.error(f'RSS地址 {params.url} 请求失败!')
|
logger.error(f'RSS地址 {params.url} 请求失败!')
|
||||||
self._has_error = True
|
self._has_error = True
|
||||||
@@ -103,7 +98,7 @@ class FetchRssAction(BaseAction):
|
|||||||
meta = MetaInfo(title=torrentinfo.title, subtitle=torrentinfo.description)
|
meta = MetaInfo(title=torrentinfo.title, subtitle=torrentinfo.description)
|
||||||
mediainfo = None
|
mediainfo = None
|
||||||
if params.match_media:
|
if params.match_media:
|
||||||
mediainfo = self.chain.recognize_media(meta)
|
mediainfo = ActionChain().recognize_media(meta)
|
||||||
if not mediainfo:
|
if not mediainfo:
|
||||||
logger.warning(f"{torrentinfo.title} 未识别到媒体信息")
|
logger.warning(f"{torrentinfo.title} 未识别到媒体信息")
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -29,26 +29,23 @@ class FetchTorrentsAction(BaseAction):
|
|||||||
搜索站点资源
|
搜索站点资源
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_torrents = []
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self.searchchain = SearchChain()
|
|
||||||
self._torrents = []
|
self._torrents = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def name(cls) -> str: # noqa
|
def name(cls) -> str: # noqa
|
||||||
return "搜索站点资源"
|
return "搜索站点资源"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def description(cls) -> str: # noqa
|
def description(cls) -> str: # noqa
|
||||||
return "搜索站点种子资源列表"
|
return "搜索站点种子资源列表"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def data(cls) -> dict: # noqa
|
def data(cls) -> dict: # noqa
|
||||||
return FetchTorrentsParams().dict()
|
return FetchTorrentsParams().dict()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -60,9 +57,10 @@ class FetchTorrentsAction(BaseAction):
|
|||||||
搜索站点,获取资源列表
|
搜索站点,获取资源列表
|
||||||
"""
|
"""
|
||||||
params = FetchTorrentsParams(**params)
|
params = FetchTorrentsParams(**params)
|
||||||
|
searchchain = SearchChain()
|
||||||
if params.search_type == "keyword":
|
if params.search_type == "keyword":
|
||||||
# 按关键字搜索
|
# 按关键字搜索
|
||||||
torrents = self.searchchain.search_by_title(title=params.name, sites=params.sites)
|
torrents = searchchain.search_by_title(title=params.name, sites=params.sites)
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
if global_vars.is_workflow_stopped(workflow_id):
|
if global_vars.is_workflow_stopped(workflow_id):
|
||||||
break
|
break
|
||||||
@@ -74,7 +72,7 @@ class FetchTorrentsAction(BaseAction):
|
|||||||
continue
|
continue
|
||||||
# 识别媒体信息
|
# 识别媒体信息
|
||||||
if params.match_media:
|
if params.match_media:
|
||||||
torrent.media_info = self.searchchain.recognize_media(torrent.meta_info)
|
torrent.media_info = searchchain.recognize_media(torrent.meta_info)
|
||||||
if not torrent.media_info:
|
if not torrent.media_info:
|
||||||
logger.warning(f"{torrent.torrent_info.title} 未识别到媒体信息")
|
logger.warning(f"{torrent.torrent_info.title} 未识别到媒体信息")
|
||||||
continue
|
continue
|
||||||
@@ -84,10 +82,10 @@ class FetchTorrentsAction(BaseAction):
|
|||||||
for media in context.medias:
|
for media in context.medias:
|
||||||
if global_vars.is_workflow_stopped(workflow_id):
|
if global_vars.is_workflow_stopped(workflow_id):
|
||||||
break
|
break
|
||||||
torrents = self.searchchain.search_by_id(tmdbid=media.tmdb_id,
|
torrents = searchchain.search_by_id(tmdbid=media.tmdb_id,
|
||||||
doubanid=media.douban_id,
|
doubanid=media.douban_id,
|
||||||
mtype=MediaType(media.type),
|
mtype=MediaType(media.type),
|
||||||
sites=params.sites)
|
sites=params.sites)
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
self._torrents.append(torrent)
|
self._torrents.append(torrent)
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ class FilterMediasAction(BaseAction):
|
|||||||
过滤媒体数据
|
过滤媒体数据
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_medias = []
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self._medias = []
|
self._medias = []
|
||||||
|
|||||||
@@ -27,12 +27,8 @@ class FilterTorrentsAction(BaseAction):
|
|||||||
过滤资源数据
|
过滤资源数据
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_torrents = []
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self.torrenthelper = TorrentHelper()
|
|
||||||
self.chain = ActionChain()
|
|
||||||
self._torrents = []
|
self._torrents = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -62,7 +58,7 @@ class FilterTorrentsAction(BaseAction):
|
|||||||
for torrent in context.torrents:
|
for torrent in context.torrents:
|
||||||
if global_vars.is_workflow_stopped(workflow_id):
|
if global_vars.is_workflow_stopped(workflow_id):
|
||||||
break
|
break
|
||||||
if self.torrenthelper.filter_torrent(
|
if TorrentHelper().filter_torrent(
|
||||||
torrent_info=torrent.torrent_info,
|
torrent_info=torrent.torrent_info,
|
||||||
filter_params={
|
filter_params={
|
||||||
"quality": params.quality,
|
"quality": params.quality,
|
||||||
@@ -73,7 +69,7 @@ class FilterTorrentsAction(BaseAction):
|
|||||||
"size": params.size
|
"size": params.size
|
||||||
}
|
}
|
||||||
):
|
):
|
||||||
if self.chain.filter_torrents(
|
if ActionChain().filter_torrents(
|
||||||
rule_groups=params.rule_groups,
|
rule_groups=params.rule_groups,
|
||||||
torrent_list=[torrent.torrent_info],
|
torrent_list=[torrent.torrent_info],
|
||||||
mediainfo=torrent.media_info
|
mediainfo=torrent.media_info
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ class InvokePluginAction(BaseAction):
|
|||||||
调用插件
|
调用插件
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_success = False
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self._success = False
|
self._success = False
|
||||||
|
|||||||
@@ -24,12 +24,8 @@ class ScanFileAction(BaseAction):
|
|||||||
整理文件
|
整理文件
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_fileitems = []
|
|
||||||
_has_error = False
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self.storagechain = StorageChain()
|
|
||||||
self._fileitems = []
|
self._fileitems = []
|
||||||
self._has_error = False
|
self._has_error = False
|
||||||
|
|
||||||
@@ -59,12 +55,13 @@ class ScanFileAction(BaseAction):
|
|||||||
params = ScanFileParams(**params)
|
params = ScanFileParams(**params)
|
||||||
if not params.storage or not params.directory:
|
if not params.storage or not params.directory:
|
||||||
return context
|
return context
|
||||||
fileitem = self.storagechain.get_file_item(params.storage, Path(params.directory))
|
storagechain = StorageChain()
|
||||||
|
fileitem = storagechain.get_file_item(params.storage, Path(params.directory))
|
||||||
if not fileitem:
|
if not fileitem:
|
||||||
logger.error(f"目录不存在: 【{params.storage}】{params.directory}")
|
logger.error(f"目录不存在: 【{params.storage}】{params.directory}")
|
||||||
self._has_error = True
|
self._has_error = True
|
||||||
return context
|
return context
|
||||||
files = self.storagechain.list_files(fileitem, recursion=True)
|
files = storagechain.list_files(fileitem, recursion=True)
|
||||||
for file in files:
|
for file in files:
|
||||||
if global_vars.is_workflow_stopped(workflow_id):
|
if global_vars.is_workflow_stopped(workflow_id):
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -21,13 +21,8 @@ class ScrapeFileAction(BaseAction):
|
|||||||
刮削文件
|
刮削文件
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_scraped_files = []
|
|
||||||
_has_error = False
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self.storagechain = StorageChain()
|
|
||||||
self.mediachain = MediaChain()
|
|
||||||
self._scraped_files = []
|
self._scraped_files = []
|
||||||
self._has_error = False
|
self._has_error = False
|
||||||
|
|
||||||
@@ -61,7 +56,7 @@ class ScrapeFileAction(BaseAction):
|
|||||||
break
|
break
|
||||||
if fileitem in self._scraped_files:
|
if fileitem in self._scraped_files:
|
||||||
continue
|
continue
|
||||||
if not self.storagechain.exists(fileitem):
|
if not StorageChain().exists(fileitem):
|
||||||
continue
|
continue
|
||||||
# 检查缓存
|
# 检查缓存
|
||||||
cache_key = f"{fileitem.path}"
|
cache_key = f"{fileitem.path}"
|
||||||
@@ -69,12 +64,13 @@ class ScrapeFileAction(BaseAction):
|
|||||||
logger.info(f"{fileitem.path} 已刮削过,跳过")
|
logger.info(f"{fileitem.path} 已刮削过,跳过")
|
||||||
continue
|
continue
|
||||||
meta = MetaInfoPath(Path(fileitem.path))
|
meta = MetaInfoPath(Path(fileitem.path))
|
||||||
mediainfo = self.mediachain.recognize_media(meta)
|
mediachain = MediaChain()
|
||||||
|
mediainfo = mediachain.recognize_media(meta)
|
||||||
if not mediainfo:
|
if not mediainfo:
|
||||||
_failed_count += 1
|
_failed_count += 1
|
||||||
logger.info(f"{fileitem.path} 未识别到媒体信息,无法刮削")
|
logger.info(f"{fileitem.path} 未识别到媒体信息,无法刮削")
|
||||||
continue
|
continue
|
||||||
self.mediachain.scrape_metadata(fileitem=fileitem, meta=meta, mediainfo=mediainfo)
|
mediachain.scrape_metadata(fileitem=fileitem, meta=meta, mediainfo=mediainfo)
|
||||||
self._scraped_files.append(fileitem)
|
self._scraped_files.append(fileitem)
|
||||||
# 保存缓存
|
# 保存缓存
|
||||||
self.save_cache(workflow_id, cache_key)
|
self.save_cache(workflow_id, cache_key)
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ class SendMessageAction(BaseAction):
|
|||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self.chain = ActionChain()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
@@ -60,7 +59,7 @@ class SendMessageAction(BaseAction):
|
|||||||
if not params.client:
|
if not params.client:
|
||||||
params.client = [""]
|
params.client = [""]
|
||||||
for client in params.client:
|
for client in params.client:
|
||||||
self.chain.post_message(
|
ActionChain().post_message(
|
||||||
Notification(
|
Notification(
|
||||||
source=client,
|
source=client,
|
||||||
userid=params.userid,
|
userid=params.userid,
|
||||||
|
|||||||
@@ -26,30 +26,24 @@ class TransferFileAction(BaseAction):
|
|||||||
整理文件
|
整理文件
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_fileitems = []
|
|
||||||
_has_error = False
|
|
||||||
|
|
||||||
def __init__(self, action_id: str):
|
def __init__(self, action_id: str):
|
||||||
super().__init__(action_id)
|
super().__init__(action_id)
|
||||||
self.transferchain = TransferChain()
|
|
||||||
self.storagechain = StorageChain()
|
|
||||||
self.transferhis = TransferHistoryOper()
|
|
||||||
self._fileitems = []
|
self._fileitems = []
|
||||||
self._has_error = False
|
self._has_error = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def name(cls) -> str: # noqa
|
def name(cls) -> str: # noqa
|
||||||
return "整理文件"
|
return "整理文件"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def description(cls) -> str: # noqa
|
def description(cls) -> str: # noqa
|
||||||
return "整理队列中的文件"
|
return "整理队列中的文件"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def data(cls) -> dict: # noqa
|
def data(cls) -> dict: # noqa
|
||||||
return TransferFileParams().dict()
|
return TransferFileParams().dict()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -72,6 +66,9 @@ class TransferFileAction(BaseAction):
|
|||||||
params = TransferFileParams(**params)
|
params = TransferFileParams(**params)
|
||||||
# 失败次数
|
# 失败次数
|
||||||
_failed_count = 0
|
_failed_count = 0
|
||||||
|
storagechain = StorageChain()
|
||||||
|
transferchain = TransferChain()
|
||||||
|
transferhis = TransferHistoryOper()
|
||||||
if params.source == "downloads":
|
if params.source == "downloads":
|
||||||
# 从下载任务中整理文件
|
# 从下载任务中整理文件
|
||||||
for download in context.downloads:
|
for download in context.downloads:
|
||||||
@@ -85,16 +82,16 @@ class TransferFileAction(BaseAction):
|
|||||||
if self.check_cache(workflow_id, cache_key):
|
if self.check_cache(workflow_id, cache_key):
|
||||||
logger.info(f"{download.path} 已整理过,跳过")
|
logger.info(f"{download.path} 已整理过,跳过")
|
||||||
continue
|
continue
|
||||||
fileitem = self.storagechain.get_file_item(storage="local", path=Path(download.path))
|
fileitem = storagechain.get_file_item(storage="local", path=Path(download.path))
|
||||||
if not fileitem:
|
if not fileitem:
|
||||||
logger.info(f"文件 {download.path} 不存在")
|
logger.info(f"文件 {download.path} 不存在")
|
||||||
continue
|
continue
|
||||||
transferd = self.transferhis.get_by_src(fileitem.path, storage=fileitem.storage)
|
transferd = transferhis.get_by_src(fileitem.path, storage=fileitem.storage)
|
||||||
if transferd:
|
if transferd:
|
||||||
# 已经整理过的文件不再整理
|
# 已经整理过的文件不再整理
|
||||||
continue
|
continue
|
||||||
logger.info(f"开始整理文件 {download.path} ...")
|
logger.info(f"开始整理文件 {download.path} ...")
|
||||||
state, errmsg = self.transferchain.do_transfer(fileitem, background=False)
|
state, errmsg = transferchain.do_transfer(fileitem, background=False)
|
||||||
if not state:
|
if not state:
|
||||||
_failed_count += 1
|
_failed_count += 1
|
||||||
logger.error(f"整理文件 {download.path} 失败: {errmsg}")
|
logger.error(f"整理文件 {download.path} 失败: {errmsg}")
|
||||||
@@ -112,13 +109,13 @@ class TransferFileAction(BaseAction):
|
|||||||
if self.check_cache(workflow_id, cache_key):
|
if self.check_cache(workflow_id, cache_key):
|
||||||
logger.info(f"{fileitem.path} 已整理过,跳过")
|
logger.info(f"{fileitem.path} 已整理过,跳过")
|
||||||
continue
|
continue
|
||||||
transferd = self.transferhis.get_by_src(fileitem.path, storage=fileitem.storage)
|
transferd = transferhis.get_by_src(fileitem.path, storage=fileitem.storage)
|
||||||
if transferd:
|
if transferd:
|
||||||
# 已经整理过的文件不再整理
|
# 已经整理过的文件不再整理
|
||||||
continue
|
continue
|
||||||
logger.info(f"开始整理文件 {fileitem.path} ...")
|
logger.info(f"开始整理文件 {fileitem.path} ...")
|
||||||
state, errmsg = self.transferchain.do_transfer(fileitem, background=False,
|
state, errmsg = transferchain.do_transfer(fileitem, background=False,
|
||||||
continue_callback=check_continue)
|
continue_callback=check_continue)
|
||||||
if not state:
|
if not state:
|
||||||
_failed_count += 1
|
_failed_count += 1
|
||||||
logger.error(f"整理文件 {fileitem.path} 失败: {errmsg}")
|
logger.error(f"整理文件 {fileitem.path} 失败: {errmsg}")
|
||||||
|
|||||||
Reference in New Issue
Block a user