Skip to content

Commit

Permalink
Adds new eps/seasons format
Browse files Browse the repository at this point in the history
  • Loading branch information
pintoso authored Jan 12, 2025
1 parent cd695c2 commit 1b8c92f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@ def get_act_episode_from_act_id(self, act_id):
"episode": None
}

def has_letter_and_number(text):
"""Check if text contains both letters and numbers (new format)."""
has_letter = any(c.isalpha() for c in text)
has_number = any(c.isdigit() for c in text)
return has_letter and has_number

def roman_to_int(roman):
"""Convert a Roman numeral to an integer."""
# Basic Roman numeral values
roman_values = {
'I': 1,
'V': 5,
Expand All @@ -85,7 +90,6 @@ def roman_to_int(roman):
total = 0
prev_value = 0

# Process the Roman numeral from right to left
for char in reversed(roman.upper()):
if char not in roman_values:
return None
Expand All @@ -100,9 +104,7 @@ def roman_to_int(roman):
return total

def parse_season_number(name):
"""Parse the season number from a name string.
Handles both regular numbers and Roman numerals."""
# Check for empty or invalid input
"""Parse the season number from a name string."""
if not name or not isinstance(name, str):
return None

Expand All @@ -111,6 +113,10 @@ def parse_season_number(name):
return None

number_part = parts[-1]

# If it has a letter + number(new format), return the original value.
if has_letter_and_number(number_part):
return number_part.lower()

# For episodes (using regular numbers primarily)
if name.startswith('EPISODE'):
Expand Down

0 comments on commit 1b8c92f

Please sign in to comment.