mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-06-26 04:34:56 +00:00
Compare commits
2 Commits
d49565da20
...
4b97b18050
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b97b18050 | ||
|
|
e89132c678 |
@ -86,6 +86,51 @@ class SubstackIE(InfoExtractor):
|
|||||||
'duration': 25.939592,
|
'duration': 25.939592,
|
||||||
'uploader_id': '535611',
|
'uploader_id': '535611',
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
# A "podcast" page which contains embedded video
|
||||||
|
'url': 'https://substack.com/home/post/p-161501224',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '161501224',
|
||||||
|
'title': 'Videos for Global Medical Tyranny Just Got Real | Daily Pulse',
|
||||||
|
},
|
||||||
|
'playlist': [{
|
||||||
|
'info_dict': {
|
||||||
|
'id': '161501224',
|
||||||
|
'ext': 'mp3',
|
||||||
|
'title': 'Global Medical Tyranny Just Got Real | Daily Pulse',
|
||||||
|
'uploader_id': '975571',
|
||||||
|
'uploader': 'The Vigilant Fox',
|
||||||
|
'thumbnail': r're:https://substack.*video.*/video_upload/post/.+\.png',
|
||||||
|
'description': 'The news you weren’t supposed to see.',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'info_dict': {
|
||||||
|
'id': '95b4b5a7-3873-465d-a6f4-8d3c499f29f2',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'WHO.mp4',
|
||||||
|
'uploader_id': '82027648',
|
||||||
|
'duration': 593.3333,
|
||||||
|
'thumbnail': r're:https://substack.*video.*/video_upload/post/.+\.png',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'info_dict': {
|
||||||
|
'id': '235db8bf-c6e8-439a-b51a-eb7566fc7ac1',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'The Vigilant Fox\'s Video - Apr 16, 2025-VEED.mp4',
|
||||||
|
'uploader_id': '82027648',
|
||||||
|
'duration': 498.86667,
|
||||||
|
'thumbnail': r're:https://substack.*video.*/video_upload/post/.+\.png',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'ef3fe4c1-d748-4665-ba9c-33396008e75b',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'The Vigilant Fox\'s Video - Apr 16, 2025-VEED (1).mp4',
|
||||||
|
'uploader_id': '82027648',
|
||||||
|
'duration': 410.53333,
|
||||||
|
'thumbnail': r're:https://substack.*video.*/video_upload/post/.+\.png',
|
||||||
|
},
|
||||||
|
}],
|
||||||
}]
|
}]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -133,7 +178,9 @@ class SubstackIE(InfoExtractor):
|
|||||||
canonical_url = urllib.parse.urlparse(url)._replace(netloc=domain).geturl()
|
canonical_url = urllib.parse.urlparse(url)._replace(netloc=domain).geturl()
|
||||||
|
|
||||||
post_type = webpage_info['post']['type']
|
post_type = webpage_info['post']['type']
|
||||||
|
post_title = traverse_obj(webpage_info, ('post', 'title'))
|
||||||
formats, subtitles = [], {}
|
formats, subtitles = [], {}
|
||||||
|
all_results = []
|
||||||
result_info = {
|
result_info = {
|
||||||
'id': str(webpage_info['post']['id']),
|
'id': str(webpage_info['post']['id']),
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
@ -144,7 +191,9 @@ class SubstackIE(InfoExtractor):
|
|||||||
'uploader_id': str_or_none(traverse_obj(webpage_info, ('post', 'publication_id'))),
|
'uploader_id': str_or_none(traverse_obj(webpage_info, ('post', 'publication_id'))),
|
||||||
'webpage_url': canonical_url,
|
'webpage_url': canonical_url,
|
||||||
}
|
}
|
||||||
|
# handle specific post types which are based on media
|
||||||
if post_type == 'podcast':
|
if post_type == 'podcast':
|
||||||
|
podcast_result = dict(result_info)
|
||||||
fmt = {'url': webpage_info['post']['podcast_url']}
|
fmt = {'url': webpage_info['post']['podcast_url']}
|
||||||
if not determine_ext(fmt['url'], default_ext=None):
|
if not determine_ext(fmt['url'], default_ext=None):
|
||||||
# The redirected format URL expires but the original URL doesn't,
|
# The redirected format URL expires but the original URL doesn't,
|
||||||
@ -153,21 +202,21 @@ class SubstackIE(InfoExtractor):
|
|||||||
HEADRequest(fmt['url']), display_id,
|
HEADRequest(fmt['url']), display_id,
|
||||||
'Resolving podcast file extension',
|
'Resolving podcast file extension',
|
||||||
'Podcast URL is invalid').url)
|
'Podcast URL is invalid').url)
|
||||||
result_info['formats'] = [fmt]
|
podcast_result['formats'] = [fmt]
|
||||||
return result_info
|
all_results.append(podcast_result)
|
||||||
elif post_type == 'video':
|
if post_type == 'video':
|
||||||
|
video_result = dict(result_info)
|
||||||
formats, subtitles = self._extract_video_formats(
|
formats, subtitles = self._extract_video_formats(
|
||||||
webpage_info['post']['videoUpload']['id'], canonical_url)
|
webpage_info['post']['videoUpload']['id'], canonical_url)
|
||||||
result_info.update({
|
video_result.update({
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
})
|
})
|
||||||
return result_info
|
all_results.append(video_result)
|
||||||
elif post_type == 'newsletter':
|
|
||||||
results = []
|
# search for embedded players on the page
|
||||||
found_items = []
|
found_items = []
|
||||||
post_id = str(webpage_info['post']['id'])
|
post_id = str(webpage_info['post']['id'])
|
||||||
post_title = traverse_obj(webpage_info, ('post', 'title'))
|
|
||||||
assert result_info['uploader_id'] is not None, 'newsletter posted without user_id'
|
assert result_info['uploader_id'] is not None, 'newsletter posted without user_id'
|
||||||
|
|
||||||
video_players = re.finditer(
|
video_players = re.finditer(
|
||||||
@ -230,12 +279,10 @@ class SubstackIE(InfoExtractor):
|
|||||||
'uploader_id': str_or_none(json_vid_data.get('user_id', None)),
|
'uploader_id': str_or_none(json_vid_data.get('user_id', None)),
|
||||||
'uploader': None, # video uploader username is not included
|
'uploader': None, # video uploader username is not included
|
||||||
})
|
})
|
||||||
results.append(new_result)
|
all_results.append(new_result)
|
||||||
|
|
||||||
if len(results) > 0:
|
if len(all_results) > 0:
|
||||||
playlist_title = f'Videos for {post_title}'
|
playlist_title = f'Videos for {post_title}'
|
||||||
return self.playlist_result(results, post_id, playlist_title)
|
return self.playlist_result(all_results, post_id, playlist_title)
|
||||||
else:
|
else:
|
||||||
self.raise_no_formats(f'Page type "{post_type}" contains no supported embeds')
|
self.raise_no_formats(f'Page type "{post_type}" contains no supported embeds')
|
||||||
|
|
||||||
self.raise_no_formats(f'Page type "{post_type}" is not supported')
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user