support lazy playlist

This commit is contained in:
kclauhk 2024-12-18 03:29:07 +08:00
parent bf4aa73fb7
commit 055c1183ca

View file

@ -24,36 +24,24 @@ class MeritPlusIE(InfoExtractor):
'timestamp': 1724716800,
'upload_date': '20240827',
'series': 'Dr. Phil Primetime',
},
}, {
'url': 'https://www.meritplus.com/m/XeoP00kQ/marching-cobras-somebodys-gotta-do-it-with-mike-rowe?r=8SrBMsCA&play=1',
'info_dict': {
'id': 'XeoP00kQ',
'ext': 'mp4',
'title': 'Marching Cobras | Somebody\'s Gotta Do It with Mike Rowe',
'description': r're:^Don Daughtry teaches his young students to reach for a brighter future',
'thumbnail': 'https://cdn.jwplayer.com/v2/media/XeoP00kQ/poster.jpg?width=1920',
'duration': 1471.0,
'tags': 'count:14',
'timestamp': 1714233600,
'upload_date': '20240427',
'series': 'Somebody\'s Gotta Do It With Mike Rowe',
'episode': 'Episode 13',
'episode_number': 13,
'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',
'info_dict': {
'id': 'AzVJ4sEH',
'ext': 'mp4',
'title': 'Bull Rider Najiah Knight | The Cowgirl Way',
'description': r're:^Najiah Knight is rewriting the rules and inspiring future Cowgirls',
'thumbnail': 'https://cdn.jwplayer.com/v2/media/AzVJ4sEH/poster.jpg?width=1920',
'duration': 300.0,
'tags': ['The Cowgirl Way', 'seriesId_uzD8QNRj', 'PBR'],
'timestamp': 1720195320,
'upload_date': '20240705',
},
}, {
'url': 'https://www.meritplus.com/c/sns/jryHEWXj',
@ -61,18 +49,18 @@ class MeritPlusIE(InfoExtractor):
'id': 'jryHEWXj',
'title': 'Morning On Merit Street',
'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',
'info_dict': {
'id': 'eAzd5bqW',
'title': 'Crime Stories with Nancy Grace',
'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):
@ -82,8 +70,7 @@ class MeritPlusIE(InfoExtractor):
else:
json = self._download_json(f'https://cdn.jwplayer.com/v2/playlists/{video_id}?format=json&page_limit=500', video_id)
entries = []
for video in json.get('playlist', []):
def extract_video(video):
thumbnails, formats, subtitles = [], [], {}
for image in video.get('images', []):
thumbnails.append({
@ -120,7 +107,7 @@ class MeritPlusIE(InfoExtractor):
'vcodec': ('type', {lambda v: 'none' if 'audio' in v else None}),
}))
entries.append({**traverse_obj(video, {
return {**traverse_obj(video, {
'id': ('mediaid', {str}),
'title': ('title', {str}),
'description': ('description', {str}),
@ -138,15 +125,17 @@ class MeritPlusIE(InfoExtractor):
'thumbnails': thumbnails,
'formats': formats,
'subtitles': subtitles,
})
}
if len(entries) == 1:
return entries[0]
elif len(entries) > 1:
playlist = json.get('playlist', [])
if len(playlist) == 1:
return extract_video(playlist[0])
elif len(playlist) > 1:
description = join_nonempty('shortDescription', 'description', delim=' ', from_dict=json)
thumbnail = traverse_obj(json, (('imgHomeRailThumb16x9', 'imgFeaturedTvBanner16x9'),
{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)
else:
self.raise_no_formats('No video formats found!')