Skip to content

The only downloader you need. 下载器的集大成者。

refactor: 移除冗余代码和未使用的变量

XiaoYouChRc8edfbd916b2
diff --git a/app/bases/models.py b/app/bases/models.py
index 42fcf01f..cd011785 100644
--- a/app/bases/models.py
+++ b/app/bases/models.py
@@ -263,19 +263,17 @@ class Task:
return self.updateStatus()
def pendingStages(self) -> Iterable[TaskStage]:
+ from app.supports.recorder import taskRecorder
+
self.stages.sort(key=lambda stage: stage.stageIndex)
for stage in self.stages:
if self.status != TaskStatus.RUNNING:
break
if stage.status == TaskStatus.COMPLETED:
continue
- self._onStageStarted(stage)
+ taskRecorder.flush()
yield stage
- def _onStageStarted(self, stage: TaskStage):
- from app.supports.recorder import taskRecorder
- taskRecorder.flush()
-
def setSelection(self, selectedIndexes: list[int]):
if self.files is None or self.stageType is None:
return
diff --git a/app/services/browser_service.py b/app/services/browser_service.py
index a1d2f91d..da874d89 100644
--- a/app/services/browser_service.py
+++ b/app/services/browser_service.py
@@ -13,7 +13,6 @@ from qfluentwidgets import MessageBox
from app.bases.models import Task, TaskStatus
from app.services.core_service import coreService
-from app.services.feature_service import featureService
from app.supports.config import VERSION, cfg
from app.supports.recorder import taskRecorder
from app.supports.utils import bringWindowToTop, getProxies, openFile, openFolder
diff --git a/features/bili_pack/config.py b/features/bili_pack/config.py
index a875a823..c397ae4c 100644
--- a/features/bili_pack/config.py
+++ b/features/bili_pack/config.py
@@ -91,7 +91,6 @@ class ScanLoginDialog(MessageBoxBase):
self._loginUrl = ""
self._generation = 0
self._generating = False
- self._polling = False
self._closed = False
self.setClosableOnMaskClicked(True)
@@ -161,7 +160,6 @@ class ScanLoginDialog(MessageBoxBase):
self._generation += 1
self._generating = True
- self._polling = False
self.cookie = ""
self._qrCodeKey = ""
self._loginUrl = ""
@@ -200,7 +198,6 @@ class ScanLoginDialog(MessageBoxBase):
self.openBrowserButton.setEnabled(True)
self.statusLabel.setText(self.tr("等待扫码并在手机端确认登录"))
- self._polling = True
generation = self._generation
coreService.runCoroutine(
pollQrLogin(
@@ -230,8 +227,6 @@ class ScanLoginDialog(MessageBoxBase):
if self._closed or generation != self._generation:
return
- self._polling = False
-
if error:
self.statusLabel.setText(self.tr('轮询扫码状态失败,请点击"刷新二维码"重试'))
return
diff --git a/features/bili_pack/pack.py b/features/bili_pack/pack.py
index 3aefbaf3..82e96944 100644
--- a/features/bili_pack/pack.py
+++ b/features/bili_pack/pack.py
@@ -1,6 +1,5 @@
import re
from pathlib import Path
-from typing import TYPE_CHECKING
from urllib.parse import parse_qs, urlparse
import niquests
diff --git a/features/bittorrent_pack/cards.py b/features/bittorrent_pack/cards.py
index 9d296aa1..886d0d32 100644
--- a/features/bittorrent_pack/cards.py
+++ b/features/bittorrent_pack/cards.py
@@ -1,7 +1,7 @@
import shutil
-from pathlib import Path, PurePosixPath
+from pathlib import Path
-from PySide6.QtCore import Qt, QFileInfo
+from PySide6.QtCore import Qt
from PySide6.QtWidgets import (
QHBoxLayout,
QVBoxLayout,
diff --git a/features/bittorrent_pack/config.py b/features/bittorrent_pack/config.py
index 93f7e72f..85a37c8c 100644
--- a/features/bittorrent_pack/config.py
+++ b/features/bittorrent_pack/config.py
@@ -12,7 +12,6 @@ from qfluentwidgets import (
MessageBoxBase,
OptionsConfigItem,
OptionsValidator,
- PlainTextEdit,
PrimaryPushButton,
RangeConfigItem,
RangeSettingCard,
diff --git a/features/bittorrent_pack/pack.py b/features/bittorrent_pack/pack.py
index a259d11f..16a5c03d 100644
--- a/features/bittorrent_pack/pack.py
+++ b/features/bittorrent_pack/pack.py
@@ -8,7 +8,7 @@ from app.services.core_service import coreService
from .cards import BitTorrentResultCard, BTTaskCard
from .config import bittorrentConfig, getCachedWebTrackers, refreshConfiguredWebTrackers
-from .task import BTTask, resolve as _btResolve, loadLocalTorrent
+from .task import resolve as _btResolve, loadLocalTorrent
def _isTorrentUrl(url: str) -> bool:
diff --git a/features/ffmpeg_pack/pack.py b/features/ffmpeg_pack/pack.py
index c5aec7f1..8f7c75ae 100644
--- a/features/ffmpeg_pack/pack.py
+++ b/features/ffmpeg_pack/pack.py
@@ -5,7 +5,6 @@ from typing import Any, TYPE_CHECKING
from urllib.parse import urlparse
import niquests
-from loguru import logger
from app.bases.interfaces import FeaturePack
from app.bases.models import Task, SpecialFileSize
diff --git a/features/ftp_pack/pack.py b/features/ftp_pack/pack.py
index cd859217..49483088 100644
--- a/features/ftp_pack/pack.py
+++ b/features/ftp_pack/pack.py
@@ -4,7 +4,7 @@ from app.bases.interfaces import FeaturePack
from app.bases.models import Task
from .cards import FtpResultCard, FtpTaskCard
-from .task import FtpTask, resolve as _ftpResolve
+from .task import resolve as _ftpResolve
class FtpPack(FeaturePack):
diff --git a/features/m3u8_pack/task.py b/features/m3u8_pack/task.py
index e8941720..2c0656d3 100644
--- a/features/m3u8_pack/task.py
+++ b/features/m3u8_pack/task.py
@@ -6,11 +6,10 @@ from contextlib import suppress
from dataclasses import dataclass, field
from email.message import Message
from pathlib import Path
-from typing import Any, TYPE_CHECKING
+from typing import TYPE_CHECKING
from urllib.parse import parse_qs, unquote, urlparse
import niquests
-from loguru import logger
from app.bases.interfaces import Worker
from app.bases.models import Task, TaskStage, TaskStatus
@@ -127,7 +126,7 @@ class M3U8Worker(Worker):
self.stage = stage
self.task = stage.task
- def _buildArgs(self, downloaderPath: str) -> list[str]:
+ def _buildArgs(self) -> list[str]:
meta = self.task.metadata
saveName = meta.get("saveName", _stem(self.task.title))
@@ -284,7 +283,7 @@ class M3U8Worker(Worker):
process = None
supervisorTask = None
try:
- args = self._buildArgs(execPath)
+ args = self._buildArgs()
process = await asyncio.create_subprocess_exec(
execPath,
*args,