diff --git a/src/you_get/extractors/ixigua.py b/src/you_get/extractors/ixigua.py index 151107a6..2f11e7f9 100644 --- a/src/you_get/extractors/ixigua.py +++ b/src/you_get/extractors/ixigua.py @@ -5,10 +5,10 @@ import binascii from ..common import * import random -import requests import string import ctypes from json import loads +from urllib import request __all__ = ['ixigua_download', 'ixigua_download_playlist_by_url'] @@ -82,8 +82,14 @@ def get_video_url_from_video_id(video_id): def ixigua_download(url, output_dir='.', merge=True, info_only=False, **kwargs): # example url: https://www.ixigua.com/i6631065141750268420/#mid=63024814422 - sess = requests.session() - html = sess.get(url, headers=headers).text + resp = urlopen_with_retry(request.Request(url)) + html = resp.read().decode('utf-8') + + _cookies = [] + for c in resp.getheader('Set-Cookie').split("httponly,"): + _cookies.append(c.strip().split(' ')[0]) + headers['cookie'] = ' '.join(_cookies) + conf = loads(match1(html, r"window\.config = (.+);")) if not conf: log.e("Get window.config from url failed, url: {}".format(url)) @@ -97,7 +103,7 @@ def ixigua_download(url, output_dir='.', merge=True, info_only=False, **kwargs): if ok != 'OK': log.e("Verify failed, verify_url: {}, result: {}".format(verify_url, ok)) return - html = sess.get(url, headers=headers).text + html = get_content(url, headers=headers) video_id = match1(html, r"\"vid\":\"([^\"]+)") title = match1(html, r"\"player__videoTitle\">.*?(.*)<\/h1><\/div>")