1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-12-31 00:17:51 +08:00

[trilulilu] handle errors

This commit is contained in:
remitamine 2015-12-05 09:29:14 +01:00
parent 64b7e89c0c
commit 02e3952f3b

View File

@ -49,6 +49,15 @@ class TriluliluIE(InfoExtractor):
display_id = self._match_id(url) display_id = self._match_id(url)
media_info = self._download_json('http://m.trilulilu.ro/%s?format=json' % display_id, display_id) media_info = self._download_json('http://m.trilulilu.ro/%s?format=json' % display_id, display_id)
age_limit = 0
errors = media_info.get('errors', {})
if errors.get('friends'):
raise ExtractorError('This video is private.', expected=True)
elif errors.get('geoblock'):
raise ExtractorError('This video is not available in your country.', expected=True)
elif errors.get('xxx_unlogged'):
age_limit = 18
media_class = media_info.get('class') media_class = media_info.get('class')
if media_class not in ('video', 'audio'): if media_class not in ('video', 'audio'):
raise ExtractorError('not a video or an audio') raise ExtractorError('not a video or an audio')
@ -90,4 +99,5 @@ class TriluliluIE(InfoExtractor):
'view_count': int_or_none(media_info.get('count_views')), 'view_count': int_or_none(media_info.get('count_views')),
'like_count': int_or_none(media_info.get('count_likes')), 'like_count': int_or_none(media_info.get('count_likes')),
'comment_count': int_or_none(media_info.get('count_comments')), 'comment_count': int_or_none(media_info.get('count_comments')),
'age_limit': age_limit,
} }