mirror of
https://github.com/soimort/you-get.git
synced 2025-02-11 20:52:31 +03:00
youku download bug fix
This commit is contained in:
parent
370b183d81
commit
f04f4b4056
@ -79,6 +79,7 @@ SITES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
import getopt
|
import getopt
|
||||||
|
import http
|
||||||
import json
|
import json
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
@ -231,15 +232,24 @@ def undeflate(data):
|
|||||||
decompressobj = zlib.decompressobj(-zlib.MAX_WBITS)
|
decompressobj = zlib.decompressobj(-zlib.MAX_WBITS)
|
||||||
return decompressobj.decompress(data)+decompressobj.flush()
|
return decompressobj.decompress(data)+decompressobj.flush()
|
||||||
|
|
||||||
# DEPRECATED in favor of get_content()
|
cj = http.cookiejar.CookieJar()
|
||||||
def get_response(url, faker = False):
|
def getOpener(head):
|
||||||
# install cookies
|
pro = request.HTTPCookieProcessor(cj)
|
||||||
if cookies:
|
opener = request.build_opener(pro)
|
||||||
opener = request.build_opener(request.HTTPCookieProcessor(cookies))
|
header = []
|
||||||
request.install_opener(opener)
|
for key, value in head.items():
|
||||||
|
elem = (key, value)
|
||||||
|
header.append(elem)
|
||||||
|
opener.addheaders = header
|
||||||
|
return opener
|
||||||
|
|
||||||
|
# DEPRECATED in favor of get_content()
|
||||||
|
def get_response(url, faker = False, youku_url=None):
|
||||||
if faker:
|
if faker:
|
||||||
response = request.urlopen(request.Request(url, headers = fake_headers), None)
|
if youku_url:
|
||||||
|
fake_headers['Referer'] = youku_url
|
||||||
|
opener = getOpener(fake_headers)
|
||||||
|
response = opener.open(url)
|
||||||
else:
|
else:
|
||||||
response = request.urlopen(url)
|
response = request.urlopen(url)
|
||||||
|
|
||||||
@ -252,8 +262,8 @@ def get_response(url, faker = False):
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
# DEPRECATED in favor of get_content()
|
# DEPRECATED in favor of get_content()
|
||||||
def get_html(url, encoding = None, faker = False):
|
def get_html(url, encoding = None, faker = False, youku_url=None):
|
||||||
content = get_response(url, faker).data
|
content = get_response(url, faker, youku_url).data
|
||||||
return str(content, 'utf-8', 'ignore')
|
return str(content, 'utf-8', 'ignore')
|
||||||
|
|
||||||
# DEPRECATED in favor of get_content()
|
# DEPRECATED in favor of get_content()
|
||||||
|
@ -113,7 +113,7 @@ class Youku(VideoExtractor):
|
|||||||
|
|
||||||
api_url = 'http://play.youku.com/play/get.json?vid=%s&ct=12' % self.vid
|
api_url = 'http://play.youku.com/play/get.json?vid=%s&ct=12' % self.vid
|
||||||
try:
|
try:
|
||||||
meta = json.loads(get_html(api_url))
|
meta = json.loads(get_html(api_url, faker=True, youku_url=self.url))
|
||||||
data = meta['data']
|
data = meta['data']
|
||||||
assert 'stream' in data
|
assert 'stream' in data
|
||||||
except:
|
except:
|
||||||
@ -184,7 +184,7 @@ class Youku(VideoExtractor):
|
|||||||
if self.password_protected:
|
if self.password_protected:
|
||||||
m3u8_url += '&password={}'.format(self.password)
|
m3u8_url += '&password={}'.format(self.password)
|
||||||
|
|
||||||
m3u8 = get_html(m3u8_url)
|
m3u8 = get_html(m3u8_url, faker=True)
|
||||||
|
|
||||||
self.streams[stream_id]['src'] = self.__class__.parse_m3u8(m3u8)
|
self.streams[stream_id]['src'] = self.__class__.parse_m3u8(m3u8)
|
||||||
if not self.streams[stream_id]['src'] and self.password_protected:
|
if not self.streams[stream_id]['src'] and self.password_protected:
|
||||||
|
Loading…
Reference in New Issue
Block a user