Merge branch 'master' of github.com:rg3/youtube-dl into remitamine-ndr
This commit is contained in:
commit
d5867276a9
|
@ -2,14 +2,12 @@
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
|
||||||
import json
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import compat_str
|
||||||
|
|
||||||
|
|
||||||
class TudouIE(InfoExtractor):
|
class TudouIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?tudou\.com/(?:listplay|programs(?:/view)?|albumplay)/.*?/(?P<id>[^/?#]+?)(?:\.html)?/?(?:$|[?#])'
|
_VALID_URL = r'https?://(?:www\.)?tudou\.com/(?:listplay|programs(?:/view)?|albumplay)/([^/]+/)*(?P<id>[^/?#]+?)(?:\.html)?/?(?:$|[?#])'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.tudou.com/listplay/zzdE77v6Mmo/2xN2duXMxmw.html',
|
'url': 'http://www.tudou.com/listplay/zzdE77v6Mmo/2xN2duXMxmw.html',
|
||||||
'md5': '140a49ed444bd22f93330985d8475fcb',
|
'md5': '140a49ed444bd22f93330985d8475fcb',
|
||||||
|
@ -27,41 +25,41 @@ class TudouIE(InfoExtractor):
|
||||||
'title': 'La Sylphide-Bolshoi-Ekaterina Krysanova & Vyacheslav Lopatin 2012',
|
'title': 'La Sylphide-Bolshoi-Ekaterina Krysanova & Vyacheslav Lopatin 2012',
|
||||||
'thumbnail': 're:^https?://.*\.jpg$',
|
'thumbnail': 're:^https?://.*\.jpg$',
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
'url': 'http://www.tudou.com/albumplay/cJAHGih4yYg.html',
|
||||||
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
_PLAYER_URL = 'http://js.tudouui.com/bin/lingtong/PortalPlayer_177.swf'
|
_PLAYER_URL = 'http://js.tudouui.com/bin/lingtong/PortalPlayer_177.swf'
|
||||||
|
|
||||||
def _url_for_id(self, id, quality=None):
|
def _url_for_id(self, video_id, quality=None):
|
||||||
info_url = "http://v2.tudou.com/f?id=" + str(id)
|
info_url = 'http://v2.tudou.com/f?id=' + compat_str(video_id)
|
||||||
if quality:
|
if quality:
|
||||||
info_url += '&hd' + quality
|
info_url += '&hd' + quality
|
||||||
webpage = self._download_webpage(info_url, id, "Opening the info webpage")
|
xml_data = self._download_xml(info_url, video_id, "Opening the info XML page")
|
||||||
final_url = self._html_search_regex('>(.+?)</f>', webpage, 'video url')
|
final_url = xml_data.text
|
||||||
return final_url
|
return final_url
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
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)
|
||||||
|
|
||||||
m = re.search(r'vcode:\s*[\'"](.+?)[\'"]', webpage)
|
youku_vcode = self._search_regex(
|
||||||
if m and m.group(1):
|
r'vcode\s*:\s*[\'"]([^\'"]*)[\'"]', webpage, 'youku vcode', default=None)
|
||||||
return {
|
if youku_vcode:
|
||||||
'_type': 'url',
|
return self.url_result('youku:' + youku_vcode, ie='Youku')
|
||||||
'url': 'youku:' + m.group(1),
|
|
||||||
'ie_key': 'Youku'
|
|
||||||
}
|
|
||||||
|
|
||||||
title = self._search_regex(
|
title = self._search_regex(
|
||||||
r",kw:\s*['\"](.+?)[\"']", webpage, 'title')
|
r',kw\s*:\s*[\'"]([^\'"]+)[\'"]', webpage, 'title')
|
||||||
thumbnail_url = self._search_regex(
|
thumbnail_url = self._search_regex(
|
||||||
r",pic:\s*[\"'](.+?)[\"']", webpage, 'thumbnail URL', fatal=False)
|
r',pic\s*:\s*[\'"]([^\'"]+)[\'"]', webpage, 'thumbnail URL', fatal=False)
|
||||||
|
|
||||||
player_url = self._search_regex(
|
player_url = self._search_regex(
|
||||||
r"playerUrl\s*:\s*['\"](.+?\.swf)[\"']",
|
r'playerUrl\s*:\s*[\'"]([^\'"]+\.swf)[\'"]',
|
||||||
webpage, 'player URL', default=self._PLAYER_URL)
|
webpage, 'player URL', default=self._PLAYER_URL)
|
||||||
|
|
||||||
segs_json = self._search_regex(r'segs: \'(.*)\'', webpage, 'segments')
|
segments = self._parse_json(self._search_regex(
|
||||||
segments = json.loads(segs_json)
|
r'segs: \'([^\']+)\'', webpage, 'segments'), video_id)
|
||||||
# It looks like the keys are the arguments that have to be passed as
|
# It looks like the keys are the arguments that have to be passed as
|
||||||
# the hd field in the request url, we pick the higher
|
# the hd field in the request url, we pick the higher
|
||||||
# Also, filter non-number qualities (see issue #3643).
|
# Also, filter non-number qualities (see issue #3643).
|
||||||
|
|
Loading…
Reference in New Issue