Skip to content

Commit

Permalink
fix: handle more filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
bugale committed Sep 1, 2024
1 parent c0e2d9d commit 05a0bdc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion buganime/buganime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<name>[^\\]+?)[ -]+S(?:eason ?)?\d{1,2}(?:[ -][^\\]*)?'
dir_re = r'(?P<name>[^\\]+?)[ -]+S(?:eason ?)?\d{1,2}(?:P\d{1,2})?(?:[ -][^\\]*)?'
file_re = r'[^\\]*S(?P<season>\d{1,2})E(?P<episode>\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')))
Expand Down
3 changes: 3 additions & 0 deletions tests/test_buganime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
]


Expand Down

0 comments on commit 05a0bdc

Please sign in to comment.