mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
refactor: unify download chain data ports
This commit is contained in:
@@ -30,9 +30,9 @@ from app.domain.meta.metabase import MetaBase
|
||||
from app.domain.meta.metamusic import MetaMusic
|
||||
from app.domain.metainfo import MetaInfo
|
||||
from app.application.chain.data import (
|
||||
DownloadFailurePortProxy as DownloadFailureOper,
|
||||
DownloadHistoryPortProxy as DownloadHistoryOper,
|
||||
MediaServerPortProxy as MediaServerOper,
|
||||
get_chain_download_failure_port,
|
||||
get_chain_download_history_port,
|
||||
get_chain_media_server_port,
|
||||
)
|
||||
from app.application.directory import DirectoryHelper, validate_download_save_path
|
||||
from app.application.download.tasks import DownloadTaskService
|
||||
@@ -872,7 +872,7 @@ class DownloadChain(ChainBase):
|
||||
torrent = context.torrent_info
|
||||
site = getattr(torrent, "site", None)
|
||||
try:
|
||||
DownloadFailureOper().record_failure(
|
||||
get_chain_download_failure_port().record_failure(
|
||||
fingerprint=fingerprint,
|
||||
now_time=now_time,
|
||||
next_retry_at=next_retry_at,
|
||||
@@ -918,7 +918,7 @@ class DownloadChain(ChainBase):
|
||||
return {}
|
||||
now_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||||
try:
|
||||
return DownloadFailureOper().get_active_by_fingerprints(
|
||||
return get_chain_download_failure_port().get_active_by_fingerprints(
|
||||
fingerprints=fingerprints, now_time=now_time,
|
||||
)
|
||||
except Exception as err:
|
||||
@@ -1291,7 +1291,7 @@ class DownloadChain(ChainBase):
|
||||
publish=lambda payload: self.eventmanager.send_event(EventType.DownloadAdded, payload),
|
||||
)
|
||||
return
|
||||
downloadhis = DownloadHistoryOper()
|
||||
downloadhis = get_chain_download_history_port()
|
||||
downloadhis.add(**history_payload)
|
||||
if files_to_add:
|
||||
downloadhis.add_files(files_to_add)
|
||||
@@ -2075,7 +2075,7 @@ class DownloadChain(ChainBase):
|
||||
if not totals:
|
||||
totals = {}
|
||||
|
||||
mediaserver = MediaServerOper()
|
||||
mediaserver = get_chain_media_server_port()
|
||||
if mediainfo.type == MediaType.MOVIE:
|
||||
# 电影
|
||||
itemid = mediaserver.get_item_id(mtype=mediainfo.type.value,
|
||||
@@ -2263,7 +2263,7 @@ class DownloadChain(ChainBase):
|
||||
"""构造绑定当前下载器能力与历史仓储的任务服务。"""
|
||||
return DownloadTaskService(
|
||||
list_torrents=self.list_torrents,
|
||||
get_history_by_hashes=DownloadHistoryOper().get_by_hashes,
|
||||
get_history_by_hashes=get_chain_download_history_port().get_by_hashes,
|
||||
start_torrents=self.start_torrents,
|
||||
stop_torrents=self.stop_torrents,
|
||||
remove_torrents=self.remove_torrents,
|
||||
|
||||
Reference in New Issue
Block a user