mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-01-08 12:30:10 +09:00
[InstagramUser] Make use of try_get()
This commit is contained in:
parent
acf3c646db
commit
b4b9ab4a08
@ -365,11 +365,12 @@ class InstagramUserIE(InfoExtractor):
|
|||||||
resp = self._download_json('https://www.instagram.com/graphql/query/',
|
resp = self._download_json('https://www.instagram.com/graphql/query/',
|
||||||
username,
|
username,
|
||||||
query=query)
|
query=query)
|
||||||
media = resp['data']['user']['edge_saved_media']
|
media = try_get(resp,
|
||||||
|
lambda x: x['data']['user']['edge_saved_media'])
|
||||||
|
|
||||||
for edge in media.get('edges', []):
|
for edge in media.get('edges', []):
|
||||||
node = edge.get('node')
|
node = try_get(edge, lambda x: x['node'], dict)
|
||||||
if not node or not isinstance(node, dict):
|
if not node:
|
||||||
continue
|
continue
|
||||||
if node.get('__typename') != 'GraphVideo' and node.get('is_video') is not True:
|
if node.get('__typename') != 'GraphVideo' and node.get('is_video') is not True:
|
||||||
continue
|
continue
|
||||||
@ -382,16 +383,16 @@ class InstagramUserIE(InfoExtractor):
|
|||||||
|
|
||||||
yield info
|
yield info
|
||||||
|
|
||||||
page_info = media.get('page_info')
|
page_info = try_get(media, lambda x: x['page_info'], dict)
|
||||||
if not page_info or not isinstance(page_info, dict):
|
if not page_info:
|
||||||
break
|
break
|
||||||
|
|
||||||
has_next_page = page_info.get('has_next_page')
|
has_next_page = page_info.get('has_next_page')
|
||||||
if not has_next_page:
|
if not has_next_page:
|
||||||
break
|
break
|
||||||
|
|
||||||
cursor = page_info.get('end_cursor')
|
cursor = try_get(page_info, lambda x: x['end_cursor'], compat_str)
|
||||||
if not cursor or not isinstance(cursor, compat_str):
|
if not cursor:
|
||||||
break
|
break
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
Loading…
Reference in New Issue
Block a user