mirror of
https://github.com/soimort/you-get.git
synced 2025-02-11 12:42:29 +03:00
youku download bug fix
This commit is contained in:
parent
370b183d81
commit
f04f4b4056
@ -79,6 +79,7 @@ SITES = {
|
||||
}
|
||||
|
||||
import getopt
|
||||
import http
|
||||
import json
|
||||
import locale
|
||||
import os
|
||||
@ -231,15 +232,24 @@ def undeflate(data):
|
||||
decompressobj = zlib.decompressobj(-zlib.MAX_WBITS)
|
||||
return decompressobj.decompress(data)+decompressobj.flush()
|
||||
|
||||
# DEPRECATED in favor of get_content()
|
||||
def get_response(url, faker = False):
|
||||
# install cookies
|
||||
if cookies:
|
||||
opener = request.build_opener(request.HTTPCookieProcessor(cookies))
|
||||
request.install_opener(opener)
|
||||
cj = http.cookiejar.CookieJar()
|
||||
def getOpener(head):
|
||||
pro = request.HTTPCookieProcessor(cj)
|
||||
opener = request.build_opener(pro)
|
||||
header = []
|
||||
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:
|
||||
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:
|
||||
response = request.urlopen(url)
|
||||
|
||||
@ -252,8 +262,8 @@ def get_response(url, faker = False):
|
||||
return response
|
||||
|
||||
# DEPRECATED in favor of get_content()
|
||||
def get_html(url, encoding = None, faker = False):
|
||||
content = get_response(url, faker).data
|
||||
def get_html(url, encoding = None, faker = False, youku_url=None):
|
||||
content = get_response(url, faker, youku_url).data
|
||||
return str(content, 'utf-8', 'ignore')
|
||||
|
||||
# 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
|
||||
try:
|
||||
meta = json.loads(get_html(api_url))
|
||||
meta = json.loads(get_html(api_url, faker=True, youku_url=self.url))
|
||||
data = meta['data']
|
||||
assert 'stream' in data
|
||||
except:
|
||||
@ -184,7 +184,7 @@ class Youku(VideoExtractor):
|
||||
if self.password_protected:
|
||||
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)
|
||||
if not self.streams[stream_id]['src'] and self.password_protected:
|
||||
|
Loading…
Reference in New Issue
Block a user