The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
fix(m3u8): 伪装文件名的 M3U8 没有交给 m3u8_pack
XiaoYouChR6db00936b8ea
diff --git a/features/m3u8_pack/pack.py b/features/m3u8_pack/pack.pyindex c325c268..97e8638f 100644--- a/features/m3u8_pack/pack.py+++ b/features/m3u8_pack/pack.py@@ -16,7 +16,7 @@ from app.config.cfg import cfgfrom app.i18n import Nfrom app.models.pack import FeaturePack, TaskParser, FileType-from app.models.task import PageTaskOptions, Task, TaskOptions+from app.models.task import PageTaskOptions, ResourceTaskOptions, Task, TaskOptionsfrom app.platform.filesystem import localFilePath, toSafeFilenamefrom .config import m3u8Config, m3u8Runtimefrom .task import M3U8SubtitleStep, M3U8Task, M3U8TaskStep@@ -48,7 +48,11 @@ class M3U8Parser(TaskParser):lowered = options.url.lower()if ".m3u" in lowered or ".mpd" in lowered:return True- return options.isProbed and options.file.matchType(MANIFEST_SUFFIXES, MANIFEST_CONTENT_TYPES)+ if not options.isProbed:+ return False+ # The MIME alone is enough: parse checks the body and falls back to a plain file.+ return (Path(options.file.name).suffix.lower() in MANIFEST_SUFFIXES+ or options.file.contentType in MANIFEST_CONTENT_TYPES)async def parse(self, options: TaskOptions) -> Task:url = options.url.strip()@@ -133,6 +137,8 @@ class M3U8Parser(TaskParser):name = ""if isinstance(options, PageTaskOptions) and options.pageTitle:name = toSafeFilename(options.pageTitle, fallback="")+ elif isinstance(options, ResourceTaskOptions) and options.name:+ name = options.nameif not name:cd = responseHeaders.get("content-disposition", "")diff --git a/tests/m3u8_pack/test_task_parser.py b/tests/m3u8_pack/test_task_parser.pyindex 6e6d8a7f..7c453eec 100644--- a/tests/m3u8_pack/test_task_parser.py+++ b/tests/m3u8_pack/test_task_parser.py@@ -6,10 +6,11 @@ import pytestfrom aiohttp import webfrom app.models.pack import PackServices-from app.models.task import TaskOptions+from app.models.task import ResourceTaskOptions, TaskOptionsfrom ffmpeg_pack.pack import FFmpegPackfrom http_pack.pack import HttpPackfrom http_pack.task import HttpTask+from m3u8_pack.config import m3u8Configfrom m3u8_pack.pack import M3U8Packfrom m3u8_pack.task import M3U8Task, subtitleChoicesfrom tests.helpers import buildRangeHandler@@ -59,6 +60,32 @@ async def test_parse_broken_playlist_without_suffix_adds_plain_file(features, stassert isinstance(task, HttpTask)+def buildDisguisedHandler(content: bytes):+ typedHandler = buildTypedHandler(content, "application/x-mpegurl")++ async def handler(request: web.Request) -> web.Response:+ response = await typedHandler(request)+ response.headers["Content-Disposition"] = "attachment; filename=my.9stream.us"+ return response+ return handler+++async def test_parse_playlist_with_disguised_filename_adds_stream(features, startServer):+ url = await startServer(buildDisguisedHandler(PLAYLIST))++ task = await features.parse(TaskOptions(url=url))++ assert isinstance(task, M3U8Task)+++async def test_parse_resource_playlist_takes_resource_name(features, startServer):+ url = await startServer(buildDisguisedHandler(PLAYLIST))++ task = await features.parse(ResourceTaskOptions(url=url, name="Nocturne.m3u8"))++ assert task.name == f"Nocturne.{m3u8Config.outputFormat.value}"++async def test_parse_vimeo_playlist_adds_stream(features, startServer):url = await startServer(buildTypedHandler(VIMEO_SAMPLE.read_bytes(), "application/json"))playlistUrl = url.removesuffix("/file") + "/exp=1~acl=x/clip/psid=1/v2/playlist/av/primary/prot/x/playlist.json"