2023-12-11 10:31:07 +00:00
|
|
|
# 使用示例
|
|
|
|
|
2023-12-06 04:35:16 +00:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
from pprint import pprint
|
|
|
|
import dotenv
|
|
|
|
|
2023-12-14 09:50:37 +00:00
|
|
|
from package.NeteaseCloudMusic import NeteaseCloudMusicApi, api_help, api_list
|
|
|
|
|
|
|
|
# from NeteaseCloudMusic import NeteaseCloudMusicApi, api_help, api_list
|
2023-12-06 04:35:16 +00:00
|
|
|
|
2023-12-06 08:01:28 +00:00
|
|
|
dotenv.load_dotenv() # 从.env文件中加载环境变量
|
2023-12-06 04:35:16 +00:00
|
|
|
|
2023-12-06 08:01:28 +00:00
|
|
|
netease_cloud_music_api = NeteaseCloudMusicApi() # 初始化API
|
2023-12-15 07:55:04 +00:00
|
|
|
# netease_cloud_music_api.cookie = os.getenv("COOKIE") # 设置cookie
|
2023-12-06 08:01:28 +00:00
|
|
|
netease_cloud_music_api.DEBUG = True # 开启调试模式
|
2023-12-06 04:35:16 +00:00
|
|
|
|
|
|
|
|
2023-12-14 09:50:37 +00:00
|
|
|
def song_url_v1_test():
|
2023-12-06 04:35:16 +00:00
|
|
|
# 获取歌曲详情
|
2023-12-11 10:31:07 +00:00
|
|
|
response = netease_cloud_music_api.request("song_url_v1", {"id": 33894312, "level": "exhigh"})
|
|
|
|
pprint(response)
|
2023-12-06 04:35:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
def search_test():
|
|
|
|
# 搜索
|
2023-12-11 10:31:07 +00:00
|
|
|
response = netease_cloud_music_api.request("search", {"keywords": "海阔天空"})
|
2023-12-06 08:01:28 +00:00
|
|
|
# print("|", response.text, "|")
|
2023-12-11 10:31:07 +00:00
|
|
|
pprint(response)
|
2023-12-06 04:35:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
def search_default_test():
|
|
|
|
# 搜索
|
2023-12-11 10:31:07 +00:00
|
|
|
response = netease_cloud_music_api.request("search_default")
|
|
|
|
pprint(response)
|
2023-12-06 04:35:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
def user_account_test():
|
|
|
|
# 获取用户账号信息
|
2023-12-11 10:31:07 +00:00
|
|
|
response = netease_cloud_music_api.request("user_account")
|
|
|
|
pprint(response)
|
2023-12-06 08:01:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
def comment_new_test():
|
2023-12-11 10:31:07 +00:00
|
|
|
response = netease_cloud_music_api.request("comment_new", {
|
2023-12-06 08:01:28 +00:00
|
|
|
"type": "0",
|
|
|
|
"id": "1407551413",
|
|
|
|
"sortType": 3,
|
|
|
|
"cursor": 1602072870260,
|
|
|
|
"pageSize": 20,
|
|
|
|
"pageNo": 2,
|
|
|
|
"realIP": "116.25.146.177",
|
|
|
|
})
|
2023-12-11 10:31:07 +00:00
|
|
|
pprint(response)
|
|
|
|
|
|
|
|
|
|
|
|
def toplist_detail_test():
|
|
|
|
# 获取用户账号信息
|
|
|
|
response = netease_cloud_music_api.request("toplist_detail")
|
|
|
|
pprint(response)
|
|
|
|
|
|
|
|
|
|
|
|
def playlist_detail_test():
|
|
|
|
# 获取用户账号信息
|
|
|
|
response = netease_cloud_music_api.request("playlist_detail", {"id": 19723756})
|
|
|
|
pprint(response)
|
|
|
|
|
|
|
|
|
|
|
|
def top_playlist_highquality_test():
|
|
|
|
response = netease_cloud_music_api.request("/top/playlist/highquality")
|
|
|
|
pprint(response)
|
|
|
|
|
|
|
|
|
|
|
|
def captcha_sent_test():
|
2023-12-15 07:55:04 +00:00
|
|
|
response = netease_cloud_music_api.request("/captcha/sent", {"phone": "15229954305"})
|
2023-12-11 10:31:07 +00:00
|
|
|
pprint(response)
|
|
|
|
|
|
|
|
|
|
|
|
def login_cellphone_test():
|
2023-12-15 07:55:04 +00:00
|
|
|
response = netease_cloud_music_api.request("/login/cellphone",{"phone": "15229954305", "captcha": "4273"})
|
|
|
|
pprint(response)
|
2023-12-06 04:35:16 +00:00
|
|
|
|
|
|
|
|
2023-12-14 09:50:37 +00:00
|
|
|
def personalized_djprogram_test():
|
|
|
|
response = netease_cloud_music_api.request("personalized_djprogram")
|
|
|
|
pprint(response)
|
|
|
|
|
|
|
|
|
|
|
|
def top_mv_test():
|
|
|
|
response = netease_cloud_music_api.request("top_mv", {'limit': 6})
|
|
|
|
pprint(response)
|
|
|
|
|
|
|
|
|
2023-12-06 04:35:16 +00:00
|
|
|
if __name__ == '__main__':
|
2023-12-06 08:01:28 +00:00
|
|
|
pass
|
2023-12-14 09:50:37 +00:00
|
|
|
# print(api_list())
|
|
|
|
# print(api_help())
|
|
|
|
# song_url_v1_test()
|
2023-12-15 07:55:04 +00:00
|
|
|
# top_mv_test()
|
2023-12-06 04:35:16 +00:00
|
|
|
# search_test()
|
|
|
|
# search_default_test()
|
2023-12-06 08:01:28 +00:00
|
|
|
# user_account_test()
|
|
|
|
# comment_new_test()
|
2023-12-11 10:31:07 +00:00
|
|
|
# toplist_detail_test()
|
|
|
|
# playlist_detail_test()
|
|
|
|
# top_playlist_highquality_test()
|
|
|
|
# captcha_sent_test()
|
2023-12-15 07:55:04 +00:00
|
|
|
login_cellphone_test()
|