youku -- check with flake8
This commit is contained in:
parent
4ca8e3b5d9
commit
5533e594e8
@ -2,7 +2,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import json
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
@ -89,9 +88,6 @@ class YoukuIE(InfoExtractor):
|
|||||||
oip = data['security']['ip']
|
oip = data['security']['ip']
|
||||||
|
|
||||||
# get fileid
|
# get fileid
|
||||||
string_ls = list(
|
|
||||||
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\:._-1234567890')
|
|
||||||
|
|
||||||
fileid_dict = {}
|
fileid_dict = {}
|
||||||
for stream in data['stream']:
|
for stream in data['stream']:
|
||||||
format = stream.get('stream_type')
|
format = stream.get('stream_type')
|
||||||
@ -122,13 +118,12 @@ class YoukuIE(InfoExtractor):
|
|||||||
format = stream.get('stream_type')
|
format = stream.get('stream_type')
|
||||||
video_urls = []
|
video_urls = []
|
||||||
for dt in stream['segs']:
|
for dt in stream['segs']:
|
||||||
#n = str(int(dt['size']))
|
# n = str(int(dt['size']))
|
||||||
n = str(stream['segs'].index(dt))
|
n = str(stream['segs'].index(dt))
|
||||||
param = {
|
param = {
|
||||||
'K': dt['key'],
|
'K': dt['key'],
|
||||||
'hd': self.get_hd(format),
|
'hd': self.get_hd(format),
|
||||||
'myp': 0,
|
'myp': 0,
|
||||||
#'ts': dt['total_milliseconds_video'],
|
|
||||||
'ypp': 0,
|
'ypp': 0,
|
||||||
'ctype': 12,
|
'ctype': 12,
|
||||||
'ev': 1,
|
'ev': 1,
|
||||||
@ -139,7 +134,7 @@ class YoukuIE(InfoExtractor):
|
|||||||
video_url = \
|
video_url = \
|
||||||
'http://k.youku.com/player/getFlvPath/' + \
|
'http://k.youku.com/player/getFlvPath/' + \
|
||||||
'sid/' + sid + \
|
'sid/' + sid + \
|
||||||
'_00'+ \
|
'_00' + \
|
||||||
'/st/' + self.parse_ext_l(format) + \
|
'/st/' + self.parse_ext_l(format) + \
|
||||||
'/fileid/' + get_fileid(format, n) + '?' + \
|
'/fileid/' + get_fileid(format, n) + '?' + \
|
||||||
compat_urllib_parse.urlencode(param)
|
compat_urllib_parse.urlencode(param)
|
||||||
@ -198,24 +193,21 @@ class YoukuIE(InfoExtractor):
|
|||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
def retrieve_data(req_url, note):
|
def retrieve_data(req_url, note):
|
||||||
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'Referer': req_url,
|
'Referer': req_url,
|
||||||
}
|
}
|
||||||
self._set_cookie('youku.com','xreferrer','http://www.youku.com')
|
self._set_cookie('youku.com', 'xreferrer', 'http://www.youku.com')
|
||||||
req = sanitized_Request(req_url,headers=headers)
|
req = sanitized_Request(req_url, headers=headers)
|
||||||
|
|
||||||
cn_verification_proxy = self._downloader.params.get('cn_verification_proxy')
|
cn_verification_proxy = self._downloader.params.get('cn_verification_proxy')
|
||||||
if cn_verification_proxy:
|
if cn_verification_proxy:
|
||||||
req.add_header('Ytdl-request-proxy', cn_verification_proxy)
|
req.add_header('Ytdl-request-proxy', cn_verification_proxy)
|
||||||
|
|
||||||
raw_data = self._download_json(req, video_id, note=note)
|
raw_data = self._download_json(req, video_id, note=note)
|
||||||
js = json.dumps(raw_data)
|
|
||||||
|
|
||||||
return raw_data['data']
|
return raw_data['data']
|
||||||
|
|
||||||
|
|
||||||
video_password = self._downloader.params.get('videopassword', None)
|
video_password = self._downloader.params.get('videopassword', None)
|
||||||
|
|
||||||
# request basic data
|
# request basic data
|
||||||
@ -239,10 +231,9 @@ class YoukuIE(InfoExtractor):
|
|||||||
msg += ': ' + error_note
|
msg += ': ' + error_note
|
||||||
raise ExtractorError(msg)
|
raise ExtractorError(msg)
|
||||||
|
|
||||||
#get video title
|
# get video title
|
||||||
title = data['video']['title']
|
title = data['video']['title']
|
||||||
|
|
||||||
|
|
||||||
# generate video_urls_dict
|
# generate video_urls_dict
|
||||||
video_urls_dict = self.construct_video_urls(data)
|
video_urls_dict = self.construct_video_urls(data)
|
||||||
|
|
||||||
@ -263,17 +254,17 @@ class YoukuIE(InfoExtractor):
|
|||||||
'formats': [],
|
'formats': [],
|
||||||
# some formats are not available for all parts, we have to detect
|
# some formats are not available for all parts, we have to detect
|
||||||
# which one has all
|
# which one has all
|
||||||
} for i in range(min(seq))]
|
} for i in range(min(seq))]
|
||||||
stream = data['stream'][seq.index(min(seq))]
|
stream = data['stream'][seq.index(min(seq))]
|
||||||
fm = stream.get('stream_type')
|
fm = stream.get('stream_type')
|
||||||
video_urls = video_urls_dict[fm]
|
video_urls = video_urls_dict[fm]
|
||||||
for video_url, seg, entry in zip(video_urls, stream['segs'], entries):
|
for video_url, seg, entry in zip(video_urls, stream['segs'], entries):
|
||||||
entry['formats'].append({
|
entry['formats'].append({
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'format_id': self.get_format_name(fm),
|
'format_id': self.get_format_name(fm),
|
||||||
'ext': self.parse_ext_l(fm),
|
'ext': self.parse_ext_l(fm),
|
||||||
'filesize': int(seg['size']),
|
'filesize': int(seg['size']),
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'_type': 'multi_video',
|
'_type': 'multi_video',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user