diff --git a/observatoire/tmdb/data.py b/observatoire/tmdb/data.py index 4b12408..56ab800 100644 --- a/observatoire/tmdb/data.py +++ b/observatoire/tmdb/data.py @@ -28,11 +28,10 @@ def safe_list(values: dict, field_name: str, key: str) -> str: def safe_int(values: dict, field_name: str) -> int: # use first value if values[field_name] is a list - val = ( - values[field_name][0] - if isinstance(values[field_name], list) and len(values[field_name]) > 0 - else values[field_name] - ) + if isinstance(values[field_name], list): + val = values[field_name][0] if len(values[field_name]) > 0 else 0 + else: + val = values[field_name] return int(val) if val is not None else 0 diff --git a/observatoire/tmdb/series/data.py b/observatoire/tmdb/series/data.py index c2e0440..a1af015 100644 --- a/observatoire/tmdb/series/data.py +++ b/observatoire/tmdb/series/data.py @@ -1,4 +1,5 @@ import json +import sys import pandas as pd @@ -81,7 +82,8 @@ def make_series_df(series_json: list[str]) -> pd.DataFrame: safe_data["vote_average"] = safe_float(line_in_json, "vote_average") safe_data["vote_count"] = safe_int(line_in_json, "vote_count") - except Exception: + except Exception as e: + print(f"Error: {e}", file=sys.stderr) continue # remove and newline chracters