2014-11-26 11:56:28 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2013-08-26 23:59:00 +00:00
|
|
|
import json
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
|
|
|
|
|
|
|
class TriluliluIE(InfoExtractor):
|
2014-11-26 11:56:28 +00:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?trilulilu\.ro/video-[^/]+/(?P<id>[^/]+)'
|
2013-08-26 23:59:00 +00:00
|
|
|
_TEST = {
|
2014-11-26 11:56:28 +00:00
|
|
|
'url': 'http://www.trilulilu.ro/video-animatie/big-buck-bunny-1',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'big-buck-bunny-1',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Big Buck Bunny',
|
|
|
|
'description': ':) pentru copilul din noi',
|
2013-08-26 23:59:00 +00:00
|
|
|
},
|
|
|
|
# Server ignores Range headers (--test)
|
2014-11-26 11:56:28 +00:00
|
|
|
'params': {
|
|
|
|
'skip_download': True
|
2013-08-26 23:59:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-11-26 11:56:28 +00:00
|
|
|
video_id = self._match_id(url)
|
2013-08-26 23:59:00 +00:00
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
|
|
|
title = self._og_search_title(webpage)
|
|
|
|
thumbnail = self._og_search_thumbnail(webpage)
|
|
|
|
description = self._og_search_description(webpage)
|
|
|
|
|
|
|
|
log_str = self._search_regex(
|
2014-11-26 11:56:28 +00:00
|
|
|
r'block_flash_vars[ ]=[ ]({[^}]+})', webpage, 'log info')
|
2013-08-26 23:59:00 +00:00
|
|
|
log = json.loads(log_str)
|
|
|
|
|
2014-11-26 11:56:28 +00:00
|
|
|
format_url = ('http://fs%(server)s.trilulilu.ro/%(hash)s/'
|
|
|
|
'video-formats2' % log)
|
2013-11-26 17:48:52 +00:00
|
|
|
format_doc = self._download_xml(
|
2013-08-26 23:59:00 +00:00
|
|
|
format_url, video_id,
|
2014-11-26 11:56:28 +00:00
|
|
|
note='Downloading formats',
|
|
|
|
errnote='Error while downloading formats')
|
2014-11-23 19:41:03 +00:00
|
|
|
|
2013-08-26 23:59:00 +00:00
|
|
|
video_url_template = (
|
2014-11-26 11:56:28 +00:00
|
|
|
'http://fs%(server)s.trilulilu.ro/stream.php?type=video'
|
|
|
|
'&source=site&hash=%(hash)s&username=%(userid)s&'
|
|
|
|
'key=ministhebest&format=%%s&sig=&exp=' %
|
2013-08-26 23:59:00 +00:00
|
|
|
log)
|
|
|
|
formats = [
|
|
|
|
{
|
|
|
|
'format': fnode.text,
|
|
|
|
'url': video_url_template % fnode.text,
|
2013-09-14 12:45:04 +00:00
|
|
|
'ext': fnode.text.partition('-')[0]
|
2013-08-26 23:59:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for fnode in format_doc.findall('./formats/format')
|
|
|
|
]
|
|
|
|
|
2013-12-03 13:21:06 +00:00
|
|
|
return {
|
2013-08-26 23:59:00 +00:00
|
|
|
'_type': 'video',
|
|
|
|
'id': video_id,
|
|
|
|
'formats': formats,
|
|
|
|
'title': title,
|
|
|
|
'description': description,
|
|
|
|
'thumbnail': thumbnail,
|
|
|
|
}
|