mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 16:07:01 +08:00
feat(download): expose source site for active tasks (#6231)
This commit is contained in:
@@ -1779,6 +1779,7 @@ class DownloadChain(ChainBase):
|
|||||||
"episode": history.episodes,
|
"episode": history.episodes,
|
||||||
"image": history.image,
|
"image": history.image,
|
||||||
}
|
}
|
||||||
|
torrent.site_name = history.torrent_site
|
||||||
# 下载用户
|
# 下载用户
|
||||||
torrent.userid = history.userid
|
torrent.userid = history.userid
|
||||||
torrent.username = history.username
|
torrent.username = history.username
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class DownloaderTorrent(BaseModel):
|
|||||||
downloader: Optional[str] = None
|
downloader: Optional[str] = None
|
||||||
hash: Optional[str] = None
|
hash: Optional[str] = None
|
||||||
title: Optional[str] = None
|
title: Optional[str] = None
|
||||||
|
site_name: Optional[str] = None
|
||||||
name: Optional[str] = None
|
name: Optional[str] = None
|
||||||
year: Optional[str] = None
|
year: Optional[str] = None
|
||||||
season_episode: Optional[str] = None
|
season_episode: Optional[str] = None
|
||||||
|
|||||||
+1
-1
@@ -170,7 +170,7 @@ AniList 榜单、探索、详情、人物和推荐接口优先通过 `anilist-ch
|
|||||||
|
|
||||||
| 方法 | 路径 | 说明 |
|
| 方法 | 路径 | 说明 |
|
||||||
| :--- | :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
| GET | `/api/v1/download/` | 查询正在下载的任务,参数:`name` |
|
| GET | `/api/v1/download/` | 查询正在下载的任务,参数:`name`;关联下载历史时返回媒体类型及来源站点 `site_name` |
|
||||||
| POST | `/api/v1/download/` | 添加含媒体信息的下载任务,请求体包含媒体信息和种子信息 |
|
| POST | `/api/v1/download/` | 添加含媒体信息的下载任务,请求体包含媒体信息和种子信息 |
|
||||||
| POST | `/api/v1/download/add` | 添加不含媒体信息的下载任务,请求体包含 `torrent_in`,可选 `media_source` + `media_id`;继续兼容四种专用 ID,并支持 `downloader`、`save_path` |
|
| POST | `/api/v1/download/add` | 添加不含媒体信息的下载任务,请求体包含 `torrent_in`,可选 `media_source` + `media_id`;继续兼容四种专用 ID,并支持 `downloader`、`save_path` |
|
||||||
| POST | `/api/v1/download/subtitle` | 下载字幕到识别出的媒体下载目录,请求体包含 `subtitle_in`,可选 `media_source` + `media_id`;继续兼容四种专用 ID,并支持 `save_path` |
|
| POST | `/api/v1/download/subtitle` | 下载字幕到识别出的媒体下载目录,请求体包含 `subtitle_in`,可选 `media_source` + `media_id`;继续兼容四种专用 ID,并支持 `save_path` |
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ Streaming search sends `{"type":"heartbeat"}` every 15 seconds without business
|
|||||||
|
|
||||||
| Method | Path | Description |
|
| Method | Path | Description |
|
||||||
|--------|------|-------------|
|
|--------|------|-------------|
|
||||||
| GET | `/api/v1/download/` | List active downloads. Params: `name` (downloader name) |
|
| GET | `/api/v1/download/` | List active downloads. Params: `name` (downloader name); linked history adds media type and source `site_name` |
|
||||||
| POST | `/api/v1/download/` | Add download (with media info). Body: JSON |
|
| POST | `/api/v1/download/` | Add download (with media info). Body: JSON |
|
||||||
| POST | `/api/v1/download/add` | Add download without media info. Body: `torrent_in`, optional `media_source` + `media_id` (all four dedicated IDs remain supported), `downloader`, `save_path` |
|
| POST | `/api/v1/download/add` | Add download without media info. Body: `torrent_in`, optional `media_source` + `media_id` (all four dedicated IDs remain supported), `downloader`, `save_path` |
|
||||||
| POST | `/api/v1/download/subtitle` | Download subtitle file to the recognized media download directory. Body: `subtitle_in`, optional `media_source` + `media_id` (all four dedicated IDs remain supported), `save_path` |
|
| POST | `/api/v1/download/subtitle` | Download subtitle file to the recognized media download directory. Body: `subtitle_in`, optional `media_source` + `media_id` (all four dedicated IDs remain supported), `save_path` |
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from app.chain.download import DownloadChain
|
|||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.context import Context, MediaInfo, SubtitleInfo, TorrentInfo
|
from app.core.context import Context, MediaInfo, SubtitleInfo, TorrentInfo
|
||||||
from app.core.metainfo import MetaInfo
|
from app.core.metainfo import MetaInfo
|
||||||
from app.schemas import FileItem, NotExistMediaInfo, TransferDirectoryConf
|
from app.schemas import DownloaderTorrent, FileItem, NotExistMediaInfo, TransferDirectoryConf
|
||||||
from app.schemas.types import MediaType
|
from app.schemas.types import MediaType
|
||||||
|
|
||||||
|
|
||||||
@@ -1036,3 +1036,36 @@ def test_batch_download_keeps_count_check_without_complete_coverage(monkeypatch)
|
|||||||
assert lefts == {}
|
assert lefts == {}
|
||||||
assert context.confirmed_full_coverage is False
|
assert context.confirmed_full_coverage is False
|
||||||
chain.download_single.assert_called_once()
|
chain.download_single.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
|
def test_downloading_includes_media_type_and_source_site(monkeypatch):
|
||||||
|
"""
|
||||||
|
正在下载任务应从下载历史回填媒体类型和来源站点。
|
||||||
|
"""
|
||||||
|
torrent = DownloaderTorrent(hash="download-hash", title="Demo.Release")
|
||||||
|
history = SimpleNamespace(
|
||||||
|
episodes="E02",
|
||||||
|
image="https://images.example.com/demo.jpg",
|
||||||
|
seasons="S01",
|
||||||
|
title="示例剧集",
|
||||||
|
tmdbid=1001,
|
||||||
|
torrent_site="示例站点",
|
||||||
|
type="电视剧",
|
||||||
|
userid="user-1",
|
||||||
|
username="tester",
|
||||||
|
)
|
||||||
|
chain = DownloadChain.__new__(DownloadChain)
|
||||||
|
monkeypatch.setattr(chain, "list_torrents", lambda **_kwargs: [torrent])
|
||||||
|
monkeypatch.setattr(
|
||||||
|
download_module,
|
||||||
|
"DownloadHistoryOper",
|
||||||
|
lambda: SimpleNamespace(get_by_hashes=lambda _hashes: {torrent.hash: history}),
|
||||||
|
)
|
||||||
|
|
||||||
|
result = chain.downloading(name="qb-main")
|
||||||
|
|
||||||
|
assert result == [torrent]
|
||||||
|
assert torrent.media["type"] == "电视剧"
|
||||||
|
assert torrent.site_name == "示例站点"
|
||||||
|
assert torrent.userid == "user-1"
|
||||||
|
assert torrent.username == "tester"
|
||||||
|
|||||||
Reference in New Issue
Block a user