fix: 黄豆按站点方式保持登录并自动切换播放线路

This commit is contained in:
Nixevol
2026-10-25 05:40:19 +08:00
parent 3fe936fe70
commit f53498f6e6
11 changed files with 444 additions and 197 deletions
+37
View File
@@ -669,6 +669,23 @@ class DownloadManager:
live.touch()
def _download_episode(self, drama_id: str, folder: Path, row: dict) -> None:
sources = _source_candidates(row)
if not sources:
self._set_phase(drama_id, row["cid"], "skipped")
return
source_dir, _mp4_path = self._episode_paths(folder, row)
for index, src in enumerate(sources):
attempt = dict(row)
attempt["src"] = src
try:
self._download_one_source(drama_id, folder, attempt)
return
except RuntimeError as exc:
if str(exc) == "已停止" or index + 1 == len(sources):
raise
_clear_source_files(source_dir)
def _download_one_source(self, drama_id: str, folder: Path, row: dict) -> None:
if not row.get("src"):
self._set_phase(drama_id, row["cid"], "skipped")
return
@@ -869,6 +886,26 @@ class DownloadManager:
)
def _source_candidates(row: dict) -> list[str]:
urls = []
src = str(row.get("src") or "").strip()
if src:
urls.append(src)
for item in row.get("line_urls") or []:
text = str(item or "").strip()
if text and text not in urls:
urls.append(text)
return urls
def _clear_source_files(source_dir: Path) -> None:
if not source_dir.is_dir():
return
for child in source_dir.iterdir():
if child.is_file():
child.unlink(missing_ok=True)
def _keep_finished_episode(phase: str, mp4_path: Path) -> bool:
return phase == "done" and mp4_path.is_file() and mp4_path.stat().st_size > 0