Skip to content

Commit

Permalink
Merge branch 'main' into sort-results-popularity
Browse files Browse the repository at this point in the history
  • Loading branch information
kaaloo committed May 13, 2024
2 parents 7489456 + 0b86a33 commit 65e9850
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions observatoire/tmdb/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 3 additions & 1 deletion observatoire/tmdb/series/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import sys

import pandas as pd

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 65e9850

Please sign in to comment.