mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-24 04:14:16 +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)
|
urls, playlist_id=playlist_id, playlist_title=playlist_title)
|
||||||
|
|
||||||
@staticmethod
|
@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"""
|
"""Returns a playlist"""
|
||||||
video_info = {'_type': 'playlist',
|
video_info = {'_type': 'playlist',
|
||||||
'entries': entries}
|
'entries': entries}
|
||||||
|
video_info.update((key, value) for key, value in kwargs.items() if value is not None)
|
||||||
|
|
||||||
if playlist_id:
|
if playlist_id:
|
||||||
video_info['id'] = playlist_id
|
video_info['id'] = playlist_id
|
||||||
if playlist_title:
|
if playlist_title:
|
||||||
|
@ -44,6 +44,7 @@ from ..utils import (
|
|||||||
try_get,
|
try_get,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
|
date_from_str,
|
||||||
unsmuggle_url,
|
unsmuggle_url,
|
||||||
update_url,
|
update_url,
|
||||||
update_url_query,
|
update_url_query,
|
||||||
@ -3163,6 +3164,8 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
|||||||
data, lambda x: x['metadata']['channelMetadataRenderer'], dict)
|
data, lambda x: x['metadata']['channelMetadataRenderer'], dict)
|
||||||
playlist_id = item_id
|
playlist_id = item_id
|
||||||
title = description = None
|
title = description = None
|
||||||
|
view_count = None
|
||||||
|
last_updated = None
|
||||||
if renderer:
|
if renderer:
|
||||||
channel_title = renderer.get('title') or item_id
|
channel_title = renderer.get('title') or item_id
|
||||||
tab_title = selected_tab.get('title')
|
tab_title = selected_tab.get('title')
|
||||||
@ -3178,6 +3181,24 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
|||||||
data, lambda x: x['metadata']['playlistMetadataRenderer'], dict)
|
data, lambda x: x['metadata']['playlistMetadataRenderer'], dict)
|
||||||
if renderer:
|
if renderer:
|
||||||
title = renderer.get('title')
|
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:
|
else:
|
||||||
renderer = try_get(
|
renderer = try_get(
|
||||||
data, lambda x: x['header']['hashtagHeaderRenderer'], dict)
|
data, lambda x: x['header']['hashtagHeaderRenderer'], dict)
|
||||||
@ -3186,7 +3207,9 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
|||||||
playlist = self.playlist_result(
|
playlist = self.playlist_result(
|
||||||
self._entries(selected_tab, item_id, webpage),
|
self._entries(selected_tab, item_id, webpage),
|
||||||
playlist_id=playlist_id, playlist_title=title,
|
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))
|
playlist.update(self._extract_uploader(data))
|
||||||
return playlist
|
return playlist
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user