From 84ddba1d6ce71f5a1fec4e0ff564c5ba0570c688 Mon Sep 17 00:00:00 2001 From: girst Date: Wed, 5 Jan 2022 22:00:18 +0100 Subject: [PATCH] port videoid_from_thumbnail() to |G() --- app/common/innertube.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/common/innertube.py b/app/common/innertube.py index aad2027..92e29fc 100644 --- a/app/common/innertube.py +++ b/app/common/innertube.py @@ -3,10 +3,6 @@ from urllib.parse import parse_qs, urlparse import re -def listget(obj, index, fallback=None): - if obj is None: return fallback - return next(iter(obj[index:]), fallback) - class G: """ null-coalescing version of dict.get() that also works on lists. @@ -336,7 +332,7 @@ def parse_endcard(card): def videoid_from_thumbnail(content): # learning playlist; example: PL96C35uN7xGJu6skU4TBYrIWxggkZBrF5 (/user/enyay/playlists) return re.match(r"https?://i.ytimg.com/vi/([-_0-9a-zA-Z]{11})|()", - listget(listget(content.get('thumbnails',[]),0,{}).get('thumbnails',[]),0,{}).get('url','') + content|G('thumbnails')|G(0)|G('thumbnails')|G(0)|G('url') or '' ).group(1) def parse_channel_items(items, channel_id, author): -- 2.39.3