Fix channel extraction when subscribers not available

This commit is contained in:
Cadence Ember 2020-12-09 16:53:22 +13:00
parent 10f8009101
commit e95d814709
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17
2 changed files with 3 additions and 1 deletions

View File

@ -26,7 +26,7 @@ def extract_channel(ucid):
author = header["title"]
author_id = header["channelId"]
author_url = header["navigationEndpoint"]["commandMetadata"]["webCommandMetadata"]["url"]
subscriber_count = combine_runs(header["subscriberCountText"])
subscriber_count = combine_runs(header["subscriberCountText"]) if "subscribeCountText" in header else "Unknown subscribers"
description = yt_initial_data["metadata"]["channelMetadataRenderer"]["description"]
allowed_regions = yt_initial_data["metadata"]["channelMetadataRenderer"]["availableCountryCodes"]

View File

@ -128,6 +128,8 @@ def normalise_url_protocol(url):
return url
def uncompress_counter(text):
if text.lower() == "no" or text.lower() == "unknown":
return 0
last = text[-1:].lower()
if last >= "0" and last <= "9":
return int(last)