1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-11-27 08:35:37 +08:00
youtube-dl/youtube_dl/extractor/trilulilu.py

66 lines
2.0 KiB
Python
Raw Normal View History

2014-11-26 19:56:28 +08:00
from __future__ import unicode_literals
import json
from .common import InfoExtractor
class TriluliluIE(InfoExtractor):
2014-11-26 19:56:28 +08:00
_VALID_URL = r'https?://(?:www\.)?trilulilu\.ro/video-[^/]+/(?P<id>[^/]+)'
_TEST = {
2014-11-26 19:56:28 +08: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',
},
# Server ignores Range headers (--test)
2014-11-26 19:56:28 +08:00
'params': {
'skip_download': True
}
}
def _real_extract(self, url):
2014-11-26 19:56:28 +08:00
video_id = self._match_id(url)
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 19:56:28 +08:00
r'block_flash_vars[ ]=[ ]({[^}]+})', webpage, 'log info')
log = json.loads(log_str)
2014-11-26 19:56:28 +08:00
format_url = ('http://fs%(server)s.trilulilu.ro/%(hash)s/'
'video-formats2' % log)
format_doc = self._download_xml(
format_url, video_id,
2014-11-26 19:56:28 +08:00
note='Downloading formats',
errnote='Error while downloading formats')
2014-11-24 03:41:03 +08:00
video_url_template = (
2014-11-26 19:56:28 +08: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=' %
log)
formats = [
{
'format': fnode.text,
'url': video_url_template % fnode.text,
2013-09-14 20:45:04 +08:00
'ext': fnode.text.partition('-')[0]
}
for fnode in format_doc.findall('./formats/format')
]
return {
'_type': 'video',
'id': video_id,
'formats': formats,
'title': title,
'description': description,
'thumbnail': thumbnail,
}