From fe57ebf7f0942e57f1f00b1e1692da933748a696 Mon Sep 17 00:00:00 2001 From: girst Date: Wed, 19 Aug 2020 19:14:35 +0200 Subject: [PATCH] more innertube renderers --- app/common/innertube.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/app/common/innertube.py b/app/common/innertube.py index 3320d55..2d87c7b 100644 --- a/app/common/innertube.py +++ b/app/common/innertube.py @@ -164,6 +164,16 @@ def parse_result_items(items): content['videoCountText']['runs'][0]['text'], # videoCountShortText: "50+"; videoCountText: "50+ videos" }}) + elif key == 'showRenderer': # normal playlist, specially displayed + results.append({'type': 'PLAYLIST', 'content': { + 'playlist_id': content['navigationEndpoint']['watchEndpoint']['playlistId'], + 'video_id': content['navigationEndpoint']['watchEndpoint']['videoId'], + 'title': content['title']['simpleText'], + 'author': content['longBylineText']['runs'][0]['text'] or \ + content['shortBylineText']['runs'][0]['text'], + 'channel_id': None, + 'n_videos': None, + }}) elif key == 'channelRenderer': results.append({'type': 'CHANNEL', 'content': { 'channel_id': content['channelId'], @@ -176,8 +186,8 @@ def parse_result_items(items): r, e = parse_result_items(content['content'][subkey]['items']) results.extend(r) extras.extend(e) - elif key == 'movieRenderer': # movies to buy/rent - pass + elif key in ['movieRenderer', 'gridMovieRenderer']: # movies to buy/rent + pass # gMR.{videoId,title.runs[].text,lengthText.simpleText} elif key in ['carouselAdRenderer','searchPyvRenderer','promotedSparklesTextSearchRenderer']: # haha, no. pass elif key == 'horizontalCardListRenderer': @@ -193,6 +203,11 @@ def parse_result_items(items): 'query': content['correctedQueryEndpoint']['searchEndpoint']['query'], # non-misspelled query 'autocorrected': key == 'showingResultsForRenderer', }) + elif key == 'messageRenderer': # "No more results" + extras.append({ + 'type': 'message', + 'message': content['title']['runs'][0]['text'], + }) elif key == 'backgroundPromoRenderer': # e.g. "no results" extras.append({ 'type': content['icon']['iconType'], @@ -332,6 +347,15 @@ def parse_channel_items(items, channel_id, author): content.get('videoCountShortText',{}).get('simpleText') or # grid(1) content.get('videoCountText',{}).get('runs',[{}])[0].get('text')), # grid(2) }}) + elif key == "showRenderer": + result.append({'type': 'PLAYLIST', 'content': { + 'playlist_id': content['navigationEndpoint']['watchEndpoint']['playlistId'], + 'video_id': content['navigationEndpoint']['watchEndpoint']['videoId'], + 'title': content['title']['simpleText'], + 'author': author, + 'channel_id': channel_id, + 'n_videos': None, + }}) elif key in ["itemSectionRenderer", "gridRenderer", "horizontalCardListRenderer"]: newkey = { "itemSectionRenderer": 'contents', -- 2.39.3