Skip to content

Commit

Permalink
[youku]cna hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
rosynirvana committed Jul 4, 2017
1 parent 1a37527 commit 525f052
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/you_get/extractors/youku.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ def fetch_cna():
if cookie.name == 'cna' and cookie.domain == '.youku.com':
log.i('Found cna in imported cookies. Use it')
return quote_cna(cookie.value)
url = 'http://gm.mmstat.com/yt/ykcomment.play.commentInit?cna='
url = 'http://log.mmstat.com/eg.js'
req = urllib.request.urlopen(url)
cna = req.info()['Set-Cookie'].split(';')[0].split('=')[1]
return quote_cna(cna)
headers = req.getheaders()
for header in headers:
if header[0].lower() == 'set-cookie':
n_v = header[1].split(';')[0]
name, value = n_v.split('=')
if name == 'cna':
return quote_cna(value)
log.w('It seems that the client failed to fetch a cna cookie. Please load your own cookie if possible')
return quote_cna('DOG4EdW4qzsCAbZyXbU+t7Jt')

def youku_ups(vid, ccode='0401'):
url = 'https://ups.youku.com/ups/get.json?vid={}&ccode={}'.format(vid, ccode)
Expand Down

0 comments on commit 525f052

Please sign in to comment.