mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-27 13:54:14 +09:00
Added view_count
& last_updated
details about playlist to the output of: youtube-dl -J <YouTube Playlist URL/ID>
This commit is contained in:
parent
47478f876f
commit
dc7db71234
@ -968,7 +968,8 @@ 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,
|
||||
playlist_view_count=None, playlist_last_update=None):
|
||||
"""Returns a playlist"""
|
||||
video_info = {'_type': 'playlist',
|
||||
'entries': entries}
|
||||
@ -978,6 +979,10 @@ class InfoExtractor(object):
|
||||
video_info['title'] = playlist_title
|
||||
if playlist_description:
|
||||
video_info['description'] = playlist_description
|
||||
if playlist_view_count:
|
||||
video_info['view_count'] = playlist_view_count
|
||||
if playlist_last_update:
|
||||
video_info['last_updated'] = playlist_last_update
|
||||
return video_info
|
||||
|
||||
def _search_regex(self, pattern, string, name, default=NO_DEFAULT, fatal=True, flags=0, group=None):
|
||||
|
@ -2786,6 +2786,19 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||
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'])
|
||||
last_updated = unified_strdate(last_updated_text)
|
||||
|
||||
else:
|
||||
renderer = try_get(
|
||||
data, lambda x: x['header']['hashtagHeaderRenderer'], dict)
|
||||
@ -2794,7 +2807,10 @@ 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,
|
||||
playlist_view_count=view_count,
|
||||
playlist_last_update=last_updated
|
||||
)
|
||||
playlist.update(self._extract_uploader(data))
|
||||
return playlist
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user