mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
feat(indexer): API 站点支持音乐搜索(馒头/杜比/海胆/Rousi Pro/SunnyPT)
- MTorrentSpider 新增音乐分类(406 Music(音樂)),音乐搜索不再误用电影分类 - HddolbySpider 新增音乐唱片分类(408),演唱会视频(406)不计入音乐 - HaiDanSpider 新增 HQ Audio 音乐分类(408),并修复解析时从响应顶层取 category 恒为空的既有问题 - RousiSpider 支持 music 分类参数与结果标记,分类 ID 映射补充 5->music - SunnyPTSpider 分类映射与结果解析通用支持 music 媒体类型 - 新增对应站点 spider 音乐搜索单测
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
from app.modules.indexer.spider import mtorrent as mtorrent_module
|
||||
from app.modules.indexer.spider.mtorrent import MTorrentSpider
|
||||
from app.schemas import MediaType
|
||||
|
||||
|
||||
def _build_indexer() -> dict:
|
||||
"""构造 M-Team API Spider 所需的最小站点配置。"""
|
||||
return {
|
||||
"id": "mteam",
|
||||
"name": "馒头",
|
||||
"domain": "https://xp.m-team.io/",
|
||||
"apikey": "mteam-secret",
|
||||
"ua": "MoviePilot-Test",
|
||||
"proxy": False,
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mteam_spider(monkeypatch):
|
||||
"""构造不依赖真实数据库配置的 MTorrentSpider。"""
|
||||
monkeypatch.setattr(mtorrent_module, "SystemConfigOper", lambda: None)
|
||||
return MTorrentSpider(_build_indexer())
|
||||
|
||||
|
||||
def test_music_search_uses_music_categories(mteam_spider):
|
||||
"""音乐搜索应只提交馒头音乐分区分类,而不是电影分类。"""
|
||||
params = mteam_spider._MTorrentSpider__get_params("周杰伦 七里香", MediaType.MUSIC)
|
||||
|
||||
assert params["categories"] == MTorrentSpider._music_category
|
||||
|
||||
|
||||
def test_movie_search_keeps_movie_categories(mteam_spider):
|
||||
"""电影搜索行为不受音乐分类新增影响。"""
|
||||
params = mteam_spider._MTorrentSpider__get_params("流浪地球", MediaType.MOVIE)
|
||||
|
||||
assert params["categories"] == MTorrentSpider._movie_category
|
||||
|
||||
|
||||
def test_parse_result_marks_music_torrents(mteam_spider):
|
||||
"""音乐分区种子应标记为音乐媒体类型,供音乐搜索链路筛选。"""
|
||||
results = mteam_spider._MTorrentSpider__parse_result([
|
||||
{"id": "1", "name": "周杰伦 - 七里香 [FLAC]", "category": "406", "size": "1024", "status": {}},
|
||||
{"id": "2", "name": "流浪地球 2160p", "category": "419", "size": "1024", "status": {}},
|
||||
{"id": "3", "name": "其他资源", "category": "999", "size": "1024", "status": {}},
|
||||
])
|
||||
|
||||
assert [torrent["category"] for torrent in results] == [
|
||||
MediaType.MUSIC.value,
|
||||
MediaType.MOVIE.value,
|
||||
MediaType.UNKNOWN.value,
|
||||
]
|
||||
Reference in New Issue
Block a user