Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PRE-HDRip to SCR quality & Replace Multi Spaces with Single in title #11

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PTT/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def add_defaults(parser: Parser):
parser.add_handler("quality", regex.compile(r"\b(?:H[DQ][ .-]*)?CAM(?:H[DQ])?(?:[ .-]*Rip)?\b", regex.IGNORECASE), value("CAM"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\b(?:H[DQ][ .-]*)?S[ \.\-]print", regex.IGNORECASE), value("CAM"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\b(?:HD[ .-]*)?T(?:ELE)?S(?:YNC)?(?:Rip)?\b", regex.IGNORECASE), value("TeleSync"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\bP(?:RE)?-?(HD|DVD)(?:Rip)?\b", regex.IGNORECASE), value("SCR"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\b(?:HD[ .-]*)?T(?:ELE)?C(?:INE)?(?:Rip)?\b"), value("TeleCine"), {"remove": True})
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})
Expand All @@ -130,7 +131,6 @@ def add_defaults(parser: Parser):
parser.add_handler("quality", regex.compile(r"\b(?:HD[ .-]*)?DVD[ .-]*Rip\b", regex.IGNORECASE), value("DVDRip"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\bVHS[ .-]*Rip\b", regex.IGNORECASE), value("DVDRip"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\b(?:DVD?|BD|BR)?[ .-]*Scr(?:eener)?\b", regex.IGNORECASE), value("SCR"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\bP(?:re)?DVD(?:Rip)?\b", regex.IGNORECASE), value("SCR"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\bDVD(?:R\d?)?\b", regex.IGNORECASE), value("DVD"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\bVHS\b", regex.IGNORECASE), value("DVD"), {"remove": True})
parser.add_handler("quality", regex.compile(r"\bPPVRip\b", regex.IGNORECASE), value("PPVRip"), {"remove": True})
Expand Down
2 changes: 2 additions & 0 deletions PTT/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
REMAINING_NOT_ALLOWED_SYMBOLS_AT_START_AND_END = regex.compile(rf"^[^\w{NON_ENGLISH_CHARS}#]+|]$")
REDUNDANT_SYMBOLS_AT_END = regex.compile(r"[ \-:./\\]+$")
EMPTY_BRACKETS_REGEX = regex.compile(r"\(\s*\)|\[\s*\]|\{\s*\}")
MULTIPLE_SPACES_REGEX = regex.compile(r"\s+")

DEBUG_HANDLER = False

Expand Down Expand Up @@ -134,6 +135,7 @@ def clean_title(raw_title: str) -> str:
cleaned_title = regex.sub(r"\.", " ", cleaned_title)

cleaned_title = REDUNDANT_SYMBOLS_AT_END.sub("", cleaned_title)
cleaned_title = MULTIPLE_SPACES_REGEX.sub(" ", cleaned_title)
cleaned_title = cleaned_title.strip()
return cleaned_title

Expand Down
124 changes: 63 additions & 61 deletions tests/test_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,67 +11,69 @@ def parser():
return p


@pytest.mark.parametrize("release_name, expected_quality", [
("Nocturnal Animals 2016 VFF 1080p BluRay DTS HEVC-HD2", "BluRay"),
("doctor_who_2005.8x12.death_in_heaven.720p_hdtv_x264-fov", "HDTV"),
("Rebecca.1940.720p.HDTVRip.HDCLUB", "HDTV"),
("Gossip Girl - 1ª Temporada. (SAT-Rip)", "SATRip"),
("A Stable Life S01E01 DVDRip x264-Ltu", "DVDRip"),
("The Vet Life S02E01 Dunk-A-Doctor 1080p ANPL WEB-DL AAC2 0 H 264-RTN", "WEB-DL"),
("Brown Nation S01E05 1080p WEBRip x264-JAWN", "WEBRip"),
("Star Wars The Last Jedi 2017 TeleSync AAC x264-MiniMe", "TeleSync"),
("The.Shape.of.Water.2017.DVDScr.XVID.AC3.HQ.Hive-CM8", "SCR"),
("Cloudy With A Chance Of Meatballs 2 2013 720p PPVRip x264 AAC-FooKaS", "PPVRip"),
("The.OA.1x08.L.Io.Invisibile.ITA.WEBMux.x264-UBi.mkv", "WEBMux"),
("[UsifRenegade] Cardcaptor Sakura [BD][Remastered][1080p][HEVC_10Bit][Dual] + Movies", "BDRip"),
("[UsifRenegade] Cardcaptor Sakura - 54 [BD-RM][1080p][x265_10Bit][Dual_AAC].mkv", "BDRip"),
("Elvis & Nixon (MicroHD-1080p)", "HDRip"),
("Bohemian Rhapsody 2018.2160p.UHDrip.x265.HDR.DD+.5.1-DTOne", "UHDRip"),
("Blade.Runner.2049.2017.4K.UltraHD.BluRay.2160p.x264.TrueHD.Atmos", "BluRay"),
("Terminator.Dark.Fate.2019.2160p.UHD.BluRay.X265.10bit.HDR.TrueHD", "BluRay"),
("When We Were Boys 2013 BD Rip x264 titohmr", "BDRip"),
("Key.and.Peele.s03e09.720p.web.dl.mrlss.sujaidr (pimprg)", "WEB-DL"),
("Godzilla 2014 HDTS HC XVID AC3 ACAB", "TeleSync"),
("Harry Potter And The Half Blood Prince 2009 telesync aac -- king", "TeleSync"),
("Capitao.America.2.TS.BrunoG", "TeleSync"),
("Star Trek TS-Screener Spanish Alta-Calidad 2da Version 2009 - Me", "TeleSync"),
("Solo: A Star Wars Story (2018) English 720p TC x264 900MBTEAM TR", "TeleCine"),
("Alita Battle Angel 2019 720p HDTC-1XBET", "TeleCine"),
("My.Super.Ex.Girlfriend.FRENCH.TELECINE.XViD-VCDFRV", "TeleCine"),
("You're Next (2013) cam XVID", "CAM"),
("Shes the one_2013(camrip)__TOPSIDER [email protected]", "CAM"),
("Blair Witch 2016 HDCAM UnKnOwN", "CAM"),
("Thor : Love and Thunder (2022) Hindi HQCAM x264 AAC - QRips.mkv", "CAM"),
("Avatar The Way of Water (2022) 1080p HQ S-Print Dual Audio [Hindi English] x264 AAC HC-Esub - CineVood.mkv",
"CAM"),
(
"Avatar The Way of Water (2022) 1080p S Print Dual Audio [Hindi English] x264 AAC HC-Esub - CineVood.mkv", "CAM"),
("Good Deeds 2012 SCR XViD-KiNGDOM", "SCR"),
("Genova DVD-Screener Spanish 2008", "SCR"),
("El Albergue Rojo BR-Screener Spanish 2007", "SCR"),
("The.Mysteries.of.Pittsburgh.LIMITED.SCREENER.XviD-COALiTiON [NOR", "SCR"),
("El.curioso.caso.de.benjamin.button-BRScreener-[EspaDivx.com].rar", "SCR"),
("Thor- Love and Thunder (2022) Original Hindi Dubbed 1080p HQ PreDVD Rip x264 AAC [1.7 GB]- CineVood.mkv", "SCR"),
("Black Panther Wakanda Forever 2022 Hindi 1080p PDVDRip x264 AAC CineVood.mkv", "SCR"),
("Vampire in Vegas (2009) NL Subs DVDR DivXNL-Team", "DVD"),
("Звонок из прошлого / Kol / The Call (2020) WEB-DLRip | ViruseProject", "WEB-DLRip"),
("La nube (2020) [BluRay Rip][AC3 5.1 Castellano][www.maxitorrent.com]", "BRRip"),
("Joker.2019.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.TrueHD.7.1.Atmos-FGT", "BluRay REMUX"),
("Warcraft 2016 1080p Blu-ray Remux AVC TrueHD Atmos-KRaLiMaRKo", "BluRay REMUX"),
("Joker.2019.UHD.BluRay.2160p.TrueHD.Atmos.7.1.HEVC.REMUX-JAT", "BluRay REMUX"),
("Spider-Man No Way Home.2022.REMUX.1080p.Bluray.DTS-HD.MA.5.1.AVC-EVO[TGx]", "BluRay REMUX"),
("Son of God 2014 HDR BDRemux 1080p.mkv", "BluRay REMUX"),
("Peter Rabbit 2 [4K UHDremux][2160p][HDR10][DTS-HD 5.1 Castellano-TrueHD 7.1-Ingles+Subs][ES-EN]", "BluRay REMUX"),
("Snatch cerdos y diamantes [4KUHDremux 2160p][Castellano AC3 5.1-Ingles TrueHD 7.1+Subs]", "BluRay REMUX"),
("Троя / Troy [2004 HDDVDRip-AVC] Dub + Original + Sub]", "DVDRip"),
("Структура момента (Расим Исмайлов) [1980, Драма, VHSRip]", "DVDRip"),
("Мужчины без женщин (Альгимантас Видугирис) [1981, Драма, VHS]", "DVD"),
("Преферанс по пятницам (Игорь Шешуков) [1984, Детектив, DVB]", "HDTV"),
("Соперницы (Алексей Дмитриев) [1929, драма, WEB-DLRip]", "WEB-DLRip"),
("Dragon Blade (2015) HDTSRip Exclusive", "TeleSync"),
("Criminal (2016) Hindi Dubbed HDTCRip", "TeleCine"),
("Avatar La Voie de l'eau.FRENCH.CAMHD.H264.AAC", "CAM")
])
@pytest.mark.parametrize(
"release_name, expected_quality",
[
("Nocturnal Animals 2016 VFF 1080p BluRay DTS HEVC-HD2", "BluRay"),
("doctor_who_2005.8x12.death_in_heaven.720p_hdtv_x264-fov", "HDTV"),
("Rebecca.1940.720p.HDTVRip.HDCLUB", "HDTV"),
("Gossip Girl - 1ª Temporada. (SAT-Rip)", "SATRip"),
("A Stable Life S01E01 DVDRip x264-Ltu", "DVDRip"),
("The Vet Life S02E01 Dunk-A-Doctor 1080p ANPL WEB-DL AAC2 0 H 264-RTN", "WEB-DL"),
("Brown Nation S01E05 1080p WEBRip x264-JAWN", "WEBRip"),
("Star Wars The Last Jedi 2017 TeleSync AAC x264-MiniMe", "TeleSync"),
("The.Shape.of.Water.2017.DVDScr.XVID.AC3.HQ.Hive-CM8", "SCR"),
("Cloudy With A Chance Of Meatballs 2 2013 720p PPVRip x264 AAC-FooKaS", "PPVRip"),
("The.OA.1x08.L.Io.Invisibile.ITA.WEBMux.x264-UBi.mkv", "WEBMux"),
("[UsifRenegade] Cardcaptor Sakura [BD][Remastered][1080p][HEVC_10Bit][Dual] + Movies", "BDRip"),
("[UsifRenegade] Cardcaptor Sakura - 54 [BD-RM][1080p][x265_10Bit][Dual_AAC].mkv", "BDRip"),
("Elvis & Nixon (MicroHD-1080p)", "HDRip"),
("Bohemian Rhapsody 2018.2160p.UHDrip.x265.HDR.DD+.5.1-DTOne", "UHDRip"),
("Blade.Runner.2049.2017.4K.UltraHD.BluRay.2160p.x264.TrueHD.Atmos", "BluRay"),
("Terminator.Dark.Fate.2019.2160p.UHD.BluRay.X265.10bit.HDR.TrueHD", "BluRay"),
("When We Were Boys 2013 BD Rip x264 titohmr", "BDRip"),
("Key.and.Peele.s03e09.720p.web.dl.mrlss.sujaidr (pimprg)", "WEB-DL"),
("Godzilla 2014 HDTS HC XVID AC3 ACAB", "TeleSync"),
("Harry Potter And The Half Blood Prince 2009 telesync aac -- king", "TeleSync"),
("Capitao.America.2.TS.BrunoG", "TeleSync"),
("Star Trek TS-Screener Spanish Alta-Calidad 2da Version 2009 - Me", "TeleSync"),
("Solo: A Star Wars Story (2018) English 720p TC x264 900MBTEAM TR", "TeleCine"),
("Alita Battle Angel 2019 720p HDTC-1XBET", "TeleCine"),
("My.Super.Ex.Girlfriend.FRENCH.TELECINE.XViD-VCDFRV", "TeleCine"),
("You're Next (2013) cam XVID", "CAM"),
("Shes the one_2013(camrip)__TOPSIDER [email protected]", "CAM"),
("Blair Witch 2016 HDCAM UnKnOwN", "CAM"),
("Thor : Love and Thunder (2022) Hindi HQCAM x264 AAC - QRips.mkv", "CAM"),
("Avatar The Way of Water (2022) 1080p HQ S-Print Dual Audio [Hindi English] x264 AAC HC-Esub - CineVood.mkv", "CAM"),
("Avatar The Way of Water (2022) 1080p S Print Dual Audio [Hindi English] x264 AAC HC-Esub - CineVood.mkv", "CAM"),
("Good Deeds 2012 SCR XViD-KiNGDOM", "SCR"),
("Genova DVD-Screener Spanish 2008", "SCR"),
("El Albergue Rojo BR-Screener Spanish 2007", "SCR"),
("The.Mysteries.of.Pittsburgh.LIMITED.SCREENER.XviD-COALiTiON [NOR", "SCR"),
("El.curioso.caso.de.benjamin.button-BRScreener-[EspaDivx.com].rar", "SCR"),
("Thor- Love and Thunder (2022) Original Hindi Dubbed 1080p HQ PreDVD Rip x264 AAC [1.7 GB]- CineVood.mkv", "SCR"),
("Black Panther Wakanda Forever 2022 Hindi 1080p PDVDRip x264 AAC CineVood.mkv", "SCR"),
("Vampire in Vegas (2009) NL Subs DVDR DivXNL-Team", "DVD"),
("Звонок из прошлого / Kol / The Call (2020) WEB-DLRip | ViruseProject", "WEB-DLRip"),
("La nube (2020) [BluRay Rip][AC3 5.1 Castellano][www.maxitorrent.com]", "BRRip"),
("Joker.2019.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.TrueHD.7.1.Atmos-FGT", "BluRay REMUX"),
("Warcraft 2016 1080p Blu-ray Remux AVC TrueHD Atmos-KRaLiMaRKo", "BluRay REMUX"),
("Joker.2019.UHD.BluRay.2160p.TrueHD.Atmos.7.1.HEVC.REMUX-JAT", "BluRay REMUX"),
("Spider-Man No Way Home.2022.REMUX.1080p.Bluray.DTS-HD.MA.5.1.AVC-EVO[TGx]", "BluRay REMUX"),
("Son of God 2014 HDR BDRemux 1080p.mkv", "BluRay REMUX"),
("Peter Rabbit 2 [4K UHDremux][2160p][HDR10][DTS-HD 5.1 Castellano-TrueHD 7.1-Ingles+Subs][ES-EN]", "BluRay REMUX"),
("Snatch cerdos y diamantes [4KUHDremux 2160p][Castellano AC3 5.1-Ingles TrueHD 7.1+Subs]", "BluRay REMUX"),
("Троя / Troy [2004 HDDVDRip-AVC] Dub + Original + Sub]", "DVDRip"),
("Структура момента (Расим Исмайлов) [1980, Драма, VHSRip]", "DVDRip"),
("Мужчины без женщин (Альгимантас Видугирис) [1981, Драма, VHS]", "DVD"),
("Преферанс по пятницам (Игорь Шешуков) [1984, Детектив, DVB]", "HDTV"),
("Соперницы (Алексей Дмитриев) [1929, драма, WEB-DLRip]", "WEB-DLRip"),
("Dragon Blade (2015) HDTSRip Exclusive", "TeleSync"),
("Criminal (2016) Hindi Dubbed HDTCRip", "TeleCine"),
("Avatar La Voie de l'eau.FRENCH.CAMHD.H264.AAC", "CAM"),
("www.1TamilBlasters.link - Indian 2 (2024) [Tamil - 1080p Proper HQ PRE-HDRip - x264 - AAC - 6.3GB - HQ Real Audio].mkv", "SCR"),
],
)
def test_source_detection(parser, release_name, expected_quality):
result = parser.parse(release_name)
assert result.get("quality") == expected_quality, f"Source detection failed for {release_name}"
74 changes: 43 additions & 31 deletions tests/test_sports.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,48 @@ def parser():
return p


@pytest.mark.parametrize("release_name, expected", [
("UFC.239.PPV.Jones.Vs.Santos.HDTV.x264-PUNCH[TGx]", {
"title": "UFC 239 Jones Vs Santos",
"seasons": [],
"episodes": [],
"languages": [],
"quality": "HDTV",
"codec": "x264",
"group": "PUNCH",
"ppv": True,
}),
("UFC.Fight.Night.158.Cowboy.vs.Gaethje.WEB.x264-PUNCH[TGx]", {
"title": "UFC Fight Night 158 Cowboy vs Gaethje",
"seasons": [],
"episodes": [],
"languages": [],
"quality": "WEB-DL",
"codec": "x264",
"group": "PUNCH",
"ppv": True,
}),
("UFC 226 PPV Miocic vs Cormier HDTV x264-Ebi [TJET]", {
"title": "UFC 226 Miocic vs Cormier",
"seasons": [],
"episodes": [],
"languages": [],
"quality": "HDTV",
"codec": "x264",
"ppv": True,
})
])
@pytest.mark.parametrize(
"release_name, expected",
[
(
"UFC.239.PPV.Jones.Vs.Santos.HDTV.x264-PUNCH[TGx]",
{
"title": "UFC 239 Jones Vs Santos",
"seasons": [],
"episodes": [],
"languages": [],
"quality": "HDTV",
"codec": "x264",
"group": "PUNCH",
"ppv": True,
},
),
(
"UFC.Fight.Night.158.Cowboy.vs.Gaethje.WEB.x264-PUNCH[TGx]",
{
"title": "UFC Fight Night 158 Cowboy vs Gaethje",
"seasons": [],
"episodes": [],
"languages": [],
"quality": "WEB-DL",
"codec": "x264",
"group": "PUNCH",
"ppv": True,
},
),
(
"UFC 226 PPV Miocic vs Cormier HDTV x264-Ebi [TJET]",
{
"title": "UFC 226 Miocic vs Cormier",
"seasons": [],
"episodes": [],
"languages": [],
"quality": "HDTV",
"codec": "x264",
"ppv": True,
},
),
],
)
def test_random_sports_parse(parser, release_name, expected):
assert parser.parse(release_name) == expected
2 changes: 1 addition & 1 deletion tests/test_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def parser():
("ww.Tamilblasters.sbs - 8 Bit Christmas (2021) HQ HDRip - x264 - Telugu (Fan Dub) - 400MB].mkv", "8 Bit Christmas"),
("www.1TamilMV.pics - 777 Charlie (2022) Tamil HDRip - 720p - x264 - HQ Clean Aud - 1.4GB.mkv", "777 Charlie"),
("Despicable.Me.4.2024.D.TELESYNC_14OOMB.avi", "Despicable Me 4"),
("UFC.247.PPV.Jones.vs.Reyes.HDTV.x264-PUNCH[TGx]", "UFC 247 PPV Jones vs Reyes"),
("UFC.247.PPV.Jones.vs.Reyes.HDTV.x264-PUNCH[TGx]", "UFC 247 Jones vs Reyes"),
("[www.1TamilMV.pics]_The.Great.Indian.Suicide.2023.Tamil.TRUE.WEB-DL.4K.SDR.HEVC.(DD+5.1.384Kbps.&.AAC).3.2GB.ESub.mkv", "The Great Indian Suicide"),
("Game of Thrones - S02E07 - A Man Without Honor [2160p] [HDR] [5.1, 7.1, 5.1] [ger, eng, eng] [Vio].mkv", "Game of Thrones"),
("Pawn.Stars.S09E13.1080p.HEVC.x265-MeGusta", "Pawn Stars"),
Expand Down
Loading