darknessomi / musicbox

网易云音乐命令行版本
MIT License
9.79k stars 1.58k forks source link

460 cheating #745

Open yorks opened 5 years ago

yorks commented 5 years ago

解决方法见: https://github.com/Binaryify/NeteaseCloudMusicApi/commit/883d94580ed4aeeb5a4d30f9d311ffe3d3894b29#diff-3c2039f9ae0902bf44f24a0c1ad4eb32

nnnewb commented 4 years ago

用api.NetEase还是不能登录,提示cheating。这个bug是一直没修复吗?

这里是我的临时补丁。

import logging
import random
import arrow
from NEMbox.api import NetEase
from hashlib import md5

from homepage.config import config

BOX = NetEase()

_logger = logging.getLogger('netease')

def _timestamp():
    return int(arrow.now().float_timestamp)

def _random_jsession_id():
    seq = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKMNOPQRSTUVWXYZ\\/+'
    random_seq = random.choices(seq, k=176)
    return ''.join(random_seq) + ':' + str(_timestamp())

def _random_nuid(with_timestamp=True):
    seq = '0123456789abcdefghijklmnopqrstuvwxyz'
    random_seq = random.choices(seq, k=32)
    if with_timestamp:
        return ''.join(random_seq) + ',' + str(_timestamp())
    else:
        return ''.join(random_seq)

def _patch_negative_460_cheating_883d94580():
    # known issue: https://github.com/darknessomi/musicbox/issues/745
    # patch reference: https://github.com/Binaryify/NeteaseCloudMusicApi/commit/883d94580ed4aeeb5a4d30f9d311ffe3d3894b29#diff-3c2039f9ae0902bf44f24a0c1ad4eb32
    base_cookies = {
        'JSESSIONID-WYYY': _random_jsession_id(),
        '_iuqxldmzr_': '32',
        '_ntes_nnid': _random_nuid(),
        '_ntes_nuid': _random_nuid(with_timestamp=False)
    }
    for key, value in base_cookies.items():
        cookie = BOX.make_cookie(key, value)
        # known issue https://github.com/darknessomi/musicbox/issues/790
        cookie._rest = {}
        BOX.session.cookies.set_cookie(cookie)

处理两个问题:

790 AttributeError

以及这个issue -460 cheating

nnnewb commented 4 years ago

NetEase类的login api 设计也很奇怪,passwd参数必须是md5().hexdigest()但也没注释说明