Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the acts numbers #206

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions src/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,47 @@ def get_act_episode_from_act_id(self, act_id):
"act": None,
"episode": None
}

def parse_season_number(name):
# Convert roman numerals to integers
roman_map = {
'I': 1,
'II': 2,
'III': 3,
'IV': 4,
'V': 5
}

# For episodes (using regular numbers)
if name.startswith('EPISODE'):
try:
return int(name.split()[-1])
except (ValueError, IndexError):
return None

# For acts (using Roman numerals)
elif name.startswith('ACT'):
try:
roman_numeral = name.split()[-1]
return roman_map.get(roman_numeral)
except (KeyError, IndexError):
return None

return None

act_found = False
for season in self.content["Seasons"]:

if season["ID"].lower() == act_id.lower():
final["act"] = int(season["Name"][-1])
act_num = parse_season_number(season["Name"])
if act_num is not None:
final["act"] = act_num
act_found = True

if act_found and season["Type"] == "episode":
final["episode"] = int(season["Name"][-1])
episode_num = parse_season_number(season["Name"])
if episode_num is not None:
final["episode"] = episode_num
break

return final