Merge branch 'master' into ESPN-issue-13244
This commit is contained in:
commit
cf70113498
@ -98,6 +98,7 @@ from youtube_dl.compat import (
|
|||||||
compat_chr,
|
compat_chr,
|
||||||
compat_etree_fromstring,
|
compat_etree_fromstring,
|
||||||
compat_getenv,
|
compat_getenv,
|
||||||
|
compat_os_name,
|
||||||
compat_setenv,
|
compat_setenv,
|
||||||
compat_urlparse,
|
compat_urlparse,
|
||||||
compat_parse_qs,
|
compat_parse_qs,
|
||||||
@ -448,7 +449,9 @@ class TestUtil(unittest.TestCase):
|
|||||||
|
|
||||||
def test_shell_quote(self):
|
def test_shell_quote(self):
|
||||||
args = ['ffmpeg', '-i', encodeFilename('ñ€ß\'.mp4')]
|
args = ['ffmpeg', '-i', encodeFilename('ñ€ß\'.mp4')]
|
||||||
self.assertEqual(shell_quote(args), """ffmpeg -i 'ñ€ß'"'"'.mp4'""")
|
self.assertEqual(
|
||||||
|
shell_quote(args),
|
||||||
|
"""ffmpeg -i 'ñ€ß'"'"'.mp4'""" if compat_os_name != 'nt' else '''ffmpeg -i "ñ€ß'.mp4"''')
|
||||||
|
|
||||||
def test_str_to_int(self):
|
def test_str_to_int(self):
|
||||||
self.assertEqual(str_to_int('123,456'), 123456)
|
self.assertEqual(str_to_int('123,456'), 123456)
|
||||||
@ -932,7 +935,7 @@ class TestUtil(unittest.TestCase):
|
|||||||
def test_args_to_str(self):
|
def test_args_to_str(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
args_to_str(['foo', 'ba/r', '-baz', '2 be', '']),
|
args_to_str(['foo', 'ba/r', '-baz', '2 be', '']),
|
||||||
'foo ba/r -baz \'2 be\' \'\''
|
'foo ba/r -baz \'2 be\' \'\'' if compat_os_name != 'nt' else 'foo ba/r -baz "2 be" ""'
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_parse_filesize(self):
|
def test_parse_filesize(self):
|
||||||
@ -1228,6 +1231,12 @@ part 3</font></u>
|
|||||||
self.assertEqual(get_element_by_attribute('class', 'foo', html), None)
|
self.assertEqual(get_element_by_attribute('class', 'foo', html), None)
|
||||||
self.assertEqual(get_element_by_attribute('class', 'no-such-foo', html), None)
|
self.assertEqual(get_element_by_attribute('class', 'no-such-foo', html), None)
|
||||||
|
|
||||||
|
html = '''
|
||||||
|
<div itemprop="author" itemscope>foo</div>
|
||||||
|
'''
|
||||||
|
|
||||||
|
self.assertEqual(get_element_by_attribute('itemprop', 'author', html), 'foo')
|
||||||
|
|
||||||
def test_get_elements_by_class(self):
|
def test_get_elements_by_class(self):
|
||||||
html = '''
|
html = '''
|
||||||
<span class="foo bar">nice</span><span class="foo bar">also nice</span>
|
<span class="foo bar">nice</span><span class="foo bar">also nice</span>
|
||||||
|
@ -324,7 +324,7 @@ class KalturaIE(InfoExtractor):
|
|||||||
if captions:
|
if captions:
|
||||||
for caption in captions.get('objects', []):
|
for caption in captions.get('objects', []):
|
||||||
# Continue if caption is not ready
|
# Continue if caption is not ready
|
||||||
if f.get('status') != 2:
|
if caption.get('status') != 2:
|
||||||
continue
|
continue
|
||||||
if not caption.get('id'):
|
if not caption.get('id'):
|
||||||
continue
|
continue
|
||||||
|
@ -15,7 +15,21 @@ from ..utils import (
|
|||||||
class VierIE(InfoExtractor):
|
class VierIE(InfoExtractor):
|
||||||
IE_NAME = 'vier'
|
IE_NAME = 'vier'
|
||||||
IE_DESC = 'vier.be and vijf.be'
|
IE_DESC = 'vier.be and vijf.be'
|
||||||
_VALID_URL = r'https?://(?:www\.)?(?P<site>vier|vijf)\.be/(?:[^/]+/videos/(?P<display_id>[^/]+)(?:/(?P<id>\d+))?|video/v3/embed/(?P<embed_id>\d+))'
|
_VALID_URL = r'''(?x)
|
||||||
|
https?://
|
||||||
|
(?:www\.)?(?P<site>vier|vijf)\.be/
|
||||||
|
(?:
|
||||||
|
(?:
|
||||||
|
[^/]+/videos|
|
||||||
|
video(?:/[^/]+)*
|
||||||
|
)/
|
||||||
|
(?P<display_id>[^/]+)(?:/(?P<id>\d+))?|
|
||||||
|
(?:
|
||||||
|
video/v3/embed|
|
||||||
|
embed/video/public
|
||||||
|
)/(?P<embed_id>\d+)
|
||||||
|
)
|
||||||
|
'''
|
||||||
_NETRC_MACHINE = 'vier'
|
_NETRC_MACHINE = 'vier'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.vier.be/planb/videos/het-wordt-warm-de-moestuin/16129',
|
'url': 'http://www.vier.be/planb/videos/het-wordt-warm-de-moestuin/16129',
|
||||||
@ -83,6 +97,15 @@ class VierIE(InfoExtractor):
|
|||||||
}, {
|
}, {
|
||||||
'url': 'http://www.vier.be/video/v3/embed/16129',
|
'url': 'http://www.vier.be/video/v3/embed/16129',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.vijf.be/embed/video/public/4093',
|
||||||
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.vier.be/video/blockbusters/in-juli-en-augustus-summer-classics',
|
||||||
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.vier.be/video/achter-de-rug/2017/achter-de-rug-seizoen-1-aflevering-6',
|
||||||
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_initialize(self):
|
def _real_initialize(self):
|
||||||
@ -133,14 +156,20 @@ class VierIE(InfoExtractor):
|
|||||||
video_id = self._search_regex(
|
video_id = self._search_regex(
|
||||||
[r'data-nid="(\d+)"', r'"nid"\s*:\s*"(\d+)"'],
|
[r'data-nid="(\d+)"', r'"nid"\s*:\s*"(\d+)"'],
|
||||||
webpage, 'video id', default=video_id or display_id)
|
webpage, 'video id', default=video_id or display_id)
|
||||||
|
|
||||||
|
playlist_url = self._search_regex(
|
||||||
|
r'data-file=(["\'])(?P<url>(?:https?:)?//[^/]+/.+?\.m3u8.*?)\1',
|
||||||
|
webpage, 'm3u8 url', default=None, group='url')
|
||||||
|
|
||||||
|
if not playlist_url:
|
||||||
application = self._search_regex(
|
application = self._search_regex(
|
||||||
[r'data-application="([^"]+)"', r'"application"\s*:\s*"([^"]+)"'],
|
[r'data-application="([^"]+)"', r'"application"\s*:\s*"([^"]+)"'],
|
||||||
webpage, 'application', default=site + '_vod')
|
webpage, 'application', default=site + '_vod')
|
||||||
filename = self._search_regex(
|
filename = self._search_regex(
|
||||||
[r'data-filename="([^"]+)"', r'"filename"\s*:\s*"([^"]+)"'],
|
[r'data-filename="([^"]+)"', r'"filename"\s*:\s*"([^"]+)"'],
|
||||||
webpage, 'filename')
|
webpage, 'filename')
|
||||||
|
|
||||||
playlist_url = 'http://vod.streamcloud.be/%s/_definst_/mp4:%s.mp4/playlist.m3u8' % (application, filename)
|
playlist_url = 'http://vod.streamcloud.be/%s/_definst_/mp4:%s.mp4/playlist.m3u8' % (application, filename)
|
||||||
|
|
||||||
formats = self._extract_wowza_formats(
|
formats = self._extract_wowza_formats(
|
||||||
playlist_url, display_id, skip_protocols=['dash'])
|
playlist_url, display_id, skip_protocols=['dash'])
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import base64
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_urllib_parse_unquote
|
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
float_or_none,
|
||||||
|
get_element_by_attribute,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
parse_duration,
|
remove_end,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -24,6 +23,7 @@ class XuiteIE(InfoExtractor):
|
|||||||
'id': '3860914',
|
'id': '3860914',
|
||||||
'ext': 'mp3',
|
'ext': 'mp3',
|
||||||
'title': '孤單南半球-歐德陽',
|
'title': '孤單南半球-歐德陽',
|
||||||
|
'description': '孤單南半球-歐德陽',
|
||||||
'thumbnail': r're:^https?://.*\.jpg$',
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||||||
'duration': 247.246,
|
'duration': 247.246,
|
||||||
'timestamp': 1314932940,
|
'timestamp': 1314932940,
|
||||||
@ -44,7 +44,7 @@ class XuiteIE(InfoExtractor):
|
|||||||
'duration': 596.458,
|
'duration': 596.458,
|
||||||
'timestamp': 1454242500,
|
'timestamp': 1454242500,
|
||||||
'upload_date': '20160131',
|
'upload_date': '20160131',
|
||||||
'uploader': 'yan12125',
|
'uploader': '屁姥',
|
||||||
'uploader_id': '12158353',
|
'uploader_id': '12158353',
|
||||||
'categories': ['個人短片'],
|
'categories': ['個人短片'],
|
||||||
'description': 'http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4',
|
'description': 'http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4',
|
||||||
@ -72,10 +72,10 @@ class XuiteIE(InfoExtractor):
|
|||||||
# from http://forgetfulbc.blogspot.com/2016/06/date.html
|
# from http://forgetfulbc.blogspot.com/2016/06/date.html
|
||||||
'url': 'http://vlog.xuite.net/embed/cE1xbENoLTI3NDQ3MzM2LmZsdg==?ar=0&as=0',
|
'url': 'http://vlog.xuite.net/embed/cE1xbENoLTI3NDQ3MzM2LmZsdg==?ar=0&as=0',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'cE1xbENoLTI3NDQ3MzM2LmZsdg==',
|
'id': '27447336',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': '男女平權只是口號?專家解釋約會時男生是否該幫女生付錢 (中字)',
|
'title': '男女平權只是口號?專家解釋約會時男生是否該幫女生付錢 (中字)',
|
||||||
'description': 'md5:f0abdcb69df300f522a5442ef3146f2a',
|
'description': 'md5:1223810fa123b179083a3aed53574706',
|
||||||
'timestamp': 1466160960,
|
'timestamp': 1466160960,
|
||||||
'upload_date': '20160617',
|
'upload_date': '20160617',
|
||||||
'uploader': 'B.C. & Lowy',
|
'uploader': 'B.C. & Lowy',
|
||||||
@ -86,29 +86,9 @@ class XuiteIE(InfoExtractor):
|
|||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def base64_decode_utf8(data):
|
|
||||||
return base64.b64decode(data.encode('utf-8')).decode('utf-8')
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def base64_encode_utf8(data):
|
|
||||||
return base64.b64encode(data.encode('utf-8')).decode('utf-8')
|
|
||||||
|
|
||||||
def _extract_flv_config(self, encoded_media_id):
|
|
||||||
flv_config = self._download_xml(
|
|
||||||
'http://vlog.xuite.net/flash/player?media=%s' % encoded_media_id,
|
|
||||||
'flv config')
|
|
||||||
prop_dict = {}
|
|
||||||
for prop in flv_config.findall('./property'):
|
|
||||||
prop_id = self.base64_decode_utf8(prop.attrib['id'])
|
|
||||||
# CDATA may be empty in flv config
|
|
||||||
if not prop.text:
|
|
||||||
continue
|
|
||||||
encoded_content = self.base64_decode_utf8(prop.text)
|
|
||||||
prop_dict[prop_id] = compat_urllib_parse_unquote(encoded_content)
|
|
||||||
return prop_dict
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
# /play/ URLs provide embedded video URL and more metadata
|
||||||
|
url = url.replace('/embed/', '/play/')
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
@ -121,51 +101,53 @@ class XuiteIE(InfoExtractor):
|
|||||||
'%s returned error: %s' % (self.IE_NAME, error_msg),
|
'%s returned error: %s' % (self.IE_NAME, error_msg),
|
||||||
expected=True)
|
expected=True)
|
||||||
|
|
||||||
encoded_media_id = self._search_regex(
|
media_info = self._parse_json(self._search_regex(
|
||||||
r'attributes\.name\s*=\s*"([^"]+)"', webpage,
|
r'var\s+mediaInfo\s*=\s*({.*});', webpage, 'media info'), video_id)
|
||||||
'encoded media id', default=None)
|
|
||||||
if encoded_media_id is None:
|
|
||||||
video_id = self._html_search_regex(
|
|
||||||
r'data-mediaid="(\d+)"', webpage, 'media id')
|
|
||||||
encoded_media_id = self.base64_encode_utf8(video_id)
|
|
||||||
flv_config = self._extract_flv_config(encoded_media_id)
|
|
||||||
|
|
||||||
FORMATS = {
|
video_id = media_info['MEDIA_ID']
|
||||||
'audio': 'mp3',
|
|
||||||
'video': 'mp4',
|
|
||||||
}
|
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for format_tag in ('src', 'hq_src'):
|
for key in ('html5Url', 'html5HQUrl'):
|
||||||
video_url = flv_config.get(format_tag)
|
video_url = media_info.get(key)
|
||||||
if not video_url:
|
if not video_url:
|
||||||
continue
|
continue
|
||||||
format_id = self._search_regex(
|
format_id = self._search_regex(
|
||||||
r'\bq=(.+?)\b', video_url, 'format id', default=format_tag)
|
r'\bq=(.+?)\b', video_url, 'format id', default=None)
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'ext': FORMATS.get(flv_config['type'], 'mp4'),
|
'ext': 'mp4' if format_id.isnumeric() else format_id,
|
||||||
'format_id': format_id,
|
'format_id': format_id,
|
||||||
'height': int(format_id) if format_id.isnumeric() else None,
|
'height': int(format_id) if format_id.isnumeric() else None,
|
||||||
})
|
})
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
timestamp = flv_config.get('publish_datetime')
|
timestamp = media_info.get('PUBLISH_DATETIME')
|
||||||
if timestamp:
|
if timestamp:
|
||||||
timestamp = parse_iso8601(timestamp + ' +0800', ' ')
|
timestamp = parse_iso8601(timestamp + ' +0800', ' ')
|
||||||
|
|
||||||
category = flv_config.get('category')
|
category = media_info.get('catName')
|
||||||
categories = [category] if category else []
|
categories = [category] if category else []
|
||||||
|
|
||||||
|
uploader = media_info.get('NICKNAME')
|
||||||
|
uploader_url = None
|
||||||
|
|
||||||
|
author_div = get_element_by_attribute('itemprop', 'author', webpage)
|
||||||
|
if author_div:
|
||||||
|
uploader = uploader or self._html_search_meta('name', author_div)
|
||||||
|
uploader_url = self._html_search_regex(
|
||||||
|
r'<link[^>]+itemprop="url"[^>]+href="([^"]+)"', author_div,
|
||||||
|
'uploader URL', fatal=False)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': flv_config['title'],
|
'title': media_info['TITLE'],
|
||||||
'description': flv_config.get('description'),
|
'description': remove_end(media_info.get('metaDesc'), ' (Xuite 影音)'),
|
||||||
'thumbnail': flv_config.get('thumb'),
|
'thumbnail': media_info.get('ogImageUrl'),
|
||||||
'timestamp': timestamp,
|
'timestamp': timestamp,
|
||||||
'uploader': flv_config.get('author_name'),
|
'uploader': uploader,
|
||||||
'uploader_id': flv_config.get('author_id'),
|
'uploader_id': media_info.get('MEMBER_ID'),
|
||||||
'duration': parse_duration(flv_config.get('duration')),
|
'uploader_url': uploader_url,
|
||||||
|
'duration': float_or_none(media_info.get('MEDIA_DURATION'), 1000000),
|
||||||
'categories': categories,
|
'categories': categories,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
@ -365,9 +365,9 @@ def get_elements_by_attribute(attribute, value, html, escape_value=True):
|
|||||||
retlist = []
|
retlist = []
|
||||||
for m in re.finditer(r'''(?xs)
|
for m in re.finditer(r'''(?xs)
|
||||||
<([a-zA-Z0-9:._-]+)
|
<([a-zA-Z0-9:._-]+)
|
||||||
(?:\s+[a-zA-Z0-9:._-]+(?:=[a-zA-Z0-9:._-]*|="[^"]*"|='[^']*'))*?
|
(?:\s+[a-zA-Z0-9:._-]+(?:=[a-zA-Z0-9:._-]*|="[^"]*"|='[^']*'|))*?
|
||||||
\s+%s=['"]?%s['"]?
|
\s+%s=['"]?%s['"]?
|
||||||
(?:\s+[a-zA-Z0-9:._-]+(?:=[a-zA-Z0-9:._-]*|="[^"]*"|='[^']*'))*?
|
(?:\s+[a-zA-Z0-9:._-]+(?:=[a-zA-Z0-9:._-]*|="[^"]*"|='[^']*'|))*?
|
||||||
\s*>
|
\s*>
|
||||||
(?P<content>.*?)
|
(?P<content>.*?)
|
||||||
</\1>
|
</\1>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user