搜索歌曲海音乐,支持下载到群晖NAS。
类型说明可下载到群晖标准品质(API)通过API获取的直接mp3链接✅ 可以高品质(直接链接)页面上的直接mp3/flac链接✅ 可以高品质(网盘链接)夸克网盘等分享链接❌ 需手动下载
重要: API请求需要带上 X-Custom-Header: SecretKey 才能成功!
bash
python scripts/gequhai_crawler.py --search "青花瓷"
bash
python scripts/gequhai_crawler.py --detail 553
bash
python scripts/gequhai_crawler.py --download "周杰伦 晴天"
python
from scripts.gequhai_crawler import search_songs, get_download_url, download_song
# 搜索歌曲
songs = search_songs("青花瓷")
for s in songs[:5]:
print(f"[{s['id']}] {s['title']} - {s['artist']}")
# 获取下载链接
detail = get_download_url("553")
print(f"标题: {detail['title']}")
print(f"下载链接: {detail.get('url', detail.get('netdisk_url'))}")
print(f"品质: {detail.get('quality')}")
# 下载到群晖
result = download_song(detail, destination="download/音乐下载")
print(f"下载结果: {result}")
配置项值主机192.168.123.223:5000用户xiaoai默认下载目录download/音乐下载
用户问: 帮我下载周杰伦的青花瓷
用户问: 最近有什么好听的歌?
X-Custom-Header: SecretKey header,否则API返回403python
# API请求必须带上这个header
api_headers = {
"X-Requested-With": "XMLHttpRequest",
"X-Custom-Header": "SecretKey", # 关键!
}
# 使用Session保持cookie
session = requests.Session()
# 先访问播放页面获取cookie
session.get(f"{BASE_URL}/play/{song_id}")
# 再请求API
session.post(f"{BASE_URL}/api/music", headers=api_headers, data={...})
错误原因解决方案未找到歌曲关键词不匹配尝试其他关键词没有下载链接歌曲暂无资源换一首歌网盘链接高品质版本在网盘手动下载或使用标准品质