Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dreulavelle committed Jul 20, 2024
1 parent 2392ce3 commit 55882fb
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 125 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: install lint sort test coverage pr-ready publish clean
.PHONY: install format sort test coverage pr-ready publish clean

SRC_DIR := ./PTT

Expand All @@ -12,11 +12,11 @@ clean:
@find . -type d -name '.pytest_cache' -exec rm -rf {} +
@find . -type d -name '.ruff_cache' -exec rm -rf {} +

# Run linters
lint:
@poetry run ruff check $(SRC_DIR)
# Run black
format:
@poetry run black $(SRC_DIR)

# Format code
# Sort imports
sort:
@poetry run isort $(SRC_DIR)

Expand All @@ -28,7 +28,7 @@ test:
coverage:
@poetry run pytest --cov=$(SRC_DIR) --cov-report=xml --cov-report=term

pr-ready: sort lint test
pr-ready: sort format test

publish:
@poetry publish --build
2 changes: 1 addition & 1 deletion PTT/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def parse(raw_title: str) -> dict:
return _parser.parse(raw_title)


__all__ = ["Parser", "add_defaults", "parse", "parse_title", "handlers", "transformers"]
__all__ = ["Parser", "add_defaults", "parse", "parse_title", "handlers", "transformers"]
143 changes: 90 additions & 53 deletions PTT/handlers.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions PTT/transformers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, Optional, Union, List
from typing import Callable, List, Optional, Union

import arrow
import regex
Expand Down Expand Up @@ -202,4 +202,4 @@ def inner(input_value: str, result: Optional[List[Union[str, int]]] = None) -> L
result.append(output_value)
return result

return inner
return inner
100 changes: 98 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 2 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "parsett"
version = "0.2.4"
version = "0.2.5"
description = "PTT"
authors = ["Dreu LaVelle <[email protected]>"]
license = "MIT"
Expand All @@ -20,6 +20,7 @@ pytest-cov = "^5.0.0"
codecov = "^2.1.13"
coverage = "^7.4.4"

black = "^24.4.2"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Expand Down Expand Up @@ -75,33 +76,3 @@ exclude = '''
| tests
)/
'''

[tool.ruff.lint]
# https://docs.astral.sh/ruff/rules/
ignore = [
"PLR0913", # flask8-bugbear: Too many arguments for a method or function
"PLR0911", # flask8-bugbear: Too many return statements
"PLR2004", # flake8-bugbear: Magic value used in comparison
"S104", # flake8-bandit: Possible binding to all interfaces
"S108", # flake8-bandit: Probable insecure usage of temp file/directory
"S311", # flake8-bandit: Standard pseudo-random generators are not suitable for security/cryptographic purposes
"S101", # ruff: Ignore assert warnings on tests
"RET505", # ruff: Checks for else statements with a return statement in the preceding if block.
"RET503" # ruff: Ignore required explicit returns
]
extend-select = [
"I", # isort
"C90", # mccabe complexity
"B", # flake8-bugbear
"PL", # pycodestyle
"S", # flake8-bandit
"T10", # flake8-debugger
"PIE", # flake8-pie
"T20", # flake8-print
"Q", # flake8-quotes
"RSE", # flake8-raise
"RET", # flake8-return
"SLF", # flake8-self
"SIM", # flake8-simplify
"ARG", # flake8-unused-arguments
]
40 changes: 20 additions & 20 deletions tests/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ def parser():


