Skip to content

Commit

Permalink
Fix renamer 不能重命名1000集以上的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
EstrellaXD committed May 4, 2023
1 parent 1cf2865 commit 1734d8a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/module/downloader/qb_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def torrents_add(self, urls, save_path, category):

def torrents_delete(self, hash):
return self._client.torrents_delete(
delete_files=False,
delete_files=True,
torrent_hashes=hash
)

Expand Down
11 changes: 9 additions & 2 deletions src/module/parser/analyser/torrent_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class DownloadInfo:

RULES = [
r"(.*) - (\d{1,4}|\d{1,4}\.\d{1,2})(?:v\d{1,2})?(?: )?(?:END)?(.*)",
r"(.*)[\[ E](\d{1,3}|\d{1,3}\.\d{1,2})(?:v\d{1,2})?(?: )?(?:END)?[\] ](.*)",
r"(.*)[\[\ E](\d{1,4}|\d{1,4}\.\d{1,2})(?:v\d{1,2})?(?: )?(?:END)?[\]\ ](.*)",
r"(.*)\[(?:第)?(\d*\.*\d*)[话集話](?:END)?\](.*)",
r"(.*)第(\d*\.*\d*)[话話集](?:END)?(.*)",
r"(.*)EP?(\d{1,4})(.*)",
r"(.*)(?<!\w)EP?(\d+)(?!\w)(.*)",
]

SUBTITLE_LANG = {
Expand Down Expand Up @@ -159,3 +159,10 @@ def torrent_parser(
info = rename_init(file_name, folder_name, season, suffix)
return METHODS[method.lower()](info)


if __name__ == '__main__':
title = "[MagicStar] 假面骑士Geats / 仮面ライダーギーツ EP33 [WEBDL] [1080p] [TTFC]【生】"
folder_name = "名侦探柯南"
season = 1
suffix = ".mp4"
print(torrent_parser(title, folder_name, season, suffix, method="pn"))
9 changes: 9 additions & 0 deletions src/test/test_raw_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,12 @@ def test_raw_parser():
assert info.resolution == "1080P"
assert info.episode == 2
assert info.season == 1

content = "[MagicStar] 假面骑士Geats / 仮面ライダーギーツ EP33 [WEBDL] [1080p] [TTFC]【生】"
info = raw_parser(content)
assert info.group == "MagicStar"
assert info.title_zh == "假面骑士Geats"
assert info.title_jp == "仮面ライダーギーツ"
assert info.resolution == "1080p"
assert info.episode == 33
assert info.season == 1
16 changes: 15 additions & 1 deletion src/test/test_torrent_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,18 @@ def test_torrent_parser():
season = 1
suffix = ".mkv"
assert torrent_parser(file_name, folder_name, season, suffix, "pn") == "Heavenly Delusion S01E01.mkv"
assert torrent_parser(file_name, folder_name, season, suffix, "advance") == "天国大魔境(2023) S01E01.mkv"
assert torrent_parser(file_name, folder_name, season, suffix, "advance") == "天国大魔境(2023) S01E01.mkv"

file_name = "[SBSUB][Kanojo mo Kanojo][01][GB][1080P](456E234).mp4"
folder_name = "女友也要有"
season = 1
suffix = ".mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn") == "Kanojo mo Kanojo S01E01.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance") == "女友也要有 S01E01.mp4"

file_name = "[SBSUB][CONAN][1082][V2][1080P][AVC_AAC][CHS_JP](C1E4E331).mp4"
folder_name = "名侦探柯南(1996)"
season = 1
suffix = ".mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "pn") == "CONAN S01E1082.mp4"
assert torrent_parser(file_name, folder_name, season, suffix, "advance") == "名侦探柯南(1996) S01E1082.mp4"

0 comments on commit 1734d8a

Please sign in to comment.