mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
fix actions
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
from app.actions import BaseAction
|
||||
from app.schemas import ActionParams, ActionContext
|
||||
from chain.media import MediaChain
|
||||
from chain.storage import StorageChain
|
||||
from core.metainfo import MetaInfoPath
|
||||
from log import logger
|
||||
|
||||
|
||||
class ScrapeFileParams(ActionParams):
|
||||
@@ -14,6 +18,13 @@ class ScrapeFileAction(BaseAction):
|
||||
刮削文件
|
||||
"""
|
||||
|
||||
__scraped_files = []
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.storagechain = StorageChain()
|
||||
self.mediachain = MediaChain()
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "刮削文件"
|
||||
@@ -24,7 +35,24 @@ class ScrapeFileAction(BaseAction):
|
||||
|
||||
@property
|
||||
def success(self) -> bool:
|
||||
return True
|
||||
return True if self.__scraped_files else False
|
||||
|
||||
async def execute(self, params: ScrapeFileParams, context: ActionContext) -> ActionContext:
|
||||
pass
|
||||
"""
|
||||
刮削fileitems中的所有文件
|
||||
"""
|
||||
for fileitem in context.fileitems:
|
||||
if fileitem in self.__scraped_files:
|
||||
continue
|
||||
if not self.storagechain.exists(fileitem):
|
||||
continue
|
||||
meta = MetaInfoPath(fileitem.path)
|
||||
mediainfo = self.chain.recognize_media(meta)
|
||||
if not mediainfo:
|
||||
logger.info(f"{fileitem.path} 未识别到媒体信息,无法刮削")
|
||||
continue
|
||||
self.mediachain.scrape_metadata(fileitem=fileitem, meta=meta, mediainfo=mediainfo)
|
||||
self.__scraped_files.append(fileitem)
|
||||
|
||||
self.job_done()
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user