2 from __future__ import unicode_literals
4 from .common import InfoExtractor
12 class TriluliluIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:(?:www|m)\.)?trilulilu\.ro/(?:[^/]+/)?(?P<id>[^/#\?]+)'
15 'url': 'http://www.trilulilu.ro/big-buck-bunny-1',
16 'md5': '68da087b676a6196a413549212f60cc6',
18 'id': 'ae2899e124140b',
20 'title': 'Big Buck Bunny',
21 'description': ':) pentru copilul din noi',
22 'uploader_id': 'chipy',
23 'upload_date': '20120304',
24 'timestamp': 1330830647,
31 'url': 'http://www.trilulilu.ro/adena-ft-morreti-inocenta',
32 'md5': '929dfb8729dc71750463af88bbbbf4a4',
34 'id': 'f299710e3c91c5',
36 'title': 'Adena ft. Morreti - Inocenta',
37 'description': 'pop music',
38 'uploader_id': 'VEVOmixt',
39 'upload_date': '20151204',
40 'uploader': 'VEVOmixt',
41 'timestamp': 1449187937,
48 def _real_extract(self, url):
49 display_id = self._match_id(url)
50 media_info = self._download_json('http://m.trilulilu.ro/%s?format=json' % display_id, display_id)
53 errors = media_info.get('errors', {})
54 if errors.get('friends'):
55 raise ExtractorError('This video is private.', expected=True)
56 elif errors.get('geoblock'):
57 raise ExtractorError('This video is not available in your country.', expected=True)
58 elif errors.get('xxx_unlogged'):
61 media_class = media_info.get('class')
62 if media_class not in ('video', 'audio'):
63 raise ExtractorError('not a video or an audio')
65 user = media_info.get('user', {})
67 thumbnail = media_info.get('cover_url')
69 thumbnail.format(width='1600', height='1200')
71 # TODO: get correct ext for audio files
72 stream_type = media_info.get('stream_type')
74 'url': media_info['href'],
77 if media_info.get('is_hd'):
80 'url': media_info['hrefhd'],
83 if media_class == 'audio':
84 formats[0]['vcodec'] = 'none'
86 formats[0]['format_id'] = 'sd'
89 'id': media_info['identifier'].split('|')[1],
90 'display_id': display_id,
92 'title': media_info['title'],
93 'description': media_info.get('description'),
94 'thumbnail': thumbnail,
95 'uploader_id': user.get('username'),
96 'uploader': user.get('fullname'),
97 'timestamp': parse_iso8601(media_info.get('published'), ' '),
98 'duration': int_or_none(media_info.get('duration')),
99 'view_count': int_or_none(media_info.get('count_views')),
100 'like_count': int_or_none(media_info.get('count_likes')),
101 'comment_count': int_or_none(media_info.get('count_comments')),
102 'age_limit': age_limit,