python网易云音乐下载,可选择歌曲,下载路径

效果图

这里写图片描述

代码中用到了Crypto模块,Windows安装时会报错,① 建议选择对应解释器的版本搜索安装依赖.whl后缀的依赖包文件,找到之后直接pip install XXX.whl就可以了,在文章后面我提供了百度网盘连接,可以下载安装依赖、源码以及打包后的exe文件,我下载的是python3.6的依赖包,② window下安装pycryptodome模块也可以,pip install pycryptodome,但是由于这个模块暂时没有更新维护,安装了有时候无法使用,python3.6和python3.7已经亲测无法使用,③ Linux不需要考虑这个编译环境问题,可以直接安装Crypto即可

from copy import deepcopy

import requests, json, base64

from binascii import hexlify
from Crypto.Cipher import AES

from tkinter import *
from tkinter.filedialog import askdirectory
from urllib.request import urlretrieve
import os


class Encrypyed():
    '''传入歌曲的ID,加密生成'params'、'encSecKey 返回'''

    def __init__(self):
        self.pub_key = '010001'
        self.modulus = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7'
        self.nonce = '0CoJUm6Qyw8W8jud'

    def create_secret_key(self, size):
        return hexlify(os.urandom(size))[:16].decode('utf-8')

    def aes_encrypt(self, text, key):
        iv = '0102030405060708'
        pad = 16 - len(text) % 16
        text = text + pad * chr(pad)
        encryptor = AES.new(key, AES.MODE_CBC, iv)
        result = encryptor.encrypt(text)
        result_str = base64.b64encode(result).decode('utf-8')
        return result_str

    def rsa_encrpt(self, text, pubKey, modulus):
        text = text[::-1]
        rs = pow(int(hexlify(text.encode('utf-8')), 16), int(pubKey, 16), int(modulus, 16))
        return format(rs, 'x').zfill(256)

    def work(self, ids, br=128000):
        text = {
   'ids': [ids], 'br': br, 'csrf_token': ''}
        text = json.dumps(text)
        i = self.create_secret_key(16)
        encText = self.aes_encrypt(text, s
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值