diff --git a/extractors/channel.py b/extractors/channel.py index 63ce92e..03e1f74 100644 --- a/extractors/channel.py +++ b/extractors/channel.py @@ -132,12 +132,16 @@ def extract_channel(ucid, second__path="user"): for r in maybe_get(lv, "metadata", "lockupMetadataViewModel", "metadata", "contentMetadataViewModel", "metadataRows", default=[]): for p in r.get("metadataParts", []): t = maybe_get(p, "text", "content", default="") + a = maybe_get(p, "accessibilityLabel", default="") if t.startswith("Streamed") or t.endswith("ago"): published_text = t published = past_text_to_time(published_text) elif t.endswith("views"): view_count_text_short = t view_count_text = t + elif a.endswith("views"): + view_count_text_short = f"{t} views" + view_count_text = f"{t} views" for o in lv["contentImage"]["thumbnailViewModel"]["overlays"]: if m := o.get("thumbnailBottomOverlayViewModel"): diff --git a/tools/converters.py b/tools/converters.py index 075c1b2..5355854 100644 --- a/tools/converters.py +++ b/tools/converters.py @@ -169,15 +169,16 @@ def uncompress_counter(text): return int(float(text[:-1]) * multiplier) def past_text_to_time(text): - words = text.split(" ") + spaced_text = re.sub(r"^([0-9]+)([^ ])", r"\1 \2", text) + words = spaced_text.split(" ") if words[0] == "Streamed": words = words[1:] if len(words) != 3: print(words) - raise Exception("Past text is not 3 words") + raise Exception(f"Past text is not 3 words: '{text}'") if words[2] != "ago": print(words) - raise Exception('Past text does not end with "ago"') + raise Exception(f"Past text does not end with \"ago\": '{text}'") number = int(words[0]) unit = words[1][:2] multiplier = 1