Skip to main content

网易云weapi解码和封装。

Project description

from http.client import responses

netease_encode_api

网易云weapi解码和封装。

安装

  1. 请下载带有 pip 包安装器的 Python, 并将 Python 添加到 PATH。
  2. 打开命令行输入 pip install netease_encode_api
  3. 在 Python 代码内引用: from netease_encode_api import EncodeSession

使用

在 1.2.0+ 版本, EncodeSession 类已经成为了 requests.Session 的子类。 在不需要解码时, 请按照 request.Session 的使用方式正常使用。 在需要解码时, 请使用 EncodeSession.encoded_post(url, data)

预留了 EncodeSession.cmd_login(), 受不可抗力控制 (网易云好像最近抓第三方蛮狠的), 暂未实现, 请耐心等待。在此之前, 请先用 Cookies 填写的方式, 写入 MUSIC_U 字段登录。具体方式如下:

  1. 在网页版登录网易云音乐;
  2. 打开浏览器开发者工具, 切换到 Application (应用程序) 标签页;
  3. 找到 Cookies 一栏, 找到 MUSIC_U 字段, 复制其值;
  4. 在 Python 代码内, 调用 EncodeSession.set_cookie("MUSIC_U", "复制的值") 方法, 即可登录。

示例

from netease_encode_api import EncodeSession
es = EncodeSession()
# 加密获取歌曲下载链接
url = "https://music.163.com/weapi/song/enhance/player/url/v1"
data = {"ids":"[1462389992]",
        "level":"exhigh",
        "encodeType":"mp3"}
responses = es.encoded_post(url, data)
download_url = responses["data"][0]["url"]
download_responses = es.get(download_url)
with open(test.mp3, "wb") as f: f.write(download_responses.content)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netease_encode_api-1.2.1.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netease_encode_api-1.2.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file netease_encode_api-1.2.1.tar.gz.

File metadata

  • Download URL: netease_encode_api-1.2.1.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for netease_encode_api-1.2.1.tar.gz
Algorithm Hash digest
SHA256 6ba9153167dfcd11174ef19279b43d3e46433b7ed2b13722c7b055799e3853ec
MD5 2d1f6956f392cf18c19cd1713bd9d8d5
BLAKE2b-256 44f81da6f658e257d6388fbcb29ae3d9d226f5000df885d2b86d9d7c7837b9a0

See more details on using hashes here.

File details

Details for the file netease_encode_api-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for netease_encode_api-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 85de13fffbd5bcd53fb24fbd99b5ba875d17ff03f6f26f478e249bfa26bd0e63
MD5 f9ecd246aacb6d97a0b066140009bee1
BLAKE2b-256 0d1c383979c6b8141b1e7949d80bc9074c919fdca7c577917ebac31848a135a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page