fix: missing dependencies, connection resets on /api/ endpoints, and large-playlist parsing failures - #3
Open
policej wants to merge 3 commits into
Open
Conversation
music_downloader.py imports aiohttp and aiofiles for async batch downloads, but neither is listed in requirements.txt, so a fresh install following the README fails on startup with ModuleNotFoundError: No module named 'aiohttp'. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nnection resets interface3.music.163.com rejects plain /api/ requests that lack the default device cookies (os=pc, deviceId, ...) by resetting the TCP connection (ConnectionResetError 10054 on Windows, SSL EOF behind some networks). The eapi endpoints already merge DEFAULT_COOKIES in HTTPClient.post_request, but get_song_detail sent no cookies at all, and get_lyric / get_playlist_detail forwarded only the login cookie (MUSIC_U), so single-song parsing, lyrics and playlist parsing failed for affected accounts/networks. Merge DEFAULT_COOKIES with the login cookies on these three endpoints, matching the behavior of the eapi channel. Verified against a live account: identical request succeeds with the device cookies and is reset without them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The playlist parser fetched song details in batches of 100 with a 5s timeout and no retry, so a single dropped request (interface3 resets connections under load fairly often) failed the whole playlist parse. Large playlists rarely survived. Fetch in batches of 10 with a 1s pause between batches, retry each batch up to 3 times with backoff, and allow a 15s timeout for the larger responses. Verified with a 168-track playlist that previously always failed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
本 PR 修复了三个实际使用中遇到并逐一定位的问题(Windows 11 / Python 3.13 真实账号验证):
1. requirements.txt 缺少
aiohttp和aiofilesmusic_downloader.py引用了这两个库,但依赖清单未列出,按 README 全新安装后启动即报ModuleNotFoundError: No module named 'aiohttp'。2. 普通
/api/接口未携带默认设备 cookie,导致连接被服务器重置interface3.music.163.com对不带os=pc/deviceId等默认 cookie 的/api/请求会直接重置连接(Windows 上表现为ConnectionResetError(10054))。eapi 通道在HTTPClient.post_request中已正确合并DEFAULT_COOKIES,但get_song_detail(完全未带 cookie)、get_lyric与get_playlist_detail(仅带登录 cookie)没有合并,导致单曲解析、歌词、歌单解析在部分账号/网络环境下必然失败。已实测对照:同一请求带设备 cookie 返回 200,不带则被掐断。3. 歌单解析每批 100 首、无重试,大歌单几乎必失败
interface3 负载下经常重置连接,原实现任何一批失败即整单报废。改为每批 10 首、批间隔 1 秒、每批最多重试 3 次(2s/4s 退避)、超时放宽至 15 秒。168 首歌单实测:改前必失败,改后稳定解析。
(English summary) 1) Add missing
aiohttp/aiofilesdeps; 2) merge default device cookies into plain/api/endpoints to stop server-side connection resets; 3) fetch playlist song details in batches of 10 with retry/backoff instead of 100 with none.🤖 Generated with Claude Code