1
0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2024-11-24 16:37:29 +00:00

Support originals with no view count

This commit is contained in:
Cadence Ember 2021-01-01 17:28:38 +13:00
parent 20b133dbb6
commit 8a0fb5cf21
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17

View File

@ -51,7 +51,13 @@ def view_count_text_to_number(text):
return int(first_word) return int(first_word)
def get_view_count_or_recommended(view_count_container): 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 if "runs" in text: # has live viewers
return view_count_text_to_number(combine_runs(text)) return view_count_text_to_number(combine_runs(text))
else: else:
@ -62,7 +68,13 @@ def get_view_count_or_recommended(view_count_container):
return view_count_text_to_number(text) return view_count_text_to_number(text)
def get_view_count_text_or_recommended(view_count_container): 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 if "runs" in text: # has live viewers
return combine_runs(text) return combine_runs(text)
else: # has past views else: # has past views