示例#1
0
def login():
    def save():
        with open(SESSION_DUMP_FILENAME, 'w+') as f:
            f.write(pyncm.DumpSessionAsString(GetCurrentSession()))
        return True

    def load():
        if not isfile(SESSION_DUMP_FILENAME): return False
        with open(SESSION_DUMP_FILENAME) as f:
            pyncm.SetCurrentSession(LoadSessionFromString(f.read()))
        return pyncm.GetCurrentSession().login_info['success']

    print('需要登陆')
    if load():
        try:
            return input('按回车使用保存的账户 %s ,或 Ctrl + C 输入新令牌>>>' %
                         pyncm.GetCurrentSession().login_info['content']
                         ['profile']['nickname']) or True
        except KeyboardInterrupt:
            pass
    phone = input('手机号 >>>')
    passw = getpass.getpass('密码 >')
    pyncm.login.LoginViaCellphone(phone, passw)
    print(
        pyncm.GetCurrentSession().login_info['content']['profile']['nickname'],
        '登陆成功')
    return save()
示例#2
0
def login(session_file):
    def save():
        with open(session_file,'w+') as f:
            f.write(pyncm.DumpSessionAsString(GetCurrentSession()))
        return True
    def load():
        if not os.path.isfile(session_file):return False
        with open(session_file) as f:
            pyncm.SetCurrentSession(LoadSessionFromString(f.read()))
        return pyncm.GetCurrentSession().login_info['success']    
    if load():
        return print('[-] Recovered session data of [ %s ]' % pyncm.GetCurrentSession().login_info['content']['profile']['nickname']) or True
    phone = input('Phone >>>')
    passw = getpass.getpass('Password >')
    pyncm.login.LoginViaCellphone(phone,passw)
    print('[+]',pyncm.GetCurrentSession().login_info['content']['profile']['nickname'],'has logged in')
    return save()
示例#3
0
def login(session_file=SESSION_FILE, phone='', password=''):
    def save():
        with open(session_file, 'w+') as f:
            f.write(pyncm.DumpSessionAsString(GetCurrentSession()))
        return True

    def load():
        if not os.path.isfile(session_file): return False
        with open(session_file) as f:
            pyncm.SetCurrentSession(LoadSessionFromString(f.read()))
        return pyncm.GetCurrentSession().login_info['success']

    if not (phone and password) and load():
        return logging.info('Serving as %s' % pyncm.GetCurrentSession(
        ).login_info['content']['profile']['nickname']) or True
    if not (phone and password):
        return logging.warning(
            'Insufficient credentials, app will now run in guest mode') or True
    pyncm.apis.login.LoginViaCellphone(phone, password)
    logging.info(
        '%s has logged in' %
        pyncm.GetCurrentSession().login_info['content']['profile']['nickname'])
    return save()
示例#4
0
def upload_one(path):
    fname = os.path.basename(path)
    fext = path.split('.')[-1]
    '''Parsing file names'''
    fsize = os.stat(path).st_size
    md5 = md5sum(path).hexdigest()
    print('[-] Checking file ( MD5:', md5, ')')
    cresult = pyncm.cloud.GetCheckCloudUpload(md5)
    songId = cresult['songId']
    '''网盘资源发布 4 步走:
    1.拿到上传令牌 - 需要文件名,MD5,文件大小'''
    token = pyncm.cloud.GetNosToken(fname, md5, fsize, fext)['result']
    if cresult['needUpload']:
        print('[+] %s needs to be uploaded ( %s B )' % (fname, fsize))
        '''2. 若文件未曾上传完毕,则完成其上传'''
        upload_result = pyncm.cloud.SetUploadObject(open(path, 'rb'), md5,
                                                    fsize, token['objectKey'],
                                                    token['token'])
        print('[-] Response:\n  ', upload_result)
    print(f'''[!] Assuming upload has finished,preparing to submit    
    ID  :   {songId}
    MD5 :   {md5}
    NAME:   {fname}''')
    submit_result = pyncm.cloud.SetUploadCloudInfo(
        token['resourceId'],
        songId,
        md5,
        fname,
        fname,
        pyncm.GetCurrentSession().login_info['content']['profile']['nickname'],
        bitrate=1000)
    '''3. 提交资源'''
    print('[-] Response:\n  ', submit_result)
    '''4. 发布资源'''
    publish_result = pyncm.cloud.SetPublishCloudResource(
        submit_result['songId'])
    print('[-] Response:\n  ', publish_result)
示例#5
0
 def load():
     if not isfile(SESSION_DUMP_FILENAME): return False
     with open(SESSION_DUMP_FILENAME) as f:
         pyncm.SetCurrentSession(LoadSessionFromString(f.read()))
     return pyncm.GetCurrentSession().login_info['success']
示例#6
0
 def load():
     if not os.path.isfile(session_file):return False
     with open(session_file) as f:
         pyncm.SetCurrentSession(LoadSessionFromString(f.read()))
     return pyncm.GetCurrentSession().login_info['success']    
示例#7
0
            yield ''.join(s)


dot = dot_thingy()

uuid = pyncm.login.LoginQrcodeUnikey()['unikey']
url = f'https://music.163.com/login?codekey={uuid}'
img = qrcode.make(url)  # dimesion will always be 490,490
font = ImageFont.truetype('simhei.ttf', 20)  # 黑体
canvas = ImageDraw.Draw(img)
canvas.text((10, 10), '网易云音乐APP->侧边栏->下滑->扫描二维码√', font=font)
canvas.text((7, 430), '请时刻注意终端输出,扫描完毕后可关闭本对话框', font=font)
img.show(
)  # though tkinter was too expensive to use so here's my repalcement (((
print('[-] 二维码 UUID:', uuid)
while True:
    rsp = pyncm.login.LoginQrcodeCheck(uuid)
    if rsp['code'] == 803 or rsp['code'] == 800: break
    message = f"[!] {rsp['code']} -- {rsp['message']}"
    print(message, next(dot), end='\r')
    time.sleep(1)
WriteLoginInfo(GetCurrentLoginStatus())
print('[+] 登录成功。欢迎,%s (上一次登录 IP: %s)...尝试签到' % (
    pyncm.GetCurrentSession().login_info['content']['profile']['nickname'],
    pyncm.GetCurrentSession().login_info['content']['profile']['lastLoginIP']))

r = pyncm.user.SetSignin(pyncm.user.SIGNIN_TYPE_MOBILE)
if r['code'] == 200:
    print('[+] 签到完成 - EXP +%d' % r['point'])
else:
    print('[+] 无法签到 - %s' % r['msg'])
示例#8
0
def myfm():
    not pyncm.GetCurrentSession().login_info['success'] and login()
    return pyncm.miniprograms.radio.GetMoreRaidoContent()
示例#9
0
def patchPyncm():
    pyncm.GetCurrentSession().headers['X-Real-IP'] = '118.88.88.88'