Skip to content

Commit

Permalink
Youku: support password-protected videos, fix #73
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed Jul 30, 2014
1 parent 18ff097 commit 95e9b87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/you_get/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self, *args):
self.streams = {}
self.streams_sorted = []
self.audiolang = None
self.password_protected = False

if args:
self.url = args[0]
Expand Down
15 changes: 13 additions & 2 deletions src/you_get/extractors/youku.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def prepare(self, **kwargs):
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']

Expand Down Expand Up @@ -100,8 +103,16 @@ def extract(self, **kwargs):
stream_id = self.streams_sorted[0]['id']

m3u8_url = "http://v.youku.com/player/getM3U8/vid/{vid}/type/{stream_id}/video.m3u8".format(vid=self.vid, stream_id=stream_id)
m3u8 = get_html(m3u8_url)
if m3u8:

if not kwargs['info_only']:
if self.password_protected:
password = input(log.sprint('Password: ', log.YELLOW))
m3u8_url += '?password={}'.format(password)

m3u8 = get_html(m3u8_url)
if not m3u8 and self.password_protected:
log.wtf('[Failed] Wrong password.')

self.streams[stream_id]['src'] = __class__.parse_m3u8(m3u8)

site = Youku()
Expand Down

0 comments on commit 95e9b87

Please sign in to comment.