2015-02-09 22:55:31 +08:00
|
|
|
# coding: utf-8
|
2014-11-26 19:56:28 +08:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2013-08-27 07:59:00 +08:00
|
|
|
from .common import InfoExtractor
|
2015-12-04 07:51:02 +08:00
|
|
|
from ..utils import (
|
|
|
|
ExtractorError,
|
|
|
|
int_or_none,
|
|
|
|
parse_iso8601,
|
|
|
|
)
|
2013-08-27 07:59:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
class TriluliluIE(InfoExtractor):
|
2015-12-04 07:51:02 +08:00
|
|
|
_VALID_URL = r'https?://(?:(?:www|m)\.)?trilulilu\.ro/(?:[^/]+/)?(?P<id>[^/#\?]+)'
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'http://www.trilulilu.ro/big-buck-bunny-1',
|
|
|
|
'md5': '68da087b676a6196a413549212f60cc6',
|
2014-11-26 19:56:28 +08:00
|
|
|
'info_dict': {
|
2015-02-09 22:55:31 +08:00
|
|
|
'id': 'ae2899e124140b',
|
2014-11-26 19:56:28 +08:00
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Big Buck Bunny',
|
|
|
|
'description': ':) pentru copilul din noi',
|
2015-12-04 07:51:02 +08:00
|
|
|
'uploader_id': 'chipy',
|
|
|
|
'upload_date': '20120304',
|
|
|
|
'timestamp': 1330830647,
|
|
|
|
'uploader': 'chipy',
|
|
|
|
'view_count': int,
|
|
|
|
'like_count': int,
|
|
|
|
'comment_count': int,
|
2013-08-27 07:59:00 +08:00
|
|
|
},
|
2015-12-04 07:51:02 +08:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.trilulilu.ro/adena-ft-morreti-inocenta',
|
|
|
|
'md5': '929dfb8729dc71750463af88bbbbf4a4',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'f299710e3c91c5',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Adena ft. Morreti - Inocenta',
|
|
|
|
'description': 'pop music',
|
|
|
|
'uploader_id': 'VEVOmixt',
|
|
|
|
'upload_date': '20151204',
|
|
|
|
'uploader': 'VEVOmixt',
|
|
|
|
'timestamp': 1449187937,
|
|
|
|
'view_count': int,
|
|
|
|
'like_count': int,
|
|
|
|
'comment_count': int,
|
|
|
|
},
|
|
|
|
}]
|
2013-08-27 07:59:00 +08:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2015-02-09 22:55:31 +08:00
|
|
|
display_id = self._match_id(url)
|
2015-12-04 07:51:02 +08:00
|
|
|
media_info = self._download_json('http://m.trilulilu.ro/%s?format=json' % display_id, display_id)
|
|
|
|
user = media_info.get('user', {})
|
2015-02-09 22:55:31 +08:00
|
|
|
|
2015-12-04 07:51:02 +08:00
|
|
|
thumbnail = media_info.get('cover_url')
|
|
|
|
if thumbnail:
|
|
|
|
thumbnail.format(width='1600', height='1200')
|
2013-08-27 07:59:00 +08:00
|
|
|
|
2015-12-04 07:51:02 +08:00
|
|
|
media_class = media_info.get('class')
|
|
|
|
if media_class in ('video', 'audio'):
|
|
|
|
# TODO: get correct ext for audio files
|
|
|
|
stream_type = media_info.get('stream_type')
|
|
|
|
formats = [{
|
|
|
|
'url': media_info['href'],
|
|
|
|
'ext': stream_type,
|
|
|
|
}]
|
|
|
|
if media_info.get('is_hd'):
|
|
|
|
formats.append({
|
|
|
|
'url': media_info['hrefhd'],
|
|
|
|
'ext': stream_type,
|
|
|
|
})
|
2015-02-09 22:55:31 +08:00
|
|
|
else:
|
2015-12-04 07:51:02 +08:00
|
|
|
raise ExtractorError('not a video or an audio')
|
2013-08-27 07:59:00 +08:00
|
|
|
|
2015-12-04 07:51:02 +08:00
|
|
|
if media_class == 'audio':
|
|
|
|
formats[0]['vcodec'] = 'none'
|
2013-08-27 07:59:00 +08:00
|
|
|
|
2013-12-03 21:21:06 +08:00
|
|
|
return {
|
2015-12-04 07:51:02 +08:00
|
|
|
'id': media_info['identifier'].split('|')[1],
|
2015-02-09 22:55:31 +08:00
|
|
|
'display_id': display_id,
|
2013-08-27 07:59:00 +08:00
|
|
|
'formats': formats,
|
2015-12-04 07:51:02 +08:00
|
|
|
'title': media_info['title'],
|
|
|
|
'description': media_info.get('description'),
|
2013-08-27 07:59:00 +08:00
|
|
|
'thumbnail': thumbnail,
|
2015-12-04 07:51:02 +08:00
|
|
|
'uploader_id': user.get('username'),
|
|
|
|
'uploader': user.get('fullname'),
|
|
|
|
'timestamp': parse_iso8601(media_info.get('published'), ' '),
|
|
|
|
'duration': int_or_none(media_info.get('duration')),
|
|
|
|
'view_count': int_or_none(media_info.get('count_views')),
|
|
|
|
'like_count': int_or_none(media_info.get('count_likes')),
|
|
|
|
'comment_count': int_or_none(media_info.get('count_comments')),
|
2013-08-27 07:59:00 +08:00
|
|
|
}
|