mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-03-09 12:50:23 -05:00
Error early for invalid URL
This commit is contained in:
parent
35cb46c6c7
commit
592ac372ea
1 changed files with 3 additions and 3 deletions
|
@ -709,6 +709,8 @@ class InstagramStoryIE(InstagramBaseIE):
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
username, story_id = self._match_valid_url(url).group('user', 'id')
|
username, story_id = self._match_valid_url(url).group('user', 'id')
|
||||||
|
if username == 'highlights' and not story_id: # story id is only mandatory for highlights
|
||||||
|
raise ExtractorError('Missing highlight id')
|
||||||
display_id = story_id or username
|
display_id = story_id or username
|
||||||
story_info = self._download_webpage(url, display_id)
|
story_info = self._download_webpage(url, display_id)
|
||||||
user_info = self._search_json(r'"user":', story_info, 'user info', display_id, fatal=False)
|
user_info = self._search_json(r'"user":', story_info, 'user info', display_id, fatal=False)
|
||||||
|
@ -718,8 +720,6 @@ def _real_extract(self, url):
|
||||||
user_id = traverse_obj(user_info, 'pk', 'id', expected_type=str)
|
user_id = traverse_obj(user_info, 'pk', 'id', expected_type=str)
|
||||||
if username == 'highlights':
|
if username == 'highlights':
|
||||||
story_info_url = f'highlight:{story_id}'
|
story_info_url = f'highlight:{story_id}'
|
||||||
if not story_id: # story id is only mandatory for highlights
|
|
||||||
raise ExtractorError('Missing highlight id')
|
|
||||||
else:
|
else:
|
||||||
if not user_id: # user id is only mandatory for non-highlights
|
if not user_id: # user id is only mandatory for non-highlights
|
||||||
raise ExtractorError('Unable to extract user id')
|
raise ExtractorError('Unable to extract user id')
|
||||||
|
@ -739,7 +739,7 @@ def _real_extract(self, url):
|
||||||
highlights = traverse_obj(videos, (f'highlight:{story_id}', 'items'), (user_id, 'items'))
|
highlights = traverse_obj(videos, (f'highlight:{story_id}', 'items'), (user_id, 'items'))
|
||||||
info_data = []
|
info_data = []
|
||||||
for highlight in highlights:
|
for highlight in highlights:
|
||||||
highlight['title'] = story_title
|
# highlight['title'] = story_title
|
||||||
highlight_data = self._extract_product(highlight)
|
highlight_data = self._extract_product(highlight)
|
||||||
if highlight_data.get('formats'):
|
if highlight_data.get('formats'):
|
||||||
info_data.append({
|
info_data.append({
|
||||||
|
|
Loading…
Reference in a new issue