Skip to content

Commit

Permalink
fix: fixed remux and shang-chi title returning as chinese
Browse files Browse the repository at this point in the history
  • Loading branch information
dreulavelle committed Aug 27, 2024
1 parent 726a6de commit 6088ce3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
5 changes: 3 additions & 2 deletions PTT/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def add_defaults(parser: Parser):
parser.add_handler("quality", regex.compile(r"\bBlu[ .-]*Ray\b(?=.*remux)", regex.IGNORECASE), value("BluRay REMUX"), {"remove": True})
parser.add_handler("quality", regex.compile(r"(?:BD|BR|UHD)[- ]?remux", regex.IGNORECASE), value("BluRay REMUX"), {"remove": True})
parser.add_handler("quality", regex.compile(r"(?<=remux.*)\bBlu[ .-]*Ray\b", regex.IGNORECASE), value("BluRay REMUX"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\bremux\b", regex.IGNORECASE), value("REMUX"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\bBlu[ .-]*Ray\b(?![ .-]*Rip)", regex.IGNORECASE), value("BluRay"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\bUHD[ .-]*Rip\b", regex.IGNORECASE), value("UHDRip"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\bHD[ .-]*Rip\b", regex.IGNORECASE), value("HDRip"), {"remove": True})
Expand Down Expand Up @@ -374,8 +375,8 @@ def handle_episodes(context):
parser.add_handler("languages", regex.compile(r"\b(?:traditional\W*chinese|chinese\W*traditional)(?:\Wchi)?\b", regex.IGNORECASE), uniq_concat(value("zh")), {"skipIfAlreadyFound": False, "remove": True})
parser.add_handler("languages", regex.compile(r"\bzh-hant\b", regex.IGNORECASE), uniq_concat(value("zh")), {"skipIfAlreadyFound": False})
parser.add_handler("languages", regex.compile(r"\b(?:mand[ae]rin|ch[sn])\b", regex.IGNORECASE), uniq_concat(value("zh")), {"skipIfAlreadyFound": False})
parser.add_handler("languages", regex.compile(r"\bCH[IT]\b", regex.IGNORECASE), uniq_concat(value("zh")), {"skipFromTitle": True, "skipIfAlreadyFound": False})
parser.add_handler("languages", regex.compile(r"\b(chinese|chin[eê]s|chi)\b", regex.IGNORECASE), uniq_concat(value("zh")), {"skipIfFirst": True, "skipIfAlreadyFound": False})
parser.add_handler("languages", regex.compile(r"(?<!shang-?)\bCH(?:I|T)\b", regex.IGNORECASE), uniq_concat(value("zh")), {"skipFromTitle": True, "skipIfAlreadyFound": False})
parser.add_handler("languages", regex.compile(r"\b(chinese|chin[eê]s)\b", regex.IGNORECASE), uniq_concat(value("zh")), {"skipIfFirst": True, "skipIfAlreadyFound": False})
parser.add_handler("languages", regex.compile(r"\bzh-hans\b", regex.IGNORECASE), uniq_concat(value("zh")), {"skipIfAlreadyFound": False})
parser.add_handler("languages", regex.compile(r"\bFR(?:ench|a|e|anc[eê]s)?\b", regex.IGNORECASE), uniq_concat(value("fr")), {"skipIfAlreadyFound": False})
parser.add_handler("languages", regex.compile(r"\b(VOST(?:FR?|A)?)\b", regex.IGNORECASE), uniq_concat(value("fr")), {"skipIfAlreadyFound": False})
Expand Down
48 changes: 48 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,55 @@ def parser():
"group": "AMB3R",
"extension": "mkv",
"container": "mkv"
}),
("The Walking Dead S05E03 720p Remux x264-ASAP[ettv]", {
"title": "The Walking Dead",
"seasons": [5],
"episodes": [3],
"languages": [],
"quality": "REMUX",
"resolution": "720p",
"codec": "avc",
"group": "ASAP"
}),
("www.TamilBlasters.vip - Shang-Chi (2021) [720p BDRip - [Tamil + Telugu + Hindi + Eng] - x264 - DDP5.1 (192 Kbps) - 1.4GB - ESubs].mkv", {
# should not find "Shang-Chi" as chinese language
"title": "Shang-Chi",
"year": 2021,
"seasons": [],
"episodes": [],
"languages": ["en", "hi", "te", "ta"],
"quality": "BDRip",
"resolution": "720p",
"codec": "avc",
"audio": ["Dolby Digital Plus"],
"channels": ["5.1"],
"site": "www.TamilBlasters.vip",
"size": "1.4GB",
"extension": "mkv",
"container": "mkv"
})
])
def test_random_releases_parse(parser, release_name, expected):
assert parser.parse(release_name) == expected

# @pytest.mark.parametrize("release_name, expected", [
# ("www.TamilBlasters.vip - Shang-Chi (2021) [720p BDRip - [Tamil + Telugu + Hindi + Eng] - x264 - DDP5.1 (192 Kbps) - 1.4GB - ESubs].mkv", {
# "title": "Shang-Chi",
# "year": 2021,
# "seasons": [],
# "episodes": [],
# "languages": ["en", "hi", "te", "ta"],
# "quality": "BDRip",
# "resolution": "720p",
# "codec": "avc",
# "audio": ["Dolby Digital Plus"],
# "channels": ["5.1"],
# "site": "www.TamilBlasters.vip",
# "size": "1.4GB",
# "extension": "mkv",
# "container": "mkv"
# })
# ])
# def test_debug_releases_parse(parser, release_name, expected):
# assert parser.parse(release_name) == expected

0 comments on commit 6088ce3

Please sign in to comment.