Skip to content

Commit

Permalink
Merge pull request jxxghp#2093 from thsrite/main
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp authored May 16, 2024
2 parents 125e9eb + c56b58c commit 92cdd67
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/chain/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def __init__(self):
self.mediaserver = MediaServerOper()

def post_download_message(self, meta: MetaBase, mediainfo: MediaInfo, torrent: TorrentInfo,
channel: MessageChannel = None, userid: str = None, username: str = None):
channel: MessageChannel = None, userid: str = None, username: str = None,
download_episodes: str = None):
"""
发送添加下载的消息
:param meta: 元数据
Expand Down Expand Up @@ -80,7 +81,7 @@ def post_download_message(self, meta: MetaBase, mediainfo: MediaInfo, torrent: T
mtype=NotificationType.Download,
userid=userid,
title=f"{mediainfo.title_year} "
f"{meta.season_episode} 开始下载",
f"{'%s %s' % (meta.season, download_episodes) if download_episodes else meta.season_episode} 开始下载",
text=msg_text,
image=mediainfo.get_message_image()))

Expand Down Expand Up @@ -207,6 +208,9 @@ def download_single(self, context: Context, torrent_file: Path = None,
_torrent = context.torrent_info
_media = context.media_info
_meta = context.meta_info

# 实际下载的集数
download_episodes = StringUtils.format_ep(list(episodes)) if episodes else None
_folder_name = ""
if not torrent_file:
# 下载种子文件,得到的可能是文件也可能是磁力链
Expand Down Expand Up @@ -284,7 +288,7 @@ def download_single(self, context: Context, torrent_file: Path = None,
tvdbid=_media.tvdb_id,
doubanid=_media.douban_id,
seasons=_meta.season,
episodes=_meta.episode,
episodes=download_episodes or _meta.episode,
image=_media.get_backdrop_image(),
download_hash=_hash,
torrent_name=_torrent.title,
Expand Down Expand Up @@ -321,7 +325,8 @@ def download_single(self, context: Context, torrent_file: Path = None,
self.downloadhis.add_files(files_to_add)

# 发送消息(群发,不带channel和userid)
self.post_download_message(meta=_meta, mediainfo=_media, torrent=_torrent, username=username)
self.post_download_message(meta=_meta, mediainfo=_media, torrent=_torrent,
username=username, download_episodes=download_episodes)
# 下载成功后处理
self.download_added(context=context, download_dir=download_dir, torrent_path=torrent_file)
# 广播事件
Expand Down

0 comments on commit 92cdd67

Please sign in to comment.