The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
fix(bili): 封面跟分类目录走 1.1.2
XiaoYouChR7b726b29c3a7
diff --git a/dist/packs/bili_pack.zip b/dist/packs/bili_pack.zipindex 33a0253b..799cfc62 100644Binary files a/dist/packs/bili_pack.zip and b/dist/packs/bili_pack.zip differdiff --git a/features/bili_pack/manifest.toml b/features/bili_pack/manifest.tomlindex 4a24676a..397a4ef5 100644--- a/features/bili_pack/manifest.toml+++ b/features/bili_pack/manifest.toml@@ -2,5 +2,5 @@entry = "pack.py"class = "BilibiliPack"dependencies = ["http_pack", "ffmpeg_pack"]-version = "1.1.1"+version = "1.1.2"gdMinVersion = "4.2.0"diff --git a/features/bili_pack/task.py b/features/bili_pack/task.pyindex 0ea9c2a1..43a19e15 100644--- a/features/bili_pack/task.py+++ b/features/bili_pack/task.py@@ -244,10 +244,10 @@ class BilibiliTask(Task):def _addCoverSteps(self, stepIndex: int) -> int:if not self.isCoverEnabled:return stepIndex- have = {getattr(s, "outputFile", "") for s in self.steps}- covers: list[tuple[str, int, str]] = []+ have = {s.fileIndex for s in self.steps if isinstance(s, BilibiliCoverStep)}+ covers: list[tuple[str, int, int | None]] = []if self.coverUrl:- covers.append((self.coverUrl, self.coverSize, f"{self._baseName}.jpg"))+ covers.append((self.coverUrl, self.coverSize, None))if self.isSeason:seen: set[str] = set()for page in self.files or []:@@ -257,26 +257,24 @@ class BilibiliTask(Task):if key in seen:continueseen.add(key)- title = page.episodeTitle or key- name = toSafeFilename(f"{self._baseName} - {title}.jpg", fallback="cover.jpg")- covers.append((page.coverUrl, 0, name))+ covers.append((page.coverUrl, 0, page.index))referer = next((p.headers.get("referer") for p in (self.files or []) if p.headers.get("referer")), "")headers = {"referer": referer} if referer else {}- for url, size, name in covers:- outputFile = str(self.filesFolder / name)- if outputFile in have:+ for url, size, fileIndex in covers:+ if fileIndex in have:continuestepIndex += 1- self.steps.append(HttpTaskStep(+ self.steps.append(BilibiliCoverStep(stepIndex=stepIndex,url=url,fileSize=size,headers=headers,canUseRangeRequests=size > 0,subworkerCount=1,- outputFile=outputFile,+ fileIndex=fileIndex,))self.steps[-1]._bindTask(self)+ have.add(fileIndex)return stepIndexdef _addFileSteps(self, file: BiliPage, stepIndex: int) -> int:@@ -357,6 +355,20 @@ def pageStem(taskName: str, pageSuffix: str) -> str:return f"{stem}{pageSuffix}" if pageSuffix else stem+@dataclass(kw_only=True)+class BilibiliCoverStep(HttpTaskStep):++ @property+ def outputPath(self) -> str:+ stem = self.task._baseName+ if self.fileIndex is not None:+ page = pageByIndex(self.task, self.fileIndex)+ title = (page.episodeTitle or page.bvid or f"#{page.index}") if page else ""+ if title:+ stem = f"{stem} - {title}"+ return str(self.task.filesFolder / toSafeFilename(f"{stem}.jpg", fallback="cover.jpg"))++@dataclass(kw_only=True)class BilibiliVideoStep(HttpTaskStep):fileIndex: int = 0diff --git a/tests/test_bili_parse.py b/tests/test_bili_parse.pyindex d28332fb..610beb24 100644--- a/tests/test_bili_parse.py+++ b/tests/test_bili_parse.py@@ -333,7 +333,7 @@ def test_seasonSummary_one_episode():def test_cover_steps_season_and_selected_episodes():from pathlib import Path- from bili_pack.task import BiliPage, BilibiliTask+ from bili_pack.task import BiliPage, BilibiliCoverStep, BilibiliTask, setEpisodeTitlefiles = [BiliPage(@@ -355,15 +355,45 @@ def test_cover_steps_season_and_selected_episodes():isCoverEnabled=True,)task.update()- coverFiles = [getattr(s, "outputFile", "") for s in task.steps if getattr(s, "outputFile", "")]+ coverFiles = [s.outputPath for s in task.steps if isinstance(s, BilibiliCoverStep)]assert any(p.endswith("各种番.jpg") for p in coverFiles)assert any(p.endswith("各种番 - 游戏王5DS.jpg") for p in coverFiles)assert not any("棋魂" in p for p in coverFiles)task.setSelection({0, 1})- coverFiles = [getattr(s, "outputFile", "") for s in task.steps if getattr(s, "outputFile", "")]+ coverFiles = [s.outputPath for s in task.steps if isinstance(s, BilibiliCoverStep)]assert any(p.endswith("各种番 - 棋魂.jpg") for p in coverFiles)+ setEpisodeTitle([files[0]], "新标题")+ coverFiles = [s.outputPath for s in task.steps if isinstance(s, BilibiliCoverStep)]+ assert any(p.endswith("各种番 - 新标题.jpg") for p in coverFiles)+ assert not any("游戏王5DS" in p for p in coverFiles)+++def test_cover_output_follows_outputFolder():+ from pathlib import Path+ from bili_pack.task import BiliPage, BilibiliCoverStep, BilibiliTask++ task = BilibiliTask(+ name="专武.mp4",+ url="u",+ outputFolder=Path("/tmp/Downloads"),+ files=[BiliPage(index=0, relativePath="a", selected=True)],+ _baseName="专武",+ coverUrl="https://i0.hdslb.com/bfs/cover.jpg",+ isCoverEnabled=True,+ )+ task.update()+ covers = [s for s in task.steps if isinstance(s, BilibiliCoverStep)]+ assert len(covers) == 1+ assert covers[0].outputPath == str(Path("/tmp/Downloads") / "专武.jpg")++ task.outputFolder = Path("/tmp/Downloads/Video")+ assert covers[0].outputPath == str(Path("/tmp/Downloads/Video") / "专武.jpg")++ task.setName("新名字.mp4")+ assert covers[0].outputPath == str(Path("/tmp/Downloads/Video") / "新名字.jpg")+def test_setEpisodeTitle_updates_relativePath():from bili_pack.task import BiliPage, setEpisodeTitle, setPagePartdiff --git a/versions.json b/versions.jsonindex c0ec07de..80e8bc22 100644--- a/versions.json+++ b/versions.json@@ -52,9 +52,9 @@},"packs": {"bili_pack": {- "version": "1.1.1",+ "version": "1.1.2","file": "bili_pack.zip",- "sha256": "57ef8ace748714bd7b115b975b63ac16eea38b4357c34b4e0b0669f0d9b9ed11",+ "sha256": "c3848f1ca13b23e7f8d5c88facd53c790ca9ee58e6b6f300bbf68bb9abfce6bd","gdMinVersion": "4.2.0"},"bittorrent_pack": {