From e95d814709b0646d4121d9e42ac9f41eaadbe582 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Wed, 9 Dec 2020 16:53:22 +1300 Subject: [PATCH] Fix channel extraction when subscribers not available --- extractors/channel.py | 2 +- tools/converters.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extractors/channel.py b/extractors/channel.py index ef827cc..f8e8d03 100644 --- a/extractors/channel.py +++ b/extractors/channel.py @@ -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"] diff --git a/tools/converters.py b/tools/converters.py index c5875c6..d8b9a67 100644 --- a/tools/converters.py +++ b/tools/converters.py @@ -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)