support lazy playlist

pull/10876/head
kclauhk 1 week ago
parent bf4aa73fb7
commit 055c1183ca

@ -24,36 +24,24 @@ class MeritPlusIE(InfoExtractor):
'timestamp': 1724716800, 'timestamp': 1724716800,
'upload_date': '20240827', 'upload_date': '20240827',
'series': 'Dr. Phil Primetime', 'series': 'Dr. Phil Primetime',
'season': 'Season 1',
'season_number': 1,
'episode': 'Episode 79',
'episode_number': 79,
},
}, {
'url': 'https://www.meritplus.com/c/m/ebVUK1wS?r=ok5bikOE',
'info_dict': {
'id': 'ebVUK1wS',
'ext': 'mp4',
'title': 'PBR Teams 2024: Gambler Days | Day 1',
'description': r're:^Get ready for Gambler Days with the PBR! Watch elite riders battle',
'thumbnail': 'https://cdn.jwplayer.com/v2/media/ebVUK1wS/poster.jpg?width=1920',
'duration': 10876.0,
'tags': 'count:6',
'timestamp': 1724461200,
'upload_date': '20240824',
}, },
}, { }, {
'url': 'https://www.meritplus.com/m/AzVJ4sEH/bull-rider-najiah-knight-the-cowgirl-way?r=uzD8QNRj', 'url': 'https://www.meritplus.com/m/XeoP00kQ/marching-cobras-somebodys-gotta-do-it-with-mike-rowe?r=8SrBMsCA&play=1',
'info_dict': { 'info_dict': {
'id': 'AzVJ4sEH', 'id': 'XeoP00kQ',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Bull Rider Najiah Knight | The Cowgirl Way', 'title': 'Marching Cobras | Somebody\'s Gotta Do It with Mike Rowe',
'description': r're:^Najiah Knight is rewriting the rules and inspiring future Cowgirls', 'description': r're:^Don Daughtry teaches his young students to reach for a brighter future',
'thumbnail': 'https://cdn.jwplayer.com/v2/media/AzVJ4sEH/poster.jpg?width=1920', 'thumbnail': 'https://cdn.jwplayer.com/v2/media/XeoP00kQ/poster.jpg?width=1920',
'duration': 300.0, 'duration': 1471.0,
'tags': ['The Cowgirl Way', 'seriesId_uzD8QNRj', 'PBR'], 'tags': 'count:14',
'timestamp': 1720195320, 'timestamp': 1714233600,
'upload_date': '20240705', 'upload_date': '20240427',
'series': 'Somebody\'s Gotta Do It With Mike Rowe',
'episode': 'Episode 13',
'episode_number': 13,
'season': 'Season 1',
'season_number': 1,
}, },
}, { }, {
'url': 'https://www.meritplus.com/c/sns/jryHEWXj', 'url': 'https://www.meritplus.com/c/sns/jryHEWXj',
@ -61,18 +49,18 @@ class MeritPlusIE(InfoExtractor):
'id': 'jryHEWXj', 'id': 'jryHEWXj',
'title': 'Morning On Merit Street', 'title': 'Morning On Merit Street',
'description': r're:^Award winning journalist Dominique Sachse and co-host Fanchon Stinger', 'description': r're:^Award winning journalist Dominique Sachse and co-host Fanchon Stinger',
'thumbnail': 'https://assets.mediabackstage.com/merit_prod/thumbnails/moms_thumbnail_1920x1080-1708708358462.jpg', 'thumbnail': r're:^https://assets.mediabackstage.com/merit_prod.*\.png',
}, },
'playlist_count': 5, 'playlist_mincount': 5,
}, { }, {
'url': 'https://www.meritplus.com/c/s/eAzd5bqW', 'url': 'https://www.meritplus.com/c/s/eAzd5bqW',
'info_dict': { 'info_dict': {
'id': 'eAzd5bqW', 'id': 'eAzd5bqW',
'title': 'Crime Stories with Nancy Grace', 'title': 'Crime Stories with Nancy Grace',
'description': r're:^Nancy Grace explores the inside story of true crimes and cold cases', 'description': r're:^Nancy Grace explores the inside story of true crimes and cold cases',
'thumbnail': 'https://assets.mediabackstage.com/merit_prod%2Fthumbnails%2Fnancygrace_thumbnail_1920x1080-1721658217049.jpg', 'thumbnail': r're:^https://assets.mediabackstage.com/merit_prod.*\.jpg',
}, },
'playlist_count': 15, 'playlist_mincount': 10,
}] }]
def _real_extract(self, url): def _real_extract(self, url):
@ -82,8 +70,7 @@ class MeritPlusIE(InfoExtractor):
else: else:
json = self._download_json(f'https://cdn.jwplayer.com/v2/playlists/{video_id}?format=json&page_limit=500', video_id) json = self._download_json(f'https://cdn.jwplayer.com/v2/playlists/{video_id}?format=json&page_limit=500', video_id)
entries = [] def extract_video(video):
for video in json.get('playlist', []):
thumbnails, formats, subtitles = [], [], {} thumbnails, formats, subtitles = [], [], {}
for image in video.get('images', []): for image in video.get('images', []):
thumbnails.append({ thumbnails.append({
@ -120,7 +107,7 @@ class MeritPlusIE(InfoExtractor):
'vcodec': ('type', {lambda v: 'none' if 'audio' in v else None}), 'vcodec': ('type', {lambda v: 'none' if 'audio' in v else None}),
})) }))
entries.append({**traverse_obj(video, { return {**traverse_obj(video, {
'id': ('mediaid', {str}), 'id': ('mediaid', {str}),
'title': ('title', {str}), 'title': ('title', {str}),
'description': ('description', {str}), 'description': ('description', {str}),
@ -138,15 +125,17 @@ class MeritPlusIE(InfoExtractor):
'thumbnails': thumbnails, 'thumbnails': thumbnails,
'formats': formats, 'formats': formats,
'subtitles': subtitles, 'subtitles': subtitles,
}) }
if len(entries) == 1: playlist = json.get('playlist', [])
return entries[0] if len(playlist) == 1:
elif len(entries) > 1: return extract_video(playlist[0])
elif len(playlist) > 1:
description = join_nonempty('shortDescription', 'description', delim=' ', from_dict=json) description = join_nonempty('shortDescription', 'description', delim=' ', from_dict=json)
thumbnail = traverse_obj(json, (('imgHomeRailThumb16x9', 'imgFeaturedTvBanner16x9'), thumbnail = traverse_obj(json, (('imgHomeRailThumb16x9', 'imgFeaturedTvBanner16x9'),
{url_or_none}), get_all=False) {url_or_none}), get_all=False)
return self.playlist_result(entries, id=json['seriesId'], title=json['title'], return self.playlist_result((extract_video(video) for video in playlist),
id=json['seriesId'], title=json['title'],
description=description, thumbnail=thumbnail) description=description, thumbnail=thumbnail)
else: else:
self.raise_no_formats('No video formats found!') self.raise_no_formats('No video formats found!')

Loading…
Cancel
Save