1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-03-20 05:38:46 +08:00

Change long, multi-step accesses to use try_get.

This commit is contained in:
ddmgy 2018-06-12 19:39:31 -04:00
parent b59130e397
commit c3f3aa993b

View File

@ -6,7 +6,9 @@ import time
from .common import InfoExtractor
from ..utils import (
ExtractorError,
compat_str,
str_or_none,
try_get,
unified_timestamp,
urlencode_postdata,
)
@ -105,10 +107,7 @@ class RoosterTeethIE(InfoExtractor):
description = attributes.get('caption')
series = attributes.get('show_title')
images = data.get('included', {}).get('images')
if images and len(images) > 0:
images = images[0]
thumbnail = images.get('attributes', {}).get('thumb')
thumbnail = try_get(data, lambda x: x['included']['images'][0]['attributes']['thumb'], compat_str)
video_response = self._call_api(
display_id,
@ -137,7 +136,7 @@ class RoosterTeethIE(InfoExtractor):
else:
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')
if not m3u8_url: