aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2020-12-18 12:55:12 -0800
committerJesús <heckyel@hyperbola.info>2020-12-18 23:39:25 -0500
commit6b6a6653a02da9a76b101ba6c4e05366d49ee034 (patch)
treec74735a4711462316a83376432e02bd4d0fb6356 /youtube
parenta16b05af80e6532741ae58ef996b81da68ccb7a8 (diff)
downloadyt-local-6b6a6653a02da9a76b101ba6c4e05366d49ee034.tar.lz
yt-local-6b6a6653a02da9a76b101ba6c4e05366d49ee034.tar.xz
yt-local-6b6a6653a02da9a76b101ba6c4e05366d49ee034.zip
Fix youtube mixes
They cannot be viewed on their own, so change url in items to go to the video+playlist instead Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'youtube')
-rw-r--r--youtube/util.py10
-rw-r--r--youtube/yt_data_extract/common.py5
2 files changed, 13 insertions, 2 deletions
diff --git a/youtube/util.py b/youtube/util.py
index df4759e..355d8c7 100644
--- a/youtube/util.py
+++ b/youtube/util.py
@@ -502,10 +502,16 @@ def add_extra_html_info(item):
item['video_info'] = json.dumps(video_info)
+ elif item['type'] == 'playlist' and item['playlist_type'] == 'radio':
+ item['url'] = concat_or_none(
+ URL_ORIGIN,
+ '/watch?v=', item['first_video_id'],
+ '&list=', item['id']
+ )
elif item['type'] == 'playlist':
- item['url'] = (URL_ORIGIN + '/playlist?list=' + item['id']) if item.get('id') else None
+ item['url'] = concat_or_none(URL_ORIGIN, '/playlist?list=', item['id'])
elif item['type'] == 'channel':
- item['url'] = (URL_ORIGIN + "/channel/" + item['id']) if item.get('id') else None
+ item['url'] = concat_or_none(URL_ORIGIN, "/channel/", item['id'])
def parse_info_prepare_for_html(renderer, additional_info={}):
diff --git a/youtube/yt_data_extract/common.py b/youtube/yt_data_extract/common.py
index 683b1c6..1ec3dc3 100644
--- a/youtube/yt_data_extract/common.py
+++ b/youtube/yt_data_extract/common.py
@@ -226,6 +226,7 @@ def extract_item_info(item, additional_info={}):
info['type'] = 'video'
elif primary_type in ('playlist', 'radio', 'show'):
info['type'] = 'playlist'
+ info['playlist_type'] = primary_type
elif primary_type == 'channel':
info['type'] = 'channel'
elif type == 'videoWithContextRenderer': # stupid exception
@@ -313,11 +314,15 @@ def extract_item_info(item, additional_info={}):
elif primary_type in ('playlist', 'radio'):
info['id'] = item.get('playlistId')
info['video_count'] = extract_int(item.get('videoCount'))
+ info['first_video_id'] = deep_get(item, 'navigationEndpoint',
+ 'watchEndpoint', 'videoId')
elif primary_type == 'channel':
info['id'] = item.get('channelId')
info['approx_subscriber_count'] = extract_approx_int(item.get('subscriberCountText'))
elif primary_type == 'show':
info['id'] = deep_get(item, 'navigationEndpoint', 'watchEndpoint', 'playlistId')
+ info['first_video_id'] = deep_get(item, 'navigationEndpoint',
+ 'watchEndpoint', 'videoId')
if primary_type in ('playlist', 'channel'):
conservative_update(info, 'video_count', extract_int(item.get('videoCountText')))