diff --git a/src/you_get/extractors/youku.py b/src/you_get/extractors/youku.py index f67fdc39..e0072e76 100644 --- a/src/you_get/extractors/youku.py +++ b/src/you_get/extractors/youku.py @@ -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)