2015-02-09 16:55:31 +02:00
|
|
|
# coding: utf-8
|
2014-11-26 12:56:28 +01:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2015-12-05 08:51:08 +01:00
|
|
|
import re
|
|
|
|
|
2013-08-27 01:59:00 +02:00
|
|
|
from .common import InfoExtractor
|
2015-12-04 00:51:02 +01:00
|
|
|
from ..utils import (
|
|
|
|
ExtractorError,
|
|
|
|
parse_iso8601,
|
2015-12-05 08:51:08 +01:00
|
|
|
js_to_json,
|
|
|
|
parse_duration,
|
2015-12-04 00:51:02 +01:00
|
|
|
)
|
2013-08-27 01:59:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TriluliluIE(InfoExtractor):
|
2015-12-04 00:51:02 +01: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 12:56:28 +01:00
|
|
|
'info_dict': {
|
2015-02-09 16:55:31 +02:00
|
|
|
'id': 'ae2899e124140b',
|
2014-11-26 12:56:28 +01:00
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Big Buck Bunny',
|
|
|
|
'description': ':) pentru copilul din noi',
|
2015-12-04 00:51:02 +01:00
|
|
|
'uploader_id': 'chipy',
|
|
|
|
'upload_date': '20120304',
|
|
|
|
'timestamp': 1330830647,
|
2013-08-27 01:59:00 +02:00
|
|
|
},
|
2015-12-04 00:51:02 +01: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',
|
|
|
|
'timestamp': 1449187937,
|
|
|
|
},
|
|
|
|
}]
|
2013-08-27 01:59:00 +02:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2015-02-09 16:55:31 +02:00
|
|
|
display_id = self._match_id(url)
|
2015-12-05 08:51:08 +01:00
|
|
|
webpage = self._download_webpage(url, display_id)
|
2015-12-04 06:53:33 +01:00
|
|
|
|
2015-12-05 08:51:08 +01:00
|
|
|
if re.search(r'Fişierul nu este disponibil pentru vizionare în ţara dumneavoastră', webpage):
|
|
|
|
raise ExtractorError(
|
|
|
|
'This video is not available in your country.', expected=True)
|
|
|
|
elif re.search('Fişierul poate fi accesat doar de către prietenii lui', webpage):
|
|
|
|
raise ExtractorError('This video is private.', expected=True)
|
|
|
|
|
|
|
|
player_vars = self._parse_json(
|
|
|
|
self._search_regex(r'(?s)playerVars\s*=\s*({.+?});', webpage, 'player vars'),
|
|
|
|
display_id, js_to_json)
|
2015-12-04 06:53:33 +01:00
|
|
|
|
2015-12-05 08:51:08 +01:00
|
|
|
uploader_id, media_id = self._search_regex(
|
|
|
|
r'<input type="hidden" id="identifier" value="([^"]+)"',
|
|
|
|
webpage, 'identifier').split('|')
|
2015-02-09 16:55:31 +02:00
|
|
|
|
2015-12-05 08:51:08 +01:00
|
|
|
media_class = player_vars.get('fileClass')
|
|
|
|
if media_class not in ('video', 'audio'):
|
|
|
|
raise ExtractorError('not a video or an audio')
|
2013-08-27 01:59:00 +02:00
|
|
|
|
2015-12-04 06:53:33 +01:00
|
|
|
# TODO: get correct ext for audio files
|
|
|
|
formats = [{
|
2015-12-05 08:51:08 +01:00
|
|
|
'url': player_vars['file'],
|
|
|
|
'ext': player_vars.get('streamType'),
|
2015-12-04 06:53:33 +01:00
|
|
|
}]
|
2015-12-05 08:51:08 +01:00
|
|
|
|
|
|
|
hd_url = player_vars.get('fileUrlHD')
|
|
|
|
if hd_url:
|
2015-12-04 06:53:33 +01:00
|
|
|
formats.append({
|
|
|
|
'format_id': 'hd',
|
2015-12-05 08:51:08 +01:00
|
|
|
'url': hd_url,
|
|
|
|
'ext': player_vars.get('fileTypeHD'),
|
2015-12-04 06:53:33 +01:00
|
|
|
})
|
2015-12-05 08:51:08 +01:00
|
|
|
|
2015-12-04 00:51:02 +01:00
|
|
|
if media_class == 'audio':
|
|
|
|
formats[0]['vcodec'] = 'none'
|
2015-12-04 06:53:33 +01:00
|
|
|
else:
|
|
|
|
formats[0]['format_id'] = 'sd'
|
2013-08-27 01:59:00 +02:00
|
|
|
|
2013-12-03 14:21:06 +01:00
|
|
|
return {
|
2015-12-05 08:51:08 +01:00
|
|
|
'id': media_id,
|
2015-02-09 16:55:31 +02:00
|
|
|
'display_id': display_id,
|
2013-08-27 01:59:00 +02:00
|
|
|
'formats': formats,
|
2015-12-05 08:51:08 +01:00
|
|
|
'title': self._og_search_title(webpage),
|
|
|
|
'description': self._og_search_description(webpage),
|
|
|
|
'thumbnail': player_vars.get('image'),
|
|
|
|
'uploader_id': uploader_id,
|
|
|
|
'timestamp': parse_iso8601(self._html_search_meta('uploadDate', webpage), ' '),
|
|
|
|
'duration': parse_duration(self._html_search_meta('duration', webpage)),
|
2013-08-27 01:59:00 +02:00
|
|
|
}
|