mirror of
https://github.com/soimort/you-get.git
synced 2025-02-11 20:52:31 +03:00
youku:support password option and fix small size video bug
This commit is contained in:
parent
1f01898184
commit
10053e25b6
@ -90,7 +90,7 @@ class Youku(VideoExtractor):
|
||||
|
||||
|
||||
e_code = trans_e(f_code_1, base64.b64decode(bytes(ep, 'ascii')))
|
||||
|
||||
|
||||
sid, token = e_code.split('_')
|
||||
fileId0 = getFileId(streamfileids, seed)
|
||||
|
||||
@ -120,10 +120,10 @@ class Youku(VideoExtractor):
|
||||
|
||||
f_code_2 = 'bf7e5f01'
|
||||
|
||||
number = hex(int(no,10))[2:].upper()
|
||||
number = hex(int(str(no),10))[2:].upper()
|
||||
if len(number) == 1:
|
||||
number = '0' + number
|
||||
fileId = fileId0[0:8] + number + fileId0[10:]
|
||||
fileId = fileId0[0:8] + number + fileId0[10:]
|
||||
|
||||
ep = urllib.parse.quote(base64.b64encode(''.join(trans_e(f_code_2,sid+'_'+fileId+'_'+token)).encode('latin1')),safe='~()*!.\'')
|
||||
return fileId,ep
|
||||
@ -173,13 +173,20 @@ class Youku(VideoExtractor):
|
||||
log.wtf('[Failed] Video not found.')
|
||||
metadata0 = meta['data'][0]
|
||||
|
||||
if 'error_code' in metadata0 and metadata0['error_code']:
|
||||
if metadata0['error_code'] == -6:
|
||||
log.w('[Warning] This video is password protected.')
|
||||
self.password_protected = True
|
||||
password = input(log.sprint('Password: ', log.YELLOW))
|
||||
meta = json.loads(get_html('http://v.youku.com/player/getPlayList/VideoIDS/%s/Pf/4/ctype/12/ev/1/password/' % self.vid + password))
|
||||
if not meta['data']:
|
||||
log.wtf('[Failed] Video not found.')
|
||||
metadata0 = meta['data'][0]
|
||||
|
||||
if 'error_code' in metadata0 and metadata0['error_code']:
|
||||
if metadata0['error_code'] == -8:
|
||||
log.w('[Warning] This video can only be streamed within Mainland China!')
|
||||
log.w('Use \'-y\' to specify a proxy server for extracting stream data.\n')
|
||||
elif metadata0['error_code'] == -6:
|
||||
log.w('[Warning] This video is password protected.')
|
||||
self.password_protected = True
|
||||
|
||||
self.title = metadata0['title']
|
||||
self.metadata = metadata0
|
||||
@ -227,6 +234,9 @@ class Youku(VideoExtractor):
|
||||
stream_list=self.metadata['segs'][stream_id]
|
||||
for nu in range(0,len(stream_list)):
|
||||
k = stream_list[nu]['k']
|
||||
if k == -1:
|
||||
log.e('Error')
|
||||
exit()
|
||||
no = stream_list[nu]['no']
|
||||
fileId,ep = self.__class__.generate_ep(no,fileId0,sid,token)
|
||||
#pdb.set_trace()
|
||||
@ -237,12 +247,8 @@ class Youku(VideoExtractor):
|
||||
m3u8+='&ctype=12&ev=1&token='+ token
|
||||
m3u8+='&oip='+ str(self.ip)
|
||||
m3u8+='&ep='+ ep+'\r\n'
|
||||
if not kwargs['info_only']:
|
||||
# if self.password_protected:
|
||||
# password = input(log.sprint('Password: ', log.YELLOW))
|
||||
# m3u8_url += '&password={}'.format(password)
|
||||
|
||||
#pdb.set_trace()
|
||||
if not kwargs['info_only']:
|
||||
self.streams[stream_id]['src'] = self.__class__.parse_m3u8(m3u8)
|
||||
if not self.streams[stream_id]['src'] and self.password_protected:
|
||||
log.e('[Failed] Wrong password.')
|
||||
|
Loading…
Reference in New Issue
Block a user