Skip to content

Commit dce744a

Browse files
committed
Fix Mismatch indici
1 parent 2c38147 commit dce744a

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

StreamingCommunity/Api/Service/crunchyroll/util/ScrapeSerie.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def collect_season(self) -> None:
116116
# Sort by number then title
117117
season_rows.sort(key=lambda r: (r["raw_number"], r["title"] or ""))
118118

119-
# Add to manager with sequential indexing
119+
# Add to manager
120120
for idx, row in enumerate(season_rows):
121121
self.seasons_manager.add_season({
122122
'number': row["raw_number"],
@@ -127,7 +127,7 @@ def collect_season(self) -> None:
127127

128128
def _fetch_episodes_for_season(self, season_index: int) -> List[Dict]:
129129
"""Fetch and cache episodes for a season - SINGLE API CALL per season."""
130-
season = self.seasons_manager.seasons[season_index]
130+
season = self.seasons_manager.seasons[season_index-1]
131131
response = _fetch_api_episodes(season.id, self.client, self.params)
132132

133133
# Get response json
@@ -147,8 +147,7 @@ def _fetch_episodes_for_season(self, season_index: int) -> List[Dict]:
147147

148148
episodes.append({
149149
'id': ep_id,
150-
'number': ep_data.get("episode_number"),
151-
'raw_episode': ep_number or None,
150+
'number': ep_number,
152151
'is_special': is_special,
153152
'name': ep_data.get("title", f"Episodio {ep_data.get('episode_number')}"),
154153
'url': f"{self.client.web_base_url}/watch/{ep_id}",

StreamingCommunity/Api/Template/episode_manager.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,41 +290,61 @@ def display_episodes_list(episodes_manager) -> str:
290290
# Set up table for displaying episodes
291291
table_show_manager = TVShowManager()
292292

293-
# Check if any episode has a non-empty category
293+
# Check if any episode has non-empty fields
294294
has_category = False
295+
has_number = False
296+
has_duration = False
297+
295298
for media in episodes_manager:
296299
category = media.get('category') if isinstance(media, dict) else getattr(media, 'category', None)
300+
number = media.get('number') if isinstance(media, dict) else getattr(media, 'number', None)
301+
duration = media.get('duration') if isinstance(media, dict) else getattr(media, 'duration', None)
302+
297303
if category is not None and str(category).strip() != '':
298304
has_category = True
299-
break
305+
if number is not None and str(number).strip() != '':
306+
has_number = True
307+
if duration is not None and str(duration).strip() != '':
308+
has_duration = True
300309

301310
# Add columns to the table
302311
column_info = {
303312
"Index": {'color': 'red'},
304-
"Name": {'color': 'magenta'},
305313
}
306314

315+
if has_number:
316+
column_info["Number"] = {'color': 'cyan'}
317+
318+
column_info["Name"] = {'color': 'magenta'}
319+
307320
if has_category:
308321
column_info["Category"] = {'color': 'green'}
309322

310-
column_info["Duration"] = {'color': 'blue'}
323+
if has_duration:
324+
column_info["Duration"] = {'color': 'blue'}
311325

312326
table_show_manager.add_column(column_info)
313327

314328
# Populate the table with episodes information
315329
for i, media in enumerate(episodes_manager):
316330
name = media.get('name') if isinstance(media, dict) else getattr(media, 'name', None)
331+
number = media.get('number') if isinstance(media, dict) else getattr(media, 'number', None)
317332
duration = media.get('duration') if isinstance(media, dict) else getattr(media, 'duration', None)
318333
category = media.get('category') if isinstance(media, dict) else getattr(media, 'category', None)
319334

320335
episode_info = {
321336
'Index': str(i + 1),
322337
'Name': name,
323-
'Duration': duration,
324338
}
325339

340+
if has_number:
341+
episode_info['Number'] = number
342+
326343
if has_category:
327344
episode_info['Category'] = category
345+
346+
if has_duration:
347+
episode_info['Duration'] = duration
328348

329349
table_show_manager.add_tv_show(episode_info)
330350

0 commit comments

Comments
 (0)