mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-13 17:39:52 +08:00
Fix remove torrent bug
This commit is contained in:
@@ -168,19 +168,20 @@ class BangumiDatabase(DataConnector):
|
||||
dict_data = dict(zip(keys, values))
|
||||
return self.__db_to_data(dict_data)
|
||||
|
||||
def match_poster(self, torrent_name: str) -> tuple[str, str]:
|
||||
def match_poster(self, bangumi_name: str) -> str:
|
||||
# Find title_raw which in torrent_name
|
||||
self._cursor.execute(
|
||||
"""
|
||||
SELECT title_raw, poster_link, official_title FROM bangumi
|
||||
SELECT official_title, poster_link FROM bangumi
|
||||
"""
|
||||
)
|
||||
data = self._cursor.fetchall()
|
||||
if not data:
|
||||
return "", ""
|
||||
for title_raw, poster_link, official_title in data:
|
||||
if title_raw in torrent_name:
|
||||
return poster_link, official_title
|
||||
return ""
|
||||
for official_title, poster_link in data:
|
||||
if official_title in bangumi_name:
|
||||
return poster_link
|
||||
return ""
|
||||
|
||||
def match_list(self, title_dict: dict, rss_link: str) -> dict:
|
||||
# Match title_raw in database
|
||||
@@ -233,6 +234,6 @@ class BangumiDatabase(DataConnector):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
title = "[Lilith-Raws] Boku no Kokoro no Yabai Yatsu - 01 [Baha][WEB-DL][1080p][AVC AAC][CHT][MP4].mp4"
|
||||
title = "[SweetSub&LoliHouse] Heavenly Delusion - 06 [WebRip 1080p HEVC-10bit AAC ASSx2].mkv"
|
||||
with BangumiDatabase() as db:
|
||||
print(db.match_poster(title))
|
||||
@@ -66,14 +66,12 @@ class Renamer(DownloadClient):
|
||||
return f"{bangumi_name} S{season}E{episode}.{file_info.language}{file_info.suffix}"
|
||||
|
||||
@staticmethod
|
||||
def send_notification(torrent_name, ep: EpisodeFile):
|
||||
def send_notification(bangumi_name, ep: EpisodeFile):
|
||||
with BangumiDatabase() as db:
|
||||
poster_path, official_name = db.match_poster(torrent_name)
|
||||
poster_link = settings.rss_parser.custom_url + poster_path
|
||||
if "://" not in poster_link:
|
||||
poster_link = "https://" + poster_link
|
||||
poster_path = db.match_poster(bangumi_name)
|
||||
poster_link = "https://mikanani.me" + poster_path
|
||||
n = Notification(
|
||||
title=official_name,
|
||||
official_title=bangumi_name,
|
||||
season=ep.season,
|
||||
episode=ep.episode,
|
||||
poster_link=poster_link,
|
||||
@@ -105,8 +103,8 @@ class Renamer(DownloadClient):
|
||||
renamed = self.rename_torrent_file(_hash=_hash, old_path=media_path, new_path=new_path)
|
||||
if renamed:
|
||||
if settings.notification.enable:
|
||||
self.send_notification(torrent_name, ep)
|
||||
return
|
||||
self.send_notification(bangumi_name, ep)
|
||||
return True
|
||||
logger.warning(f"{media_path} parse failed")
|
||||
if settings.bangumi_manage.remove_bad_torrent:
|
||||
self.delete_torrent(hashes=_hash)
|
||||
|
||||
Reference in New Issue
Block a user