A kuwo music python API.
Project description
MusicKuwo
酷我音乐的 Python 接口。
可使用 Pip install MusicKuwo 来安装本模块。
功能
- 搜索音乐和歌手;
- 下载音乐以及对应的歌词;
- 其他功能。
使用
本模块有内置示例,可直接使用。
基于 MusicKuwo
模块的简易歌曲下载器:示例源代码
from MusicKuwo.Domes import MusicDownload
if __name__ == '__main__':
MusicDownload()
文档
使用 import MusicKuwo 来引入此模块。
注:此文档为 1.0.0 版本,与旧版并不兼容。
MusicKuwo.Core.SearchHints
函数构造:SearchHints( Word: str ) -> list[str, ...]
此函数获取搜索提示词。
- 参数
Word为传入词语的提示词,此参数可为空。
返回值为列表,列表里的元素均为字符串,获取失败返回 None 值。
MusicKuwo.Core.SearchMusic
函数构造:SearchMusic( Word: str, PageNumber: int, Page: int ) -> list[Music, ...]
此函数获取搜索音乐的结果。
- 参数
Word为搜索音乐的名称,此参数不能为空。 - 参数
PageNumber为搜索的每页数量,默认值为 30 。 - 参数
Page为页面页数值,默认值为 1 。
返回值为列表,列表里的元素均为本模块的 MusicKuwo.Objects.Music 对象,列表长度取决于参数 PageNumber 。获取失败返回 None。
MusicKuwo.Core.SearchArtist
函数构造:SearchArtist( Word: str, PageNumber: int, Page: int ) -> list[Artist, ...]
此函数获取搜索歌手的结果。
- 参数
Word为搜歌手的名字,此参数不能为空。 - 参数
PageNumber为搜索的每页数量,默认值为 10 。 - 参数
Page为页面页数值,默认值为 1 。
反回值为列表,列表里的元素均为本模块的 MusicKuwo.Objects.Artist 对象,列表长度取决于参数 PageNumber 。获取失败返回 None。
MusicKuwo.Uitls.DownloadFile
函数构造:DownloadFile( Url: str, Path: str, ChuckSize: int ) -> bool
此函数从网络上下载文件到本地。
- 参数
Url为要下载的内容链接,此参数不能为空。 - 参数
Path为你要下载的文件路径,不可为空。 - 参数
ChuckSize为一次写入到文件里的字节区块大小,默认值为 2500 。
返回结果为 True 或者 None ,其中 True 代表下载成功,而 None 则代表下载失败。你可以很方便的用代码判断文件下载是否成功:
from MusicKuwo.Uitls import DownloadFile
DownloadFlag = DownloadFile('https://h5static.kuwo.cn/www/kw-www/img/logo.7bf8751.png', './KuwoIcon.png')
if DownloadFlag:
print('下载成功!')
else:
print('下载失败!')
此代码将下载一个酷我音乐的标徽在本地,如下载成功将会打印 下载成功! 在控制台,反之则打印 下载失败! 。
MusicKuwo.Objects.Music
Download
函数构造:Download( self, Path: str )
此函数下载歌曲到本地。
- 参数
Path为歌曲下载到本地的路径。
返回值和 KuwoMusic.Uitls.DownloadFile 的返回值同理。
DownloadLyrics
函数构造:DownloadLyrics( self, Path: str, Encoding: str )
此函数把歌词文件下载到本地。
- 参数
Path为歌词下载到本地的路径。 - 参数
Encoding为下载的歌词文件的编码,默认为Gbk编码。
返回值和 KuwoMusic.Uitls.DownloadFile 的返回值同理。
MusicKuwo.Objects.Artist
初始函数
函数构造:__init__( self, Code: int )
- 参数
Code为歌手编码,编码请参考文档最后,可为空。
LoadMore
函数构造:LoadMore( self, Code: int )
此函数来加载更多的歌手信息,如所属国家和生日等。
- 参数
Code为歌手编码,编码请参考文档最后,可为空,一般不填。
返回值为 True 或 None,返回 True 时代表加载成功,反之加载失败。
编码
编码为酷我音乐给歌手或歌曲等等的 Id ,在此模块统称为 Code 。
编码为数值,如歌曲《 海市蜃楼 》的网址为 https://kuwo.cn/play_detail/201737980 则此歌曲的 Code
就为 201737980;
歌手三叔说的网址为 https://kuwo.cn/singer_detail/4477027,则 Code
为 4477027 。
有些对象的 Code 无法通过网址获取,如评论等。
在实际应用中很少用到,了解和不了解并没有太大区别。
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file MusicKuwo-1.0.0.tar.gz.
File metadata
- Download URL: MusicKuwo-1.0.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d88d056d435520b42f96e69f22cee9681eaa142d7dc7e90e8e57f65650bdfd1
|
|
| MD5 |
e8359b6c6af2288c9d593727664dccaf
|
|
| BLAKE2b-256 |
5cbead5c2a65ae623e85d74f01f817ec19ca32448cc68f1aeb06b65db49bfdd2
|
File details
Details for the file MusicKuwo-1.0.0-py3-none-any.whl.
File metadata
- Download URL: MusicKuwo-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d2f28c0445e5e27f82d1faca8c3824e6deef94bc557753a60eeaf3f0a1f44be
|
|
| MD5 |
a8e1ee8e29ba1bda80894c1346d9c543
|
|
| BLAKE2b-256 |
b5802c81372f140db7e8f4bcc5035bf56c848155bcc6fab13a721b9d18021a1b
|