2023-12-11 10:31:07 +00:00
|
|
|
# 使用示例
|
|
|
|
|
2023-12-06 04:35:16 +00:00
|
|
|
import json
|
|
|
|
import os
|
2023-12-19 14:33:19 +00:00
|
|
|
import time
|
|
|
|
from enum import Enum
|
2023-12-06 04:35:16 +00:00
|
|
|
from pprint import pprint
|
|
|
|
import dotenv
|
|
|
|
|
2023-12-30 18:26:19 +00:00
|
|
|
from package.NeteaseCloudMusic import NeteaseCloudMusicApi, api_help, api_list
|
2023-12-14 09:50:37 +00:00
|
|
|
|
|
|
|
# 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-19 14:33:19 +00:00
|
|
|
response = netease_cloud_music_api.request("song_url_v1", {"id": '1880562045', "level": "exhigh"})
|
2023-12-11 10:31:07 +00:00
|
|
|
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-19 14:33:19 +00:00
|
|
|
response = netease_cloud_music_api.request("user_account", query={"timestamp": time.time()})
|
2023-12-11 10:31:07 +00:00
|
|
|
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-19 14:33:19 +00:00
|
|
|
response = netease_cloud_music_api.request("/captcha/sent", {"phone": "15234941791", "timestamp": time.time()})
|
2023-12-11 10:31:07 +00:00
|
|
|
pprint(response)
|
|
|
|
|
|
|
|
|
|
|
|
def login_cellphone_test():
|
2023-12-19 14:33:19 +00:00
|
|
|
response = netease_cloud_music_api.request("/login/cellphone",
|
|
|
|
{
|
|
|
|
"phone": "15234941791",
|
|
|
|
"captcha": "9159",
|
|
|
|
"timestamp": time.time()
|
|
|
|
})
|
2023-12-15 07:55:04 +00:00
|
|
|
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-19 14:33:19 +00:00
|
|
|
def playlist_track_all_test():
|
|
|
|
response = netease_cloud_music_api.request("playlist_track_all", {'id': '592179800'})
|
|
|
|
pprint(response)
|
|
|
|
|
|
|
|
|
|
|
|
def login_refresh():
|
|
|
|
response = netease_cloud_music_api.request("login_refresh", {"timestamp": time.time()})
|
|
|
|
pprint(response)
|
|
|
|
|
|
|
|
|
2023-12-30 18:26:19 +00:00
|
|
|
def login_status():
|
|
|
|
response = netease_cloud_music_api.request("login_status")
|
|
|
|
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())
|
2023-12-19 17:10:25 +00:00
|
|
|
# song_url_v1_test()
|
2023-12-15 07:55:04 +00:00
|
|
|
# top_mv_test()
|
2023-12-30 18:26:19 +00:00
|
|
|
search_test()
|
2023-12-06 04:35:16 +00:00
|
|
|
# search_default_test()
|
2023-12-06 08:01:28 +00:00
|
|
|
# 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-16 15:18:26 +00:00
|
|
|
# login_cellphone_test()
|
2023-12-19 17:10:25 +00:00
|
|
|
# user_account_test()
|
2023-12-19 14:33:19 +00:00
|
|
|
# playlist_track_all_test()
|
2023-12-30 18:26:19 +00:00
|
|
|
# login_refresh()
|
|
|
|
# login_status()
|