fixed kugou download failure

This commit is contained in:
swansun 2019-05-22 14:31:47 +08:00
parent fc10ea1d06
commit 2578958692
3 changed files with 8 additions and 1 deletions

View File

@ -144,6 +144,7 @@ fake_headers = {
'Accept-Charset': 'UTF-8,*;q=0.5',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'en-US,en;q=0.8',
'Cookie': 'kg_mid=6b51749a6a9be5b85f19623d46ea8c0b;',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Firefox/60.0', # noqa
}

View File

@ -33,7 +33,7 @@ def kugou_download_by_hash(url,output_dir = '.', merge = True, info_only = False
#url_sample:http://www.kugou.com/song/#hash=93F7D2FC6E95424739448218B591AEAF&album_id=9019462
hash_val = match1(url,'hash=(\w+)')
album_id = match1(url,'album_id=(\d+)')
html = get_html("http://www.kugou.com/yy/index.php?r=play/getdata&hash={}&album_id={}".format(hash_val,album_id))
html = get_html("http://www.kugou.com/yy/index.php?r=play/getdata&hash={}&album_id={}".format(hash_val,album_id), None, True)
j =loads(html)
url = j['data']['play_url']
title = j['data']['audio_name']

View File

@ -8,6 +8,7 @@ from you_get.extractors import (
youtube,
bilibili,
toutiao,
kugou,
)
@ -31,6 +32,11 @@ class YouGetTests(unittest.TestCase):
'http://www.youtube.com/attribution_link?u=/watch?v%3DldAKIzq7bvs%26feature%3Dshare', # noqa
info_only=True
)
def test_kugou(self):
kugou.download(
'http://www.kugou.com/song/#hash=7841D696F28B57B3BA91CB23BC080A24&album_id=566329', # noqa
info_only=True
)
if __name__ == '__main__':