From 6d9a86df0ff0642aef8f763bd2e228d4c0053417 Mon Sep 17 00:00:00 2001 From: Dr_rOot Date: Wed, 23 Sep 2026 12:12:46 +0800 Subject: [PATCH] fix(scraper-hook): move beforecreate to the enrich band The hook ran in the pre-resolve band, which fails its chain closed. With `*://*/*` host permissions, any failure or slow page aborted the creation of every HTTP task (agalwood/Motrix#2189). Looking up a direct link on an HTML page is an optional convenience and must never veto a download. Run beforeCreate in the enrich band. There a failure or overrun drops the plugin's contribution and Motrix downloads the URL the user gave. pre-resolve is also reserved for builtin origin, and Motrix is retiring the plugin from its bundled set, so the plugin could not load there without this change. Bump to 1.1.0, which also ships the single three-second discovery deadline merged in #3. Document the move in the READMEs. --- CLAUDE.md | 2 +- README.md | 6 ++++++ README.zh-CN.md | 2 ++ plugins/motrix.scraper-hook/motrix-plugin.json | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index ee46c99..15a5e01 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -21,7 +21,7 @@ plugin version, bump the corresponding lockfile entry in `motrix-turbo`. | id | `plugins/` dir | purpose | |----|----------------|---------| | `motrix.filename-template` | `plugins/motrix.filename-template/` | renames completed downloads from a user-configurable filename template | -| `motrix.scraper-hook` | `plugins/motrix.scraper-hook/` | pre-resolve HTTP hook for site scraping | +| `motrix.scraper-hook` | `plugins/motrix.scraper-hook/` | enrich-band HTTP hook for page scraping; fails open, and is no longer in motrix-turbo's bundled set | | `motrix.url-resolver` | `plugins/motrix.url-resolver/` | URL-resolver framework + Wikimedia Commons demo resolver; site-specific extraction lives in separately installed site-resolver plugins | Plugin ids double as tag prefixes and manifest `id` fields — they must match diff --git a/README.md b/README.md index 92204e7..637b5fa 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,12 @@ keep their original names because the extension is appended separately. *Plugin ID: `motrix.scraper-hook`* +> **Not bundled with Motrix.** Page Scraper used to ship as a built-in plugin. +> It now installs on demand, because a page lookup is an optional convenience +> and should never be able to hold up a download. Its `beforeCreate` hook runs +> in the `enrich` band: if the lookup fails or runs long, Motrix drops the +> plugin's contribution and downloads the URL you actually gave it. + Sometimes a "download link" leads to an HTML page that contains the real file link. Without this plugin, Motrix would save the page as an `.html` file. diff --git a/README.zh-CN.md b/README.zh-CN.md index 5ef5e12..893afd0 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -77,6 +77,8 @@ Motrix 2 自带三个插件,分别用来重命名下载好的文件、从下 *插件 ID:`motrix.scraper-hook`* +> **不再随 Motrix 内置分发。** 页面抓取原本是内置插件,现在改为按需安装:查找页面只是锦上添花,不该有能力拖住一次下载。它的 `beforeCreate` hook 现在运行在 `enrich` band,抓取失败或超时时 Motrix 会丢弃该插件的结果,直接下载你输入的那个 URL。 + 有些所谓的“下载链接”其实只是一个 HTML 页面,真正的文件链接藏在页面里。直接下载这种链接,最后得到的往往只是一个没用的 `.html` 文件。 新建 HTTP 下载时,如果插件发现链接指向 HTML 页面,就会查找页面中的第一个压缩包或安装包链接。目前支持 `.zip`、`.tar.gz`、`.tgz`、`.rar`、`.7z`、`.exe`、`.dmg`、`.iso` 和 `.pkg`。找到后,Motrix 会改为下载对应的文件。 diff --git a/plugins/motrix.scraper-hook/motrix-plugin.json b/plugins/motrix.scraper-hook/motrix-plugin.json index 81402b5..b21395e 100644 --- a/plugins/motrix.scraper-hook/motrix-plugin.json +++ b/plugins/motrix.scraper-hook/motrix-plugin.json @@ -3,7 +3,7 @@ "manifestVersion": 1, "id": "motrix.scraper-hook", "name": "%name%", - "version": "1.0.0", + "version": "1.1.0", "description": "%description%", "categories": ["site-resolver"], "engines": { "motrix": ">=2.0.0 <3.0.0" }, @@ -14,7 +14,7 @@ "activationEvents": ["onTaskType:http"], "contributes": { "hooks": { - "beforeCreate": { "role": "pre-resolve" } + "beforeCreate": { "role": "enrich" } }, "configuration": { "title": "%settings.title%",