1
0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2024-11-21 23:27:29 +00:00

Correctly handle videos with 0 views

This commit is contained in:
Cadence Ember 2020-10-15 00:32:06 +13:00
parent 0b9874a4f4
commit ad1f8df7cb
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17

View File

@ -44,7 +44,11 @@ def add_html_links(text):
return text
def view_count_text_to_number(text):
return int(text.split(" ")[0].replace(",", ""))
first_word = text.split(" ")[0].replace(",", "")
if first_word == "No":
return 0
else:
return int(first_word)
def get_view_count_or_recommended(view_count_container):
text = view_count_container.get("viewCountText") or view_count_container["viewCount"]