mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-28 05:50:01 +08:00
Change long, multi-step accesses to use try_get.
This commit is contained in:
parent
b59130e397
commit
c3f3aa993b
@ -6,7 +6,9 @@ import time
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
compat_str,
|
||||||
str_or_none,
|
str_or_none,
|
||||||
|
try_get,
|
||||||
unified_timestamp,
|
unified_timestamp,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
)
|
)
|
||||||
@ -105,10 +107,7 @@ class RoosterTeethIE(InfoExtractor):
|
|||||||
description = attributes.get('caption')
|
description = attributes.get('caption')
|
||||||
series = attributes.get('show_title')
|
series = attributes.get('show_title')
|
||||||
|
|
||||||
images = data.get('included', {}).get('images')
|
thumbnail = try_get(data, lambda x: x['included']['images'][0]['attributes']['thumb'], compat_str)
|
||||||
if images and len(images) > 0:
|
|
||||||
images = images[0]
|
|
||||||
thumbnail = images.get('attributes', {}).get('thumb')
|
|
||||||
|
|
||||||
video_response = self._call_api(
|
video_response = self._call_api(
|
||||||
display_id,
|
display_id,
|
||||||
@ -137,7 +136,7 @@ class RoosterTeethIE(InfoExtractor):
|
|||||||
else:
|
else:
|
||||||
raise ExtractorError('Video is not available')
|
raise ExtractorError('Video is not available')
|
||||||
|
|
||||||
video_attributes = video_response.get('data')[0].get('attributes')
|
video_attributes = try_get(video_response, lambda x: x['data'][0]['attributes'])
|
||||||
|
|
||||||
m3u8_url = video_attributes.get('url')
|
m3u8_url = video_attributes.get('url')
|
||||||
if not m3u8_url:
|
if not m3u8_url:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user