mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-11 17:50:23 +00:00
[trilulilu] Add support for videos without category in the URL (Closes #4067)
Also, update the testcase, detect private/country restricted videos and modernize a bit.
This commit is contained in:
parent
ba61796458
commit
2caf182f37
@ -1,40 +1,55 @@
|
|||||||
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import json
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..utils import ExtractorError
|
||||||
|
|
||||||
|
|
||||||
class TriluliluIE(InfoExtractor):
|
class TriluliluIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?trilulilu\.ro/video-[^/]+/(?P<id>[^/]+)'
|
_VALID_URL = r'https?://(?:www\.)?trilulilu\.ro/(?:video-[^/]+/)?(?P<id>[^/#\?]+)'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://www.trilulilu.ro/video-animatie/big-buck-bunny-1',
|
'url': 'http://www.trilulilu.ro/video-animatie/big-buck-bunny-1',
|
||||||
|
'md5': 'c1450a00da251e2769b74b9005601cac',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'big-buck-bunny-1',
|
'id': 'ae2899e124140b',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Big Buck Bunny',
|
'title': 'Big Buck Bunny',
|
||||||
'description': ':) pentru copilul din noi',
|
'description': ':) pentru copilul din noi',
|
||||||
},
|
},
|
||||||
# Server ignores Range headers (--test)
|
|
||||||
'params': {
|
|
||||||
'skip_download': True
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
flashvars_str = self._search_regex(
|
||||||
|
r'block_flash_vars\s*=\s*(\{[^\}]+\})', webpage, 'flashvars', fatal=False, default=None)
|
||||||
|
|
||||||
|
if flashvars_str:
|
||||||
|
flashvars = self._parse_json(flashvars_str, display_id)
|
||||||
|
else:
|
||||||
|
raise ExtractorError(
|
||||||
|
'This page does not contain videos', expected=True)
|
||||||
|
|
||||||
|
if flashvars['isMP3'] == 'true':
|
||||||
|
raise ExtractorError(
|
||||||
|
'Audio downloads are currently not supported', expected=True)
|
||||||
|
|
||||||
|
video_id = flashvars['hash']
|
||||||
title = self._og_search_title(webpage)
|
title = self._og_search_title(webpage)
|
||||||
thumbnail = self._og_search_thumbnail(webpage)
|
thumbnail = self._og_search_thumbnail(webpage)
|
||||||
description = self._og_search_description(webpage)
|
description = self._og_search_description(webpage, default=None)
|
||||||
|
|
||||||
log_str = self._search_regex(
|
|
||||||
r'block_flash_vars[ ]=[ ]({[^}]+})', webpage, 'log info')
|
|
||||||
log = json.loads(log_str)
|
|
||||||
|
|
||||||
format_url = ('http://fs%(server)s.trilulilu.ro/%(hash)s/'
|
format_url = ('http://fs%(server)s.trilulilu.ro/%(hash)s/'
|
||||||
'video-formats2' % log)
|
'video-formats2' % flashvars)
|
||||||
format_doc = self._download_xml(
|
format_doc = self._download_xml(
|
||||||
format_url, video_id,
|
format_url, video_id,
|
||||||
note='Downloading formats',
|
note='Downloading formats',
|
||||||
@ -44,10 +59,10 @@ def _real_extract(self, url):
|
|||||||
'http://fs%(server)s.trilulilu.ro/stream.php?type=video'
|
'http://fs%(server)s.trilulilu.ro/stream.php?type=video'
|
||||||
'&source=site&hash=%(hash)s&username=%(userid)s&'
|
'&source=site&hash=%(hash)s&username=%(userid)s&'
|
||||||
'key=ministhebest&format=%%s&sig=&exp=' %
|
'key=ministhebest&format=%%s&sig=&exp=' %
|
||||||
log)
|
flashvars)
|
||||||
formats = [
|
formats = [
|
||||||
{
|
{
|
||||||
'format': fnode.text,
|
'format_id': fnode.text.partition('-')[2],
|
||||||
'url': video_url_template % fnode.text,
|
'url': video_url_template % fnode.text,
|
||||||
'ext': fnode.text.partition('-')[0]
|
'ext': fnode.text.partition('-')[0]
|
||||||
}
|
}
|
||||||
@ -56,8 +71,8 @@ def _real_extract(self, url):
|
|||||||
]
|
]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'_type': 'video',
|
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
'display_id': display_id,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'title': title,
|
'title': title,
|
||||||
'description': description,
|
'description': description,
|
||||||
|
Loading…
Reference in New Issue
Block a user