From 8a0fb5cf210f0b6ecd3fc530c96ae65f822e47ca Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 1 Jan 2021 17:28:38 +1300 Subject: [PATCH] Support originals with no view count --- tools/converters.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/converters.py b/tools/converters.py index d8b9a67..f8577ad 100644 --- a/tools/converters.py +++ b/tools/converters.py @@ -51,7 +51,13 @@ def view_count_text_to_number(text): return int(first_word) def get_view_count_or_recommended(view_count_container): - text = view_count_container.get("viewCountText") or view_count_container["viewCount"] + if "viewCountText" in view_count_container: + text = view_count_container["viewCountText"] + elif "viewCount" in view_count_container: + text = view_count_container["viewCount"] + else: + return 0 + if "runs" in text: # has live viewers return view_count_text_to_number(combine_runs(text)) else: @@ -62,7 +68,13 @@ def get_view_count_or_recommended(view_count_container): return view_count_text_to_number(text) def get_view_count_text_or_recommended(view_count_container): - text = view_count_container.get("viewCountText") or view_count_container["viewCount"] + if "viewCountText" in view_count_container: + text = view_count_container["viewCountText"] + elif "viewCount" in view_count_container: + text = view_count_container["viewCount"] + else: + return None + if "runs" in text: # has live viewers return combine_runs(text) else: # has past views