Skip to content

Commit 45dbbf7

Browse files
committed
Removing series information from series title
1 parent 0a351d1 commit 45dbbf7

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

src/ruvsarpur.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,8 @@ def getVodSeriesSchedule(sid, _, imdb_cache, imdb_orignal_titles):
10381038
# Determine the type
10391039
series_type = "documentary" if isDocumentary else "movie" if isMovie else "tvshow" if not isSport or 'leiknir-thaettir' in prog['cat_slugs'] else None
10401040

1041-
series_title = prog['title']
1041+
series_title = trimSeasonNumberSuffix(prog['title'])
1042+
series_title_wseason = prog['title']
10421043
series_description = prog['short_description']
10431044
series_shortdescription = prog['description']
10441045
series_image = formatCoverArtResolutionMacro(prog['image']) if 'image' in prog else None
@@ -1164,23 +1165,23 @@ def getVodSeriesSchedule(sid, _, imdb_cache, imdb_orignal_titles):
11641165

11651166
# Attempt to parse out the season number, start with 1 as the default
11661167
entry['season_num'] = '1'
1167-
if str(series_title).endswith(' 2') or str(series_title).endswith(' II') or str(foreign_title).endswith(' II') or 'önnur þáttaröð' in str(entry['desc']).lower():
1168+
if str(series_title_wseason).endswith(' 2') or str(series_title_wseason).endswith(' II') or str(foreign_title).endswith(' II') or 'önnur þáttaröð' in str(entry['desc']).lower():
11681169
entry['season_num'] = '2'
1169-
elif str(series_title).endswith(' 3') or str(series_title).endswith(' III') or str(foreign_title).endswith(' III') or 'þriðja þáttaröð' in str(entry['desc']).lower():
1170+
elif str(series_title_wseason).endswith(' 3') or str(series_title_wseason).endswith(' III') or str(foreign_title).endswith(' III') or 'þriðja þáttaröð' in str(entry['desc']).lower():
11701171
entry['season_num'] = '3'
1171-
elif str(series_title).endswith(' 4') or str(series_title).endswith(' IV') or str(foreign_title).endswith(' IV') or 'fjórða þáttaröð' in str(entry['desc']).lower():
1172+
elif str(series_title_wseason).endswith(' 4') or str(series_title_wseason).endswith(' IV') or str(foreign_title).endswith(' IV') or 'fjórða þáttaröð' in str(entry['desc']).lower():
11721173
entry['season_num'] = '4'
1173-
elif str(series_title).endswith(' 5') or str(series_title).endswith(' V') or str(foreign_title).endswith(' V') or 'fimmta þáttaröð' in str(entry['desc']).lower():
1174+
elif str(series_title_wseason).endswith(' 5') or str(series_title_wseason).endswith(' V') or str(foreign_title).endswith(' V') or 'fimmta þáttaröð' in str(entry['desc']).lower():
11741175
entry['season_num'] = '5'
1175-
elif str(series_title).endswith(' 6') or str(series_title).endswith(' VI') or str(foreign_title).endswith(' VI') or 'sjötta þáttaröð' in str(entry['desc']).lower():
1176+
elif str(series_title_wseason).endswith(' 6') or str(series_title_wseason).endswith(' VI') or str(foreign_title).endswith(' VI') or 'sjötta þáttaröð' in str(entry['desc']).lower():
11761177
entry['season_num'] = '6'
1177-
elif str(series_title).endswith(' 7') or str(series_title).endswith(' VII') or str(foreign_title).endswith(' VII') or 'sjöunda þáttaröð' in str(entry['desc']).lower():
1178+
elif str(series_title_wseason).endswith(' 7') or str(series_title_wseason).endswith(' VII') or str(foreign_title).endswith(' VII') or 'sjöunda þáttaröð' in str(entry['desc']).lower():
11781179
entry['season_num'] = '7'
1179-
elif str(series_title).endswith(' 8') or str(series_title).endswith(' VIII') or str(foreign_title).endswith(' VIII') or 'áttunda þáttaröð' in str(entry['desc']).lower():
1180+
elif str(series_title_wseason).endswith(' 8') or str(series_title_wseason).endswith(' VIII') or str(foreign_title).endswith(' VIII') or 'áttunda þáttaröð' in str(entry['desc']).lower():
11801181
entry['season_num'] = '8'
1181-
elif str(series_title).endswith(' 9') or str(series_title).endswith(' IX') or str(foreign_title).endswith(' IX') or 'níunda þáttaröð' in str(entry['desc']).lower():
1182+
elif str(series_title_wseason).endswith(' 9') or str(series_title_wseason).endswith(' IX') or str(foreign_title).endswith(' IX') or 'níunda þáttaröð' in str(entry['desc']).lower():
11821183
entry['season_num'] = '9'
1183-
elif str(series_title).endswith(' 10') or str(series_title).endswith(' XX') or str(foreign_title).endswith(' XX') or 'tíunda þáttaröð' in str(entry['desc']).lower():
1184+
elif str(series_title_wseason).endswith(' 10') or str(series_title_wseason).endswith(' XX') or str(foreign_title).endswith(' XX') or 'tíunda þáttaröð' in str(entry['desc']).lower():
11841185
entry['season_num'] = '10'
11851186

11861187
# Create the episode numbers programatically to ensure consistency if we're dealing with multi-episode program
@@ -1216,6 +1217,22 @@ def getVodSeriesSchedule(sid, _, imdb_cache, imdb_orignal_titles):
12161217

12171218
return schedule
12181219

1220+
#
1221+
# Removes any season number related suffixes for a given series title
1222+
# Ex. Monsurnar 1 => Monsurnar
1223+
# Hvolpasveitin IV => Hvolpasveitin
1224+
def trimSeasonNumberSuffix(series_title):
1225+
prefixes = [' I', ' II', ' III', ' IV', ' V', ' VI', ' VII', ' VIII', ' IX', ' X', ' XI', ' XII', ' 1', ' 2', ' 3', ' 4', ' 5', ' 6', ' 7', ' 8', ' 9', ' 10', ' 11', ' 12']
1226+
for prefix in prefixes:
1227+
new_series_title = series_title.removesuffix(prefix)
1228+
if len(new_series_title) < len(series_title):
1229+
return new_series_title
1230+
series_title = new_series_title
1231+
1232+
return series_title
1233+
1234+
1235+
12191236
def getGroup(regex, group_name, haystack):
12201237
for match in re.finditer(regex, haystack):
12211238
match_value = match.group(group_name).strip()
@@ -1515,7 +1532,7 @@ def runMain():
15151532
if not item['subtitles'] is None and len(item['subtitles']) > 0:
15161533
try:
15171534
downloadSubtitlesFiles(item['subtitles'], local_filename, display_title, item)
1518-
except ex:
1535+
except Exception as ex:
15191536
print("Error: Could not download subtitle files for item, "+item['title'])
15201537
continue
15211538

0 commit comments

Comments
 (0)