@pytest.mark.parametrize("release_name, expected_audio", [
("Nocturnal Animals 2016 VFF 1080p BluRay DTS HEVC-HD2", "dts"),
("Gold 2016 1080p BluRay DTS-HD MA 5 1 x264-HDH", "dts-hd"),
("Rain Man 1988 REMASTERED 1080p BRRip x264 AAC-m2g", "aac"),
("The Vet Life S02E01 Dunk-A-Doctor 1080p ANPL WEB-DL AAC2 0 H 264-RTN", "aac"),
("Jimmy Kimmel 2017 05 03 720p HDTV DD5 1 MPEG2-CTL", "dd5.1"),
("A Dog's Purpose 2016 BDRip 720p X265 Ac3-GANJAMAN", "ac3"),
("Retroactive 1997 BluRay 1080p AC-3 HEVC-d3g", "ac3"),
("Tempete 2016-TrueFRENCH-TVrip-H264-mp3", "mp3"),
("Nocturnal Animals 2016 VFF 1080p BluRay DTS HEVC-HD2", ["dts"]),
("Gold 2016 1080p BluRay DTS-HD MA 5 1 x264-HDH", ["dts-hd"]),
("Rain Man 1988 REMASTERED 1080p BRRip x264 AAC-m2g", ["aac"]),
("The Vet Life S02E01 Dunk-A-Doctor 1080p ANPL WEB-DL AAC2 0 H 264-RTN", ["aac"]),
("Jimmy Kimmel 2017 05 03 720p HDTV DD5 1 MPEG2-CTL", ["dd5.1"]),
("A Dog's Purpose 2016 BDRip 720p X265 Ac3-GANJAMAN", ["ac3"]),
("Retroactive 1997 BluRay 1080p AC-3 HEVC-d3g", ["ac3"]),
("Tempete 2016-TrueFRENCH-TVrip-H264-mp3", ["mp3"]),
("Detroit.2017.BDRip.MD.GERMAN.x264-SPECTRE", None),
("The Blacklist S07E04 (1080p AMZN WEB-DL x265 HEVC 10bit EAC-3 5.1)[Bandi]", "eac3"),
("Condor.S01E03.1080p.WEB-DL.x265.10bit.EAC3.6.0-Qman[UTR].mkv", "eac3"),
("The 13 Ghosts of Scooby-Doo (1985) S01 (1080p AMZN Webrip x265 10bit EAC-3 2.0 - Frys) [TAoE]", "eac3"),
("The Blacklist S07E04 (1080p AMZN WEB-DL x265 HEVC 10bit EAC-3 5.1)[Bandi]", ["eac3"]),
("Condor.S01E03.1080p.WEB-DL.x265.10bit.EAC3.6.0-Qman[UTR].mkv", ["eac3"]),
("The 13 Ghosts of Scooby-Doo (1985) S01 (1080p AMZN Webrip x265 10bit EAC-3 2.0 - Frys) [TAoE]", ["eac3"]),
("[Thund3r3mp3ror] Attack on Titan - 23.mp4", None), # Test case to ensure "mp3" isn't detected inside a word
("Buttobi!! CPU - 02 (DVDRip 720x480p x265 HEVC AC3x2 2.0x2)(Dual Audio)[sxales].mkv", "2.0"),
("[naiyas] Fate Stay Night - Unlimited Blade Works Movie [BD 1080P HEVC10 QAACx2 Dual Audio]", "aac"),
("Sakura Wars the Movie (2001) (BDRip 1920x1036p x265 HEVC FLACx2, AC3 2.0+5.1x2)(Dual Audio)[sxales].mkv", "2.0"),
("Spider-Man.No.Way.Home.2021.2160p.BluRay.REMUX.HEVC.TrueHD.7.1.Atmos-FraMeSToR", "7.1 Atmos"),
("www.1TamilMV.pics - 777 Charlie (2022) Tamil HDRip - 720p - x264 - HQ Clean Aud - 1.4GB.mkv", "hq audio"),
("Buttobi!! CPU - 02 (DVDRip 720x480p x265 HEVC AC3x2 2.0x2)(Dual Audio)[sxales].mkv", ["ac3"]),
("[naiyas] Fate Stay Night - Unlimited Blade Works Movie [BD 1080P HEVC10 QAACx2 Dual Audio]", ["aac"]),
("Sakura Wars the Movie (2001) (BDRip 1920x1036p x265 HEVC FLACx2, AC3 2.0+5.1x2)(Dual Audio)[sxales].mkv", ["flac", "ac3"]),
("Spider-Man.No.Way.Home.2021.2160p.BluRay.REMUX.HEVC.TrueHD.7.1.Atmos-FraMeSToR", ["Dolby Atmos"]),
])
def test_audio_detection(parser, release_name, expected_audio):
result = parser.parse(release_name)
Expand All @@ -40,9 +40,9 @@ def test_audio_detection(parser, release_name, expected_audio):
assert "audio" not in result, f"Unexpected audio detection for {release_name}"

