Skip to content

Commit

Permalink
feat: add ppv support
Browse files Browse the repository at this point in the history
  • Loading branch information
dreulavelle committed Jul 25, 2024
1 parent 4ec4a0a commit 643ef01
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
4 changes: 4 additions & 0 deletions PTT/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def add_defaults(parser: Parser):
# Torrent extension
parser.add_handler("torrent", regex.compile(r"\.torrent$"), boolean, {"remove": True})

# PPV
parser.add_handler("ppv", regex.compile(r"\bPPV\b", regex.IGNORECASE), boolean, {"skipFromTitle": True, "remove": True})
parser.add_handler("ppv", regex.compile(r"\b\W?Fight.?Nights?\W?\b", regex.IGNORECASE), boolean, {"skipFromTitle": True, "remove": False})

# Site before languages to get rid of domain name with country code.
parser.add_handler("site", regex.compile(r"^(www?[\.,][\w-]+\.[\w-]+(?:\.[\w-]+)?)\s+-\s*", regex.IGNORECASE), options={"skipFromTitle": True, "remove": True, "skipIfAlreadyFound": False})
parser.add_handler("site", regex.compile(r"^((?:www?[\.,])?[\w-]+\.[\w-]+(?:\.[\w-]+)*?)\s+-\s*", regex.IGNORECASE), options={"skipIfAlreadyFound": False})
Expand Down
49 changes: 49 additions & 0 deletions tests/test_anime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import pytest

from PTT import parse_title


@pytest.mark.parametrize("release_name, expected", [
("Sword.Art.Online.Alternative.S01.v2.1080p.Blu-Ray.10-Bit.Dual-Audio.LPCM.x265-iAHD", {
"title": "Sword Art Online Alternative: Gun Gale Online",
"seasons": [1],
"episodes": [],
"languages": ["dual audio"],
"bit_depth": "10bit",
"dubbed": True,
"quality": "BluRay",
"codec": "x265",
"resolution": "1080p",
"group": "iAHD",
}),
("[SubsPlease] Tearmoon Teikoku Monogatari - 01 (1080p) [15ADAE00].mkv", {
"title": "Tearmoon Teikoku Monogatari",
"seasons": [],
"episodes": [1],
"episode_code": "15ADAE00",
"languages": [],
"resolution": "1080p",
"group": "SubsPlease",
"container": "mkv",
"extension": "mkv",
}),
("[Erai-raws] Tearmoon Teikoku Monogatari - 01 [1080p][Multiple Subtitle] [ENG][POR-BR][SPA-LA][SPA][ARA][FRE][GER][ITA][RUS]", {
"title": "Tearmoon Teikoku Monogatari",
"seasons": [],
"episodes": [1],
"languages": ["multi subs", "english", "french", "spanish", "portuguese", "italian", "german", "russian", "arabic"],
"resolution": "1080p",
"group": "Erai-raws",
}),
("Hunter x Hunter (2011) - 01 [1080p][Multiple Subtitle] [ENG][POR-BR][SPA-LA][SPA][ARA][FRE][GER][ITA][RUS]", {
"title": "Hunter x Hunter",
"seasons": [],
"episodes": [1],
"languages": ["multi subs", "english", "french", "spanish", "portuguese", "italian", "german", "russian", "arabic"],
"resolution": "1080p",
"year": 2011,
}),
])
def test_random_anime_parse(release_name, expected):
result = parse_title(release_name)
assert result == expected
46 changes: 46 additions & 0 deletions tests/test_sports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import pytest

from PTT.handlers import add_defaults
from PTT.parse import Parser


@pytest.fixture
def parser():
p = Parser()
add_defaults(p)
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,
})
])
def test_random_sports_parse(parser, release_name, expected):
assert parser.parse(release_name) == expected

0 comments on commit 643ef01

Please sign in to comment.