mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-23 11:54:13 +09:00
Merge 8d657f3efc6b36753cec07832bdd4fa9274145bb into 1d3751c3fe50b203d3e2bff71d866c8c500f8288
This commit is contained in:
commit
104897db3b
@ -969,10 +969,12 @@ class InfoExtractor(object):
|
||||
urls, playlist_id=playlist_id, playlist_title=playlist_title)
|
||||
|
||||
@staticmethod
|
||||
def playlist_result(entries, playlist_id=None, playlist_title=None, playlist_description=None):
|
||||
def playlist_result(entries, playlist_id=None, playlist_title=None, playlist_description=None, **kwargs):
|
||||
"""Returns a playlist"""
|
||||
video_info = {'_type': 'playlist',
|
||||
'entries': entries}
|
||||
video_info.update((key, value) for key, value in kwargs.items() if value is not None)
|
||||
|
||||
if playlist_id:
|
||||
video_info['id'] = playlist_id
|
||||
if playlist_title:
|
||||
|
@ -44,6 +44,7 @@ from ..utils import (
|
||||
try_get,
|
||||
unescapeHTML,
|
||||
unified_strdate,
|
||||
date_from_str,
|
||||
unsmuggle_url,
|
||||
update_url,
|
||||
update_url_query,
|
||||
@ -3163,6 +3164,8 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||
data, lambda x: x['metadata']['channelMetadataRenderer'], dict)
|
||||
playlist_id = item_id
|
||||
title = description = None
|
||||
view_count = None
|
||||
last_updated = None
|
||||
if renderer:
|
||||
channel_title = renderer.get('title') or item_id
|
||||
tab_title = selected_tab.get('title')
|
||||
@ -3178,6 +3181,24 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||
data, lambda x: x['metadata']['playlistMetadataRenderer'], dict)
|
||||
if renderer:
|
||||
title = renderer.get('title')
|
||||
description = renderer.get('description')
|
||||
|
||||
stats = try_get(
|
||||
data, lambda x: x['sidebar']['playlistSidebarRenderer']['items'][0]['playlistSidebarPrimaryInfoRenderer']['stats'])
|
||||
view_count_text = try_get(
|
||||
stats, lambda x: x[1]['simpleText'], compat_str) or ''
|
||||
view_count = str_to_int(self._search_regex(
|
||||
r'^([\d,]+)', re.sub(r'\s', '', view_count_text),
|
||||
'view count', default=None))
|
||||
|
||||
last_updated_text = try_get(stats, lambda x: x[2]['runs'][1]['text']) or try_get(stats, lambda x: x[2]['runs'][0]['text'])
|
||||
last_updated_text = last_updated_text.replace('Updated ', '') if 'Updated ' in last_updated_text else last_updated_text
|
||||
try:
|
||||
last_updated = unified_strdate(last_updated_text)
|
||||
if last_updated is None:
|
||||
last_updated = date_from_str(last_updated_text).strftime("%Y%m%d")
|
||||
except ValueError:
|
||||
last_updated = None
|
||||
else:
|
||||
renderer = try_get(
|
||||
data, lambda x: x['header']['hashtagHeaderRenderer'], dict)
|
||||
@ -3186,7 +3207,9 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||
playlist = self.playlist_result(
|
||||
self._entries(selected_tab, item_id, webpage),
|
||||
playlist_id=playlist_id, playlist_title=title,
|
||||
playlist_description=description)
|
||||
playlist_description=description,
|
||||
view_count=view_count,
|
||||
last_updated=last_updated)
|
||||
playlist.update(self._extract_uploader(data))
|
||||
return playlist
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user