From f0a64122d31795207d98ad722837de79a0c7071c Mon Sep 17 00:00:00 2001 From: Bugale Bugalit Date: Mon, 2 Sep 2024 00:56:54 +0300 Subject: [PATCH] fix: handle more filenames --- buganime/buganime.py | 2 +- tests/test_buganime.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/buganime/buganime.py b/buganime/buganime.py index 1d0557e..dd465f3 100644 --- a/buganime/buganime.py +++ b/buganime/buganime.py @@ -110,7 +110,7 @@ def parse_filename(input_path: str) -> TVShow | Movie: return TVShow(name=match.group('name'), season=int(match.group('season')), episode=int(match.group('episode'))) # Structured TV Shows - dir_re = r'(?P[^\\]+?)[ -]+S(?:eason ?)?\d{1,2}(?:[ -][^\\]*)?' + dir_re = r'(?P[^\\]+?)[ -]+S(?:eason ?)?\d{1,2}(?:P\d{1,2})?(?:[ -][^\\]*)?' file_re = r'[^\\]*S(?P\d{1,2})E(?P\d{1,3})(?:[ -][^\\]*)?' if match := re.match(fr'^.*\\{dir_re}(?:\\.*)?\\{file_re}$', input_path): return TVShow(name=match.group('name'), season=int(match.group('season')), episode=int(match.group('episode'))) diff --git a/tests/test_buganime.py b/tests/test_buganime.py index 49b8082..923311d 100644 --- a/tests/test_buganime.py +++ b/tests/test_buganime.py @@ -74,6 +74,9 @@ (r'C:\Temp\Torrents\Mushoku Tensei S01+SP 1080p Dual Audio BDRip 10 bits DDP x265-EMBER\Mushoku Tensei S01P01 1080p Dual Audio BDRip 10 bits DD ' r'x265-EMBER\S01E08-Turning Point 1 V2 [87C2150F].mkv', buganime.TVShow(name='Mushoku Tensei', season=1, episode=8)), + + (r'C:\Temp\Torrents\Mushoku Tensei S02P01+SP 1080p Dual Audio BDRip 10 bits DD+ x265-EMBER\S02E01-The Brokenhearted Mage [AFBB9792].mkv', + buganime.TVShow(name='Mushoku Tensei', season=2, episode=1)), ]