@pytest.mark.parametrize("release_name, expected_audio", [
("Macross ~ Do You Remember Love (1984) (BDRip 1920x1036p x265 HEVC DTS-HD MA, FLAC, AC3x2 5.1+2.0x3)(Dual Audio)[sxales].mkv", "2.0"),
("Escaflowne (2000) (BDRip 1896x1048p x265 HEVC TrueHD, FLACx3, AC3 5.1x2+2.0x3)(Triple Audio)[sxales].mkv", "2.0"),
("[SAD] Inuyasha - The Movie 4 - Fire on the Mystic Island [BD 1920x1036 HEVC10 FLAC2.0x2] [84E9A4A1].mkv", "flac"),
("Macross ~ Do You Remember Love (1984) (BDRip 1920x1036p x265 HEVC DTS-HD MA, FLAC, AC3x2 5.1+2.0x3)(Dual Audio)[sxales].mkv", ["dts-hd", "ac3"]),
("Escaflowne (2000) (BDRip 1896x1048p x265 HEVC TrueHD, FLACx3, AC3 5.1x2+2.0x3)(Triple Audio)[sxales].mkv", ["truehd", "ac3"]),
("[SAD] Inuyasha - The Movie 4 - Fire on the Mystic Island [BD 1920x1036 HEVC10 FLAC2.0x2] [84E9A4A1].mkv", ["flac"]),
])
def test_audio_detection_without_episode(parser, release_name, expected_audio):
result = parser.parse(release_name)
Expand All @@ -54,7 +54,7 @@ def test_audio_detection_without_episode(parser, release_name, expected_audio):
assert result.get("episodes") == [], f"Unexpected episode detection for {release_name}"

@pytest.mark.parametrize("release_name, expected_audio, expected_episode", [
("Outlaw Star - 23 (BDRip 1440x1080p x265 HEVC AC3, FLACx2 2.0x3)(Dual Audio)[sxales].mkv", "2.0", [23]),
("Outlaw Star - 23 (BDRip 1440x1080p x265 HEVC AC3, FLACx2 2.0x3)(Dual Audio)[sxales].mkv", ["flac", "ac3"], [23]),
])
def test_audio_detection_with_episode(parser, release_name, expected_audio, expected_episode):
result = parser.parse(release_name)
Expand Down
47 changes: 40 additions & 7 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def parser():
"year": 2024,
"quality": "BluRay REMUX",
"resolution": "4k",
"audio": "truehd",
"audio": ["hd"],
"codec": "x265",
"languages": [],
"seasons": [],
Expand All @@ -330,7 +330,7 @@ def parser():
"quality": "BluRay REMUX",
"resolution": "1080p",
"audio": "dd5.1",
"channels": "5.1",
"channels": ["5.1"],
"codec": "avc",
"group": "NOGRP"
}),
Expand All @@ -353,7 +353,7 @@ def parser():
"resolution": "1080p",
"bit_depth": "10bit",
"audio": "dd5.1",
"channels": "5.1",
"channels": ["5.1"],
"codec": "x265",
"seasons": [],
"episodes": [],
Expand All @@ -369,7 +369,7 @@ def parser():
"codec": "x265",
"bit_depth": "10bit",
"audio": "aac",
"channels": "5.1"
"channels": ["5.1"]
}),
("[DB]_Bleach_264_[012073FE].avi", {
"title": "Bleach",
Expand Down Expand Up @@ -413,7 +413,7 @@ def parser():
"quality": "BluRay REMUX",
"resolution": "1080p",
"audio": "dts-hd",
"channels": "5.1",
"channels": ["5.1"],
"codec": "avc",
"group": "LEGi0N"
}),
Expand All @@ -428,10 +428,43 @@ def parser():
"quality": "BluRay",
"codec": "x265",
"bit_depth": "10bit",
"audio": "7.1 Atmos",
"channels": "7.1",
"audio": ["atmos"],
"channels": ["7.1"],
"hdr": ["HDR"],
"group": "BOREDOR"
}),
("Escaflowne (2000) (BDRip 1896x1048p x265 HEVC TrueHD, FLACx3, AC3 5.1x2+2.0x3)(Triple Audio)[sxales].mkv", {
"title": "Escaflowne",
"year": 2000,
"languages": ["multi audio"],
"seasons": [],
"episodes": [],
"quality": "BDRip",
"codec": "x265",
"resolution": "1896x1048p", # this needs to be 1080p instead probably
"audio": ["truehd"],
"channels": ["5.1"],
"group": "sxales",
"dubbed": True,
"extension": "mkv"
}),
("[www.1TamilMV.pics]_The.Great.Indian.Suicide.2023.Tamil.TRUE.WEB-DL.4K.SDR.HEVC.(DD+5.1.384Kbps.&.AAC).3.2GB.ESub.mkv", {
"title": "The Great Indian Suicide",
"year": 2023,
"languages": ["tamil"],
"seasons": [],
"episodes": [],
"quality": "WEB-DL",
"resolution": "4k",
"hdr": ["SDR"],
"codec": "x265",
"site": "www.1TamilMV.pics",
"size": "3.2GB",
"container": "mkv",
"extension": "mkv",
"bitrate": "384kbps",
"audio": ["true"],
"channels": ["5.1"],
})
])
def test_random_releases_parse(parser, release_name, expected):
Expand Down
Loading

0 comments on commit 55882fb

Please sign in to comment.