mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-30 12:17:54 +01:00
Fixed issues from travis-ci
This commit is contained in:
parent
53ca134ca9
commit
36ce480413
@ -1,3 +1,4 @@
|
|||||||
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
@ -22,9 +23,7 @@ class RtlluIE(InfoExtractor):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
match = self._VALID_URL_RE.match(url)
|
id = self._match_id(url)
|
||||||
id = match.group('id')
|
|
||||||
|
|
||||||
webpage = self._download_webpage(url, id)
|
webpage = self._download_webpage(url, id)
|
||||||
|
|
||||||
javascript_regex = r'<script language="Javascript">((\n*?.*?)*?)</script>'
|
javascript_regex = r'<script language="Javascript">((\n*?.*?)*?)</script>'
|
||||||
@ -32,60 +31,91 @@ class RtlluIE(InfoExtractor):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
javascript_sources_regex = r'object.*\.sources = \'(?P<value>.*?)\';'
|
javascript_sources_regex = r'object.*\.sources = \'(?P<value>.*?)\';'
|
||||||
sources = json.loads(re.search(javascript_sources_regex, javascript).group('value'))
|
sources = self._search_regex(javascript_sources_regex, javascript, 'sources')
|
||||||
|
sources = json.loads(sources)
|
||||||
|
|
||||||
javascript_videoid_regex = r'object.*\.videoid = \'(?P<value>.*?)\';'
|
videoid_regex = r'object.*\.videoid = \'(?P<value>.*?)\';'
|
||||||
javascript_videoid = re.search(javascript_videoid_regex, javascript).group('value')
|
videoid = self._search_regex(videoid_regex, javascript, 'videoid', fatal=False, default=id)
|
||||||
|
|
||||||
javascript_publicdate_regex = r'object.*\.publicdate = \'(?P<value>.*?)\';'
|
publicdate_regex = r'object.*\.publicdate = \'(?P<value>.*?)\';'
|
||||||
javascript_publicdate = re.search(javascript_publicdate_regex, javascript).group('value')
|
publicdate = self._search_regex(publicdate_regex, javascript, 'publicdate', fatal=False)
|
||||||
|
|
||||||
javascript_thumbnail_regex = r'object.*\.thumbnail = \'(?P<value>.*?)\';'
|
thumbnail_regex = r'object.*\.thumbnail = \'(?P<value>.*?)\';'
|
||||||
javascript_thumbnail = re.search(javascript_thumbnail_regex, javascript).group('value')
|
thumbnail = self._search_regex(thumbnail_regex, javascript, 'thumbnail', fatal=False)
|
||||||
|
|
||||||
formats = [
|
formats = []
|
||||||
|
|
||||||
|
rtmp_source = sources.get('rtmp')
|
||||||
|
if rtmp_source is not None:
|
||||||
|
rtmp_url = rtmp_source.get('src')
|
||||||
|
|
||||||
|
if rtmp_url is not None:
|
||||||
|
formats.append(
|
||||||
{
|
{
|
||||||
'url': sources['rtmp']['src'],
|
'url': rtmp_url,
|
||||||
'format': 'RTMP Stream',
|
'format': 'RTMP Stream',
|
||||||
'format_id': 'rtmp',
|
'format_id': 'rtmp',
|
||||||
'protocol': 'rtmp',
|
'protocol': 'rtmp'
|
||||||
},
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
httplq_source = sources.get('httplq')
|
||||||
|
if httplq_source is not None:
|
||||||
|
httplq_url = httplq_source.get('src')
|
||||||
|
|
||||||
|
if httplq_url is not None:
|
||||||
|
formats.append(
|
||||||
{
|
{
|
||||||
'url': sources['httplq']['src'],
|
'url': httplq_url,
|
||||||
'format': 'Low Quality',
|
'format': 'Low Quality',
|
||||||
'format_id': 'lq',
|
'format_id': 'lq',
|
||||||
'protocol': 'http',
|
'protocol': 'http',
|
||||||
},
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
http_source = sources.get('http')
|
||||||
|
if http_source is not None:
|
||||||
|
http_url = http_source.get('src')
|
||||||
|
|
||||||
|
if http_url is not None:
|
||||||
|
formats.append(
|
||||||
{
|
{
|
||||||
'url': sources['http']['src'],
|
'url': http_url,
|
||||||
'format': 'Standard Quality',
|
'format': 'Standard Quality',
|
||||||
'format_id': 'sd',
|
'format_id': 'sd',
|
||||||
'protocol': 'http',
|
'protocol': 'http',
|
||||||
},
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
httphq_source = sources.get('httphq')
|
||||||
|
if httphq_source is not None:
|
||||||
|
httphq_url = httphq_source.get('src')
|
||||||
|
|
||||||
|
if httphq_url is not None:
|
||||||
|
formats.append(
|
||||||
{
|
{
|
||||||
'url': sources['httphq']['src'],
|
'url': httphq_url,
|
||||||
'format': 'High Quality',
|
'format': 'High Quality',
|
||||||
'format_id': 'hq',
|
'format_id': 'hq',
|
||||||
'protocol': 'http',
|
'protocol': 'http',
|
||||||
},
|
}
|
||||||
]
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': javascript_videoid or id,
|
'id': videoid,
|
||||||
'title': self.get_video_title(webpage, javascript),
|
'title': self.get_video_title(webpage, javascript),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'thumbnail': javascript_thumbnail,
|
'thumbnail': thumbnail,
|
||||||
'upload_date': javascript_publicdate,
|
'upload_date': publicdate,
|
||||||
}
|
}
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
javascript_mp3_regex = r'play_mp3\("object[0-9]*", "(?P<value>.*?)",'
|
mp3_regex = r'play_mp3\("object[0-9]*", "(?P<value>.*?)",'
|
||||||
javascript_mp3 = re.search(javascript_mp3_regex, javascript).group('value')
|
mp3_url = self._search_regex(mp3_regex, javascript, 'mp3_url')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': id,
|
'id': id,
|
||||||
'title': self.get_audio_title(webpage),
|
'title': self.get_audio_title(webpage),
|
||||||
'url': javascript_mp3,
|
'url': mp3_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_video_title(self, webpage, javascript):
|
def get_video_title(self, webpage, javascript):
|
||||||
@ -97,7 +127,7 @@ class RtlluIE(InfoExtractor):
|
|||||||
title = title[-1]
|
title = title[-1]
|
||||||
|
|
||||||
javascript_title_regex = r'object.*\.title = \'(?P<value>.*?)\';'
|
javascript_title_regex = r'object.*\.title = \'(?P<value>.*?)\';'
|
||||||
javascript_title = re.search(javascript_title_regex, javascript).group('value')
|
javascript_title = self._search_regex(javascript_title_regex, javascript, 'javascript_title', fatal=False)
|
||||||
return javascript_title or title or self._og_search_title(webpage)
|
return javascript_title or title or self._og_search_title(webpage)
|
||||||
|
|
||||||
def get_audio_title(self, webpage):
|
def get_audio_title(self, webpage):
|
||||||
|
Loading…
Reference in New Issue
Block a user