diff --git a/docs/content/en/usage/_index.md b/docs/content/en/usage/_index.md index a131eef..0a0932e 100644 --- a/docs/content/en/usage/_index.md +++ b/docs/content/en/usage/_index.md @@ -13,248 +13,4 @@ To use the bot's Telegram file saving feature, you need to send or forward the f 1. File or media messages, such as images, videos, documents, etc. 2. Telegram message links, for example: `https://t.me/acherkrau/1097`. **Even if the channel prohibits forwarding and saving, the bot can still download its files.** -3. Telegra.ph article links. The bot will download all images in the article. - -## Silent Mode (silent) - -Use the `/silent` command to toggle silent mode. - -By default, silent mode is off, and the bot will ask you for the save location of each file. - -When silent mode is enabled, the bot will save files directly to the default location without confirmation. - -Before enabling silent mode, you need to set the default save location using the `/storage` command. - - -## Storage Rules - -Storage rules allow you to define redirection rules when the bot uploads files to storage, so that saved files are automatically organized. - -See: #28 - -Currently supported rule types: - -1. FILENAME-REGEX -2. MESSAGE-REGEX -3. IS-ALBUM - -Basic syntax for adding rules: - -"RuleType RuleContent StorageName Path" - -Pay attention to spaces; the bot can only parse correctly formatted syntax. Below is an example of a valid rule command: - -``` -/rule add FILENAME-REGEX (?i)\.(mp4|mkv|ts|avi|flv)$ MyAlist /videos -``` - -In addition, if `CHOSEN` is used as the storage name in the rule, it means files will be stored under the path of the storage you selected by clicking the inline button. - -Rule types: - -### FILENAME-REGEX - -Matches based on filename regex. The rule content must be a valid regular expression, such as: - -``` -FILENAME-REGEX (?i)\.(mp4|mkv|ts|avi|flv)$ MyAlist /videos -``` - -This means files with extensions mp4, mkv, ts, avi, flv will be saved to the `/videos` directory in the storage named `MyAlist` (also affected by the `base_path` in the configuration file). - -### MESSAGE-REGEX - -Similar to the above, but matches based on the text content of the message itself. - -### IS-ALBUM - -Matches album messages (media groups). Rule content can only be `true` or `false`. - -If the path in the rule uses `NEW-FOR-ALBUM`, the bot will create a new folder for each media group and store all files of that group there. See: https://github.com/krau/SaveAny-Bot/issues/87 - -For example: - -``` -IS-ALBUM true MyWebdav NEW-FOR-ALBUM -``` - -This will save media-group messages to the storage named `MyWebdav`, creating a new folder (generated from the first file) for each album. - -## Watch Chats - -{{< hint warning >}} -This feature requires enabling UserBot integration. -{{< /hint >}} - -You can watch messages in a specific chat and automatically save them to the default storage, following storage rules. You can also add filters so that only matching messages are saved. - -Watch a chat: - -``` -/watch [filter] -``` - -Stop watching: - -``` -/unwatch -``` - -Filter types: - -### msgre - -Regex-match the message text. For example: - -``` -/watch 12345678 msgre:.*hello.* -``` - -This will watch the chat with ID `12345678`, and only save messages whose text contains `hello`. - -## Direct Download Links - -Use the `/dl` command to directly download one or more HTTP/HTTPS files to storage. - -```bash -/dl [url2] [url3] ... -``` - -Examples: - -```bash -/dl https://example.com/file.zip -/dl https://example.com/file1.zip https://example.com/file2.zip -``` - -The bot will validate the link format and then ask you to select the target storage location. - -## Aria2 Download - -{{< hint warning >}} -This feature requires enabling Aria2 in the configuration file and configuring the RPC connection. -{{< /hint >}} - -Use the `/aria2dl` command to download files via the Aria2 download manager, supporting HTTP/HTTPS, FTP, BitTorrent, and other protocols. - -```bash -/aria2dl [uri2] [uri3] ... -``` - -Examples: - -```bash -# Download HTTP link -/aria2dl https://example.com/file.zip - -# Download magnet link -/aria2dl magnet:?xt=urn:btih:... - -# Download torrent file (need to upload .torrent file first) -/aria2dl https://example.com/file.torrent -``` - -Configure Aria2: - -Add to `config.toml`: - -```toml -[aria2] -enable = true -url = "http://localhost:6800/jsonrpc" -secret = "your-rpc-secret" # If rpc-secret is configured -remove_after_transfer = true # Remove local files after transfer -``` - -## yt-dlp Video Download - -{{< hint warning >}} -This feature requires the yt-dlp command-line tool installed on your system. -{{< /hint >}} - -Use the `/ytdlp` command to download videos and audio from supported video websites, including YouTube, Bilibili, Twitter, and 1000+ other sites. - -```bash -/ytdlp [url2] [flags...] -``` - -Examples: - -```bash -# Basic download -/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ - -# Download multiple videos -/ytdlp https://www.youtube.com/watch?v=video1 https://www.youtube.com/watch?v=video2 - -# Use custom parameters -/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ -f best -/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ --extract-audio --audio-format mp3 -``` - -Common parameters: - -- `-f `: Specify download format (e.g., `best`, `worst`, `bestvideo+bestaudio`) -- `--extract-audio`: Extract audio -- `--audio-format `: Audio format (e.g., `mp3`, `m4a`, `wav`) -- `--write-sub`: Download subtitles -- `--write-thumbnail`: Download thumbnail - -For more parameters, see [yt-dlp documentation](https://github.com/yt-dlp/yt-dlp#usage-and-options). - -## Storage Transfer - -Use the `/transfer` command to transfer files directly between different storages without going through Telegram. - -```bash -/transfer :/ [filter] -``` - -Parameters: - -- `source_storage`: Source storage name -- `source_path`: Source path -- `filter`: Optional regex filter to transfer only matching files - -Examples: - -```bash -# Transfer entire directory -/transfer local1:/downloads - -# Transfer files from specified path -/transfer alist1:/media/photos - -# Transfer only mp4 files -/transfer webdav1:/videos ".*\.mp4$" - -# Transfer image files -/transfer local1:/pictures "(?i)\.(jpg|png|gif)$" -``` - -The bot will: - -1. List all files in the source path -2. Apply the filter (if provided) -3. Display file count and total size -4. Ask you to select the target storage -5. Ask you to select the target directory (if configured for that storage) -6. Start the transfer task - -Notes: - -- Source storage must support listing and reading -- Target storage must support writing -- Real-time progress is displayed during transfer -- Transfer tasks can be cancelled - -## Save Files Outside Telegram - -Besides files on Telegram, the bot can also save files from other websites via JavaScript plugins or built-in parsers. - -> See the [Contributing Parsers](../contribute) document for details. - -Just send links that match the requirements of a parser to the bot. Currently built-in parsers include: - -- Twitter -- Kemono \ No newline at end of file +3. Telegra.ph article links. The bot will download all images in the article. \ No newline at end of file diff --git a/docs/content/en/usage/api.md b/docs/content/en/usage/api.md new file mode 100644 index 0000000..183651a --- /dev/null +++ b/docs/content/en/usage/api.md @@ -0,0 +1,442 @@ +--- +title: "HTTP API" +weight: 20 +--- + +# HTTP API + +SaveAny-Bot provides an HTTP API that allows you to programmatically create download/transfer tasks, query task status, cancel tasks, and more — without going through Telegram. + +## Enabling the API + +Add or modify the following section in `config.toml`: + +```toml +[api] +enable = true +host = "0.0.0.0" # Bind address, default 0.0.0.0 +port = 8080 # Listen port, default 8080 +token = "your-token" # Auth token — strongly recommended +``` + +You can also override these settings with environment variables (prefix `SAVEANY_`): + +| Environment Variable | Config Key | +|---|---| +| `SAVEANY_API_ENABLE` | `api.enable` | +| `SAVEANY_API_HOST` | `api.host` | +| `SAVEANY_API_PORT` | `api.port` | +| `SAVEANY_API_TOKEN` | `api.token` | + +{{< hint warning >}} +If `token` is empty, the API server will be accessible **without any authentication**, which is a security risk. +{{< /hint >}} + +## Authentication + +When `token` is configured, all API requests must include a Bearer token in the HTTP header: + +``` +Authorization: Bearer +``` + +On authentication failure, the server returns `401`: + +```json +{ "error": "unauthorized", "message": "invalid token" } +``` + +## Error Response Format + +All errors use a consistent JSON format: + +```json +{ + "error": "error_code", + "message": "human readable description" +} +``` + +Common error codes: + +| Error Code | HTTP Status | Meaning | +|---|---|---| +| `unauthorized` | 401 | Authentication failed | +| `method_not_allowed` | 405 | Wrong HTTP method | +| `invalid_request` | 400 | Malformed request body or parameters | +| `task_creation_failed` | 400 | Failed to create task | +| `task_not_found` | 404 | Task ID does not exist | +| `cancel_failed` | 500 | Failed to cancel task | +| `internal_error` | 500 | Internal server error | + +--- + +## Endpoints + +### GET /health — Health Check + +No authentication required. + +**Response `200 OK`:** + +```json +{ "status": "ok" } +``` + +--- + +### GET /api/v1/storages — List Storages + +Returns all currently loaded storage backends. + +**Response `200 OK`:** + +```json +{ + "storages": [ + { "name": "local", "type": "local" }, + { "name": "MyMinio", "type": "s3" } + ] +} +``` + +--- + +### GET /api/v1/task-types — List Supported Task Types + +**Response `200 OK`:** + +```json +{ + "types": [ + "directlinks", + "ytdlp", + "aria2", + "parseditem", + "tgfiles", + "tphpics", + "transfer" + ] +} +``` + +--- + +### POST /api/v1/tasks — Create Task + +**Request headers:** + +``` +Content-Type: application/json +Authorization: Bearer +``` + +**Request body:** + +```json +{ + "type": "", + "storage": "", + "path": "", + "webhook": "", + "params": { } +} +``` + +| Field | Type | Required | Description | +|---|---|---|---| +| `type` | string | Yes | Task type — see below | +| `storage` | string | Yes | Target storage name, must match a name in your config | +| `path` | string | No | Subdirectory path within the storage | +| `webhook` | string | No | Callback URL invoked when the task reaches a terminal state | +| `params` | object | Yes | Type-specific parameters — see below | + +**Response `201 Created`:** + +```json +{ + "task_id": "abc123xyz", + "type": "directlinks", + "status": "queued", + "created_at": "2026-03-11T10:00:00Z" +} +``` + +#### Task Types and params + +##### directlinks — Direct URL Download + +Download one or more files from direct HTTP/HTTPS URLs. + +```json +{ + "type": "directlinks", + "storage": "local", + "path": "downloads", + "params": { + "urls": [ + "https://example.com/file.zip", + "https://example.com/other.zip" + ] + } +} +``` + +| params field | Type | Required | Description | +|---|---|---|---| +| `urls` | []string | Yes | List of download URLs, at least 1 | + +##### ytdlp — yt-dlp Media Download + +{{< hint warning >}} +Requires yt-dlp to be installed on the system. +{{< /hint >}} + +Download videos or audio via yt-dlp, supporting YouTube, Bilibili, and 1000+ other sites. + +```json +{ + "type": "ytdlp", + "storage": "local", + "path": "videos", + "params": { + "urls": ["https://www.youtube.com/watch?v=xxx"], + "flags": ["--extract-audio", "--audio-format", "mp3"] + } +} +``` + +| params field | Type | Required | Description | +|---|---|---|---| +| `urls` | []string | Yes | List of media URLs, at least 1 | +| `flags` | []string | No | Extra yt-dlp command-line flags | + +##### aria2 — Aria2 Download + +{{< hint warning >}} +Requires Aria2 to be enabled and configured (RPC) in the config file. +{{< /hint >}} + +Download files via the Aria2 download manager, supporting HTTP/HTTPS, FTP, BitTorrent (magnet links, torrent files), and more. + +```json +{ + "type": "aria2", + "storage": "local", + "path": "downloads", + "params": { + "urls": ["magnet:?xt=urn:btih:..."], + "options": { "split": "4" } + } +} +``` + +| params field | Type | Required | Description | +|---|---|---|---| +| `urls` | []string | Yes | List of download URIs, at least 1 | +| `options` | map[string]string | No | Aria2 download options | + +##### parseditem — Parser Plugin Download + +Hand a URL off to a registered JS plugin or built-in parser for processing and downloading. + +```json +{ + "type": "parseditem", + "storage": "local", + "path": "parsed", + "params": { + "url": "https://some-site.com/page" + } +} +``` + +| params field | Type | Required | Description | +|---|---|---|---| +| `url` | string | Yes | The URL to parse | + +Returns `400 task_creation_failed` if no parser is able to handle the URL. + +##### tgfiles — Telegram Message File Download + +Download files from Telegram messages via message links. Supported link formats: + +- `https://t.me/username/123` — public channel or group +- `https://t.me/c/123456789/123` — private channel by numeric ID +- `https://t.me/c/123456789/111/456` — topic message (thread ID / message ID) +- `https://t.me/username/111/456` — topic under a username-based chat + +If the message is part of a media group (album), all files in the group are downloaded by default. Append `?single` to the link to force downloading only the single specified message. + +```json +{ + "type": "tgfiles", + "storage": "local", + "path": "telegram", + "params": { + "message_links": [ + "https://t.me/username/123", + "https://t.me/c/1234567890/456" + ] + } +} +``` + +| params field | Type | Required | Description | +|---|---|---|---| +| `message_links` | []string | Yes | List of Telegram message links, at least 1 | + +##### tphpics — Telegraph Article Images + +Download all images from a Telegra.ph article. + +Supported URL prefixes: `https://telegra.ph/`, `http://telegra.ph/`, `https://telegraph.co/`, `http://telegraph.co/` + +```json +{ + "type": "tphpics", + "storage": "local", + "path": "telegraph", + "params": { + "telegraph_url": "https://telegra.ph/Some-Article-01-01" + } +} +``` + +| params field | Type | Required | Description | +|---|---|---|---| +| `telegraph_url` | string | Yes | URL of the Telegra.ph article | + +##### transfer — Storage-to-Storage Transfer + +Transfer files directly between two storage backends without going through Telegram. The source storage must support both listing and reading. + +{{< hint info >}} +For `transfer` tasks, the top-level `storage` field is still required for validation, but the actual storages used are determined by `source_storage` and `target_storage` inside `params`. +{{< /hint >}} + +```json +{ + "type": "transfer", + "storage": "local", + "params": { + "source_storage": "MyS3", + "source_path": "backups/", + "target_storage": "LocalDisk", + "target_path": "restored/" + } +} +``` + +| params field | Type | Required | Description | +|---|---|---|---| +| `source_storage` | string | Yes | Source storage name | +| `source_path` | string | Yes | Path within the source storage; must contain at least one file | +| `target_storage` | string | Yes | Target storage name | +| `target_path` | string | Yes | Destination path within the target storage | + +--- + +### GET /api/v1/tasks — List All Tasks + +Returns all tasks created via the API. Task records are stored in memory only and are cleared on restart. + +**Response `200 OK`:** + +```json +{ + "tasks": [ + { + "task_id": "abc123xyz", + "type": "directlinks", + "status": "running", + "title": "file.zip", + "storage": "local", + "path": "downloads", + "error": "", + "created_at": "2026-03-11T10:00:00Z", + "updated_at": "2026-03-11T10:00:05Z", + "progress": { + "total_bytes": 10485760, + "downloaded_bytes": 5242880, + "percent": 50.0 + } + } + ], + "total": 1 +} +``` + +The `progress` field is only included when `total_bytes > 0`. The `error` field is only included when non-empty. + +--- + +### GET /api/v1/tasks/{task_id} — Get Task + +**Path parameter:** `task_id` — the ID returned when the task was created. + +**Response `200 OK`:** Same structure as a single task object from the list above. + +**Error responses:** +- `400 invalid_request` — no task ID in path +- `404 task_not_found` — task does not exist + +--- + +### DELETE /api/v1/tasks/{task_id} — Cancel Task + +**Path parameter:** `task_id` + +**Response `200 OK`:** + +```json +{ "message": "task cancelled successfully" } +``` + +**Error responses:** +- `400 invalid_request` — no task ID in path +- `404 task_not_found` — task does not exist +- `500 cancel_failed` — cancellation failed + +--- + +## Task Statuses + +| Status | Meaning | +|---|---| +| `queued` | Task is queued and waiting to run | +| `running` | Task is currently executing | +| `completed` | Task finished successfully | +| `failed` | Task encountered an error | +| `cancelled` | Task was cancelled via the DELETE endpoint | + +--- + +## Webhook Callbacks + +When a `webhook` URL is provided in the create request, SaveAny-Bot sends a `POST` request to that URL when the task reaches a terminal state (`completed`, `failed`, or `cancelled`). + +**Callback request headers:** + +``` +Content-Type: application/json +User-Agent: SaveAny-Bot/1.0 +``` + +**Callback request body:** + +```json +{ + "task_id": "abc123xyz", + "type": "directlinks", + "status": "completed", + "storage": "local", + "path": "downloads", + "completed_at": "2026-03-11T10:01:00Z", + "error": "" +} +``` + +`completed_at` is only present when status is `completed` or `failed`. `error` is only present when non-empty. + +**Retry policy:** Up to 3 attempts, with delays of 1s, 2s, and 3s between retries. Each request has a 30-second timeout. diff --git a/docs/content/en/usage/aria2.md b/docs/content/en/usage/aria2.md new file mode 100644 index 0000000..eead799 --- /dev/null +++ b/docs/content/en/usage/aria2.md @@ -0,0 +1,41 @@ +--- +title: "Aria2 Download" +weight: 6 +--- + +# Aria2 Download + +{{< hint warning >}} +This feature requires enabling Aria2 in the configuration file and configuring the RPC connection. +{{< /hint >}} + +Use the `/aria2dl` command to download files via the Aria2 download manager, supporting HTTP/HTTPS, FTP, BitTorrent, and other protocols. + +```bash +/aria2dl [uri2] [uri3] ... +``` + +Examples: + +```bash +# Download HTTP link +/aria2dl https://example.com/file.zip + +# Download magnet link +/aria2dl magnet:?xt=urn:btih:... + +# Download torrent file (need to upload .torrent file first) +/aria2dl https://example.com/file.torrent +``` + +Configure Aria2: + +Add to `config.toml`: + +```toml +[aria2] +enable = true +url = "http://localhost:6800/jsonrpc" +secret = "your-rpc-secret" # If rpc-secret is configured +remove_after_transfer = true # Remove local files after transfer +``` diff --git a/docs/content/en/usage/directlinks.md b/docs/content/en/usage/directlinks.md new file mode 100644 index 0000000..56f04ba --- /dev/null +++ b/docs/content/en/usage/directlinks.md @@ -0,0 +1,21 @@ +--- +title: "Direct Download Links" +weight: 5 +--- + +# Direct Download Links + +Use the `/dl` command to directly download one or more HTTP/HTTPS files to storage. + +```bash +/dl [url2] [url3] ... +``` + +Examples: + +```bash +/dl https://example.com/file.zip +/dl https://example.com/file1.zip https://example.com/file2.zip +``` + +The bot will validate the link format and then ask you to select the target storage location. diff --git a/docs/content/en/usage/parsers.md b/docs/content/en/usage/parsers.md new file mode 100644 index 0000000..e256ad0 --- /dev/null +++ b/docs/content/en/usage/parsers.md @@ -0,0 +1,15 @@ +--- +title: "Save Files Outside Telegram" +weight: 9 +--- + +# Save Files Outside Telegram + +Besides files on Telegram, the bot can also save files from other websites via JavaScript plugins or built-in parsers. + +> See the [Contributing Parsers](../contribute) document for details. + +Just send links that match the requirements of a parser to the bot. Currently built-in parsers include: + +- Twitter +- Kemono diff --git a/docs/content/en/usage/rules.md b/docs/content/en/usage/rules.md new file mode 100644 index 0000000..06e0f75 --- /dev/null +++ b/docs/content/en/usage/rules.md @@ -0,0 +1,58 @@ +--- +title: "Storage Rules" +weight: 3 +--- + +# Storage Rules + +Storage rules allow you to define redirection rules when the bot uploads files to storage, so that saved files are automatically organized. + +See: #28 + +Currently supported rule types: + +1. FILENAME-REGEX +2. MESSAGE-REGEX +3. IS-ALBUM + +Basic syntax for adding rules: + +"RuleType RuleContent StorageName Path" + +Pay attention to spaces; the bot can only parse correctly formatted syntax. Below is an example of a valid rule command: + +``` +/rule add FILENAME-REGEX (?i)\.(mp4|mkv|ts|avi|flv)$ MyAlist /videos +``` + +In addition, if `CHOSEN` is used as the storage name in the rule, it means files will be stored under the path of the storage you selected by clicking the inline button. + +Rule types: + +## FILENAME-REGEX + +Matches based on filename regex. The rule content must be a valid regular expression, such as: + +``` +FILENAME-REGEX (?i)\.(mp4|mkv|ts|avi|flv)$ MyAlist /videos +``` + +This means files with extensions mp4, mkv, ts, avi, flv will be saved to the `/videos` directory in the storage named `MyAlist` (also affected by the `base_path` in the configuration file). + +## MESSAGE-REGEX + +Similar to the above, but matches based on the text content of the message itself. + +## IS-ALBUM + +Matches album messages (media groups). Rule content can only be `true` or `false`. + +If the path in the rule uses `NEW-FOR-ALBUM`, the bot will create a new folder for each media group and store all files of that group there. See: https://github.com/krau/SaveAny-Bot/issues/87 + +For example: + +``` +IS-ALBUM true MyWebdav NEW-FOR-ALBUM +``` + +This will save media-group messages to the storage named `MyWebdav`, creating a new folder (generated from the first file) for each album. diff --git a/docs/content/en/usage/silent.md b/docs/content/en/usage/silent.md new file mode 100644 index 0000000..fcd84c9 --- /dev/null +++ b/docs/content/en/usage/silent.md @@ -0,0 +1,14 @@ +--- +title: "Silent Mode" +weight: 2 +--- + +# Silent Mode (silent) + +Use the `/silent` command to toggle silent mode. + +By default, silent mode is off, and the bot will ask you for the save location of each file. + +When silent mode is enabled, the bot will save files directly to the default location without confirmation. + +Before enabling silent mode, you need to set the default save location using the `/storage` command. diff --git a/docs/content/en/usage/transfer.md b/docs/content/en/usage/transfer.md new file mode 100644 index 0000000..64c6225 --- /dev/null +++ b/docs/content/en/usage/transfer.md @@ -0,0 +1,50 @@ +--- +title: "Storage Transfer" +weight: 8 +--- + +# Storage Transfer + +Use the `/transfer` command to transfer files directly between different storages without going through Telegram. + +```bash +/transfer :/ [filter] +``` + +Parameters: + +- `source_storage`: Source storage name +- `source_path`: Source path +- `filter`: Optional regex filter to transfer only matching files + +Examples: + +```bash +# Transfer entire directory +/transfer local1:/downloads + +# Transfer files from specified path +/transfer alist1:/media/photos + +# Transfer only mp4 files +/transfer webdav1:/videos ".*\.mp4$" + +# Transfer image files +/transfer local1:/pictures "(?i)\.(jpg|png|gif)$" +``` + +The bot will: + +1. List all files in the source path +2. Apply the filter (if provided) +3. Display file count and total size +4. Ask you to select the target storage +5. Ask you to select the target directory (if configured for that storage) +6. Start the transfer task + +Notes: + +- Source storage must support listing and reading +- Target storage must support writing +- Real-time progress is displayed during transfer +- Transfer tasks can be cancelled diff --git a/docs/content/en/usage/watch.md b/docs/content/en/usage/watch.md new file mode 100644 index 0000000..b4b22af --- /dev/null +++ b/docs/content/en/usage/watch.md @@ -0,0 +1,36 @@ +--- +title: "Watch Chats" +weight: 4 +--- + +# Watch Chats + +{{< hint warning >}} +This feature requires enabling UserBot integration. +{{< /hint >}} + +You can watch messages in a specific chat and automatically save them to the default storage, following storage rules. You can also add filters so that only matching messages are saved. + +Watch a chat: + +``` +/watch [filter] +``` + +Stop watching: + +``` +/unwatch +``` + +Filter types: + +## msgre + +Regex-match the message text. For example: + +``` +/watch 12345678 msgre:.*hello.* +``` + +This will watch the chat with ID `12345678`, and only save messages whose text contains `hello`. diff --git a/docs/content/en/usage/ytdlp.md b/docs/content/en/usage/ytdlp.md new file mode 100644 index 0000000..9e5b826 --- /dev/null +++ b/docs/content/en/usage/ytdlp.md @@ -0,0 +1,40 @@ +--- +title: "yt-dlp Video Download" +weight: 7 +--- + +# yt-dlp Video Download + +{{< hint warning >}} +This feature requires the yt-dlp command-line tool installed on your system. +{{< /hint >}} + +Use the `/ytdlp` command to download videos and audio from supported video websites, including YouTube, Bilibili, Twitter, and 1000+ other sites. + +```bash +/ytdlp [url2] [flags...] +``` + +Examples: + +```bash +# Basic download +/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ + +# Download multiple videos +/ytdlp https://www.youtube.com/watch?v=video1 https://www.youtube.com/watch?v=video2 + +# Use custom parameters +/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ -f best +/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ --extract-audio --audio-format mp3 +``` + +Common parameters: + +- `-f `: Specify download format (e.g., `best`, `worst`, `bestvideo+bestaudio`) +- `--extract-audio`: Extract audio +- `--audio-format `: Audio format (e.g., `mp3`, `m4a`, `wav`) +- `--write-sub`: Download subtitles +- `--write-thumbnail`: Download thumbnail + +For more parameters, see [yt-dlp documentation](https://github.com/yt-dlp/yt-dlp#usage-and-options). diff --git a/docs/content/zh/usage/_index.md b/docs/content/zh/usage/_index.md index f41a83d..93e906c 100644 --- a/docs/content/zh/usage/_index.md +++ b/docs/content/zh/usage/_index.md @@ -13,248 +13,4 @@ weight: 10 1. 文件或媒体消息, 如图片, 视频, 文档等 2. Telegram 消息链接, 例如: `https://t.me/acherkrau/1097`. **即使频道禁止了转发和保存, Bot 依然可以下载其文件.** -3. Telegra.ph 的文章链接, Bot 将下载其中的所有图片 - -## 静默模式 (silent) - -使用 `/silent` 命令可以开关静默模式. - -默认情况下不开启静默模式, Bot 会询问你每个文件的保存位置. - -开启静默模式后, Bot 会直接保存文件到默认位置, 无需确认. - -在开启静默模式之前, 需要使用 `/storage` 命令设置默认保存位置. - -## 存储规则 - -允许你为 Bot 在上传文件到存储时设置一些重定向规则, 用于自动整理所保存的文件. - -见: #28 - -目前支持的规则类型: - -1. FILENAME-REGEX -2. MESSAGE-REGEX -3. IS-ALBUM - -添加规则的基本语法: - -"规则类型 规则内容 存储名 路径" - -注意空格的使用, 语法正确 bot 才能解析, 以下是一条合法的添加规则命令: - -``` -/rule add FILENAME-REGEX (?i)\.(mp4|mkv|ts|avi|flv)$ MyAlist /视频 -``` - -此外, 规则中的存储名若使用 "CHOSEN" , 则表示存储到点击按钮选择的存储端的路径下 - -规则类型: - -### FILENAME-REGEX - -根据文件名正则匹配, 规则内容要求为一个合法的正则表达式, 如 - -``` -FILENAME-REGEX (?i)\.(mp4|mkv|ts|avi|flv)$ MyAlist /视频 -``` - -表示将文件名后缀为 mp4,mkv,ts,avi,flv 的文件放到名为 MyAlist 存储下的 /视频 目录内 (同时受配置文件中的 `base_path` 影响) - -### MESSAGE-REGEX - -同上, 但是是根据消息本身的文本内容正则匹配 - -### IS-ALBUM - -匹配相册消息 (media group), 规则内容只能为 `true` 或 `false`. - -规则中的路径若使用 "NEW-FOR-ALBUM" , 则表示为该组消息新建一个文件夹来存储它们. 见: https://github.com/krau/SaveAny-Bot/issues/87 - -例如: - -``` -IS-ALBUM true MyWebdav NEW-FOR-ALBUM -``` - -这将会把以 media group 形式发送的消息保存到名为 MyWebdav 的存储下, 并为每个相册新建一个文件夹(由第一个文件生成)来存储它们. - - -## 监听聊天 - -{{< hint warning >}} -该功能需开启 UserBot 集成. -{{< /hint >}} - -监听指定聊天的消息, 并自动保存到默认存储中, 遵从存储规则, 并且可以设置过滤器来只保存匹配的消息. - -监听聊天: - -``` -/watch [filter] -``` - -取消监听: - -``` -/unwatch -``` - -过滤器类型: - -### msgre - -正则匹配消息文本, 例如: - -``` -/watch 12345678 msgre:.*hello.* -``` - -这将会监听 ID 为 12345678 的聊天, 并且只保存消息文本中包含 "hello" 的消息. - -## 直接下载链接 - -使用 `/dl` 命令可以直接下载一个或多个 HTTP/HTTPS 链接的文件到存储中. - -```bash -/dl [url2] [url3] ... -``` - -示例: - -```bash -/dl https://example.com/file.zip -/dl https://example.com/file1.zip https://example.com/file2.zip -``` - -Bot 会验证链接格式, 然后让你选择目标存储位置. - -## Aria2 下载 - -{{< hint warning >}} -该功能需要在配置文件中启用 Aria2 并配置 RPC 连接. -{{< /hint >}} - -使用 `/aria2dl` 命令可以通过 Aria2 下载管理器下载文件, 支持 HTTP/HTTPS、FTP、BitTorrent 等多种协议. - -```bash -/aria2dl [uri2] [uri3] ... -``` - -示例: - -```bash -# 下载 HTTP 链接 -/aria2dl https://example.com/file.zip - -# 下载磁力链接 -/aria2dl magnet:?xt=urn:btih:... - -# 下载种子文件 (需要先上传 .torrent 文件) -/aria2dl https://example.com/file.torrent -``` - -配置 Aria2: - -在 `config.toml` 中添加: - -```toml -[aria2] -enable = true -url = "http://localhost:6800/jsonrpc" -secret = "your-rpc-secret" # 如果配置了 rpc-secret -remove_after_transfer = true # 转存完成后删除本地文件 -``` - -## yt-dlp 视频下载 - -{{< hint warning >}} -该功能需要在系统中安装 yt-dlp 命令行工具. -{{< /hint >}} - -使用 `/ytdlp` 命令可以下载支持的视频网站的视频和音频, 支持 YouTube、Bilibili、Twitter 等 1000+ 个网站. - -```bash -/ytdlp [url2] [flags...] -``` - -示例: - -```bash -# 基本下载 -/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ - -# 下载多个视频 -/ytdlp https://www.youtube.com/watch?v=video1 https://www.youtube.com/watch?v=video2 - -# 使用自定义参数 -/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ -f best -/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ --extract-audio --audio-format mp3 -``` - -常用参数: - -- `-f `: 指定下载格式 (如 `best`, `worst`, `bestvideo+bestaudio`) -- `--extract-audio`: 提取音频 -- `--audio-format `: 音频格式 (如 `mp3`, `m4a`, `wav`) -- `--write-sub`: 下载字幕 -- `--write-thumbnail`: 下载缩略图 - -更多参数请参考 [yt-dlp 文档](https://github.com/yt-dlp/yt-dlp#usage-and-options). - -## 存储间传输 - -使用 `/transfer` 命令可以在不同存储之间直接传输文件, 无需经过 Telegram. - -```bash -/transfer :/ [filter] -``` - -参数说明: - -- `source_storage`: 源存储名称 -- `source_path`: 源路径 -- `filter`: 可选的正则表达式过滤器, 只传输匹配的文件 - -示例: - -```bash -# 传输整个目录 -/transfer local1:/downloads - -# 传输指定路径的文件 -/transfer alist1:/media/photos - -# 只传输 mp4 文件 -/transfer webdav1:/videos ".*\.mp4$" - -# 传输图片文件 -/transfer local1:/pictures "(?i)\.(jpg|png|gif)$" -``` - -Bot 会: - -1. 列出源路径下的所有文件 -2. 应用过滤器 (如果提供) -3. 显示文件数量和总大小 -4. 让你选择目标存储 -5. 让你选择目标目录 (如果该存储配置了目录) -6. 开始传输任务 - -注意: - -- 源存储必须支持列举和读取功能 -- 目标存储必须支持写入功能 -- 传输过程显示实时进度 -- 支持取消正在进行的传输任务 - -## 转存 Telegram 之外的文件 - -除了 Telegram 上的文件, Bot 还可通过 JavaScript 插件或内置解析器来支持转存其他网站的文件. - -> 查看[贡献解析器](../contribute)文档了解详情 - -只需向 Bot 发送符合解析器要求的链接即可使用, 当前内置的解析器: - -- Twitter -- Kemono \ No newline at end of file +3. Telegra.ph 的文章链接, Bot 将下载其中的所有图片 \ No newline at end of file diff --git a/docs/content/zh/usage/api.md b/docs/content/zh/usage/api.md new file mode 100644 index 0000000..f047f90 --- /dev/null +++ b/docs/content/zh/usage/api.md @@ -0,0 +1,442 @@ +--- +title: "HTTP API" +weight: 20 +--- + +# HTTP API + +SaveAny-Bot 提供了一套 HTTP API,允许你通过程序化方式创建下载/转存任务、查询任务状态、取消任务等,无需通过 Telegram 操作。 + +## 启用 API + +在 `config.toml` 中添加或修改以下配置: + +```toml +[api] +enable = true +host = "0.0.0.0" # 监听地址,默认 0.0.0.0 +port = 8080 # 监听端口,默认 8080 +token = "your-token" # 鉴权 Token,强烈建议设置 +``` + +也可通过环境变量覆盖(前缀 `SAVEANY_`): + +| 环境变量 | 对应配置项 | +|---|---| +| `SAVEANY_API_ENABLE` | `api.enable` | +| `SAVEANY_API_HOST` | `api.host` | +| `SAVEANY_API_PORT` | `api.port` | +| `SAVEANY_API_TOKEN` | `api.token` | + +{{< hint warning >}} +若 `token` 为空,API 服务将**不进行任何鉴权**即可访问,存在安全风险。 +{{< /hint >}} + +## 鉴权 + +当配置了 `token` 时,所有 API 请求均需在 HTTP 请求头中携带 Bearer Token: + +``` +Authorization: Bearer +``` + +鉴权失败时返回 `401`: + +```json +{ "error": "unauthorized", "message": "invalid token" } +``` + +## 错误响应格式 + +所有错误均使用统一的 JSON 格式: + +```json +{ + "error": "error_code", + "message": "错误说明" +} +``` + +常见错误码: + +| 错误码 | HTTP 状态 | 含义 | +|---|---|---| +| `unauthorized` | 401 | 鉴权失败 | +| `method_not_allowed` | 405 | HTTP 方法不正确 | +| `invalid_request` | 400 | 请求体/参数非法 | +| `task_creation_failed` | 400 | 任务创建失败 | +| `task_not_found` | 404 | 任务 ID 不存在 | +| `cancel_failed` | 500 | 取消任务失败 | +| `internal_error` | 500 | 服务器内部错误 | + +--- + +## 接口列表 + +### GET /health — 健康检查 + +无需鉴权。 + +**响应 `200 OK`:** + +```json +{ "status": "ok" } +``` + +--- + +### GET /api/v1/storages — 列出存储 + +返回当前所有已加载的存储后端。 + +**响应 `200 OK`:** + +```json +{ + "storages": [ + { "name": "local", "type": "local" }, + { "name": "MyMinio", "type": "s3" } + ] +} +``` + +--- + +### GET /api/v1/task-types — 列出支持的任务类型 + +**响应 `200 OK`:** + +```json +{ + "types": [ + "directlinks", + "ytdlp", + "aria2", + "parseditem", + "tgfiles", + "tphpics", + "transfer" + ] +} +``` + +--- + +### POST /api/v1/tasks — 创建任务 + +**请求头:** + +``` +Content-Type: application/json +Authorization: Bearer +``` + +**请求体:** + +```json +{ + "type": "<任务类型>", + "storage": "<存储名>", + "path": "<子目录>", + "webhook": "<回调URL>", + "params": { } +} +``` + +| 字段 | 类型 | 必填 | 说明 | +|---|---|---|---| +| `type` | string | 是 | 任务类型,见下文 | +| `storage` | string | 是 | 目标存储名,须与配置中的存储名一致 | +| `path` | string | 否 | 存储内的子目录路径 | +| `webhook` | string | 否 | 任务完成/失败时的回调地址 | +| `params` | object | 是 | 各任务类型的专属参数,见下文 | + +**响应 `201 Created`:** + +```json +{ + "task_id": "abc123xyz", + "type": "directlinks", + "status": "queued", + "created_at": "2026-03-11T10:00:00Z" +} +``` + +#### 任务类型与 params + +##### directlinks — 直接下载链接 + +下载一个或多个 HTTP/HTTPS 直链文件。 + +```json +{ + "type": "directlinks", + "storage": "local", + "path": "downloads", + "params": { + "urls": [ + "https://example.com/file.zip", + "https://example.com/other.zip" + ] + } +} +``` + +| params 字段 | 类型 | 必填 | 说明 | +|---|---|---|---| +| `urls` | []string | 是 | 下载地址列表,至少 1 条 | + +##### ytdlp — yt-dlp 视频下载 + +{{< hint warning >}} +需要在系统中安装 yt-dlp。 +{{< /hint >}} + +通过 yt-dlp 下载视频/音频,支持 YouTube、Bilibili 等 1000+ 网站。 + +```json +{ + "type": "ytdlp", + "storage": "local", + "path": "videos", + "params": { + "urls": ["https://www.youtube.com/watch?v=xxx"], + "flags": ["--extract-audio", "--audio-format", "mp3"] + } +} +``` + +| params 字段 | 类型 | 必填 | 说明 | +|---|---|---|---| +| `urls` | []string | 是 | 媒体链接列表,至少 1 条 | +| `flags` | []string | 否 | 额外的 yt-dlp 命令行参数 | + +##### aria2 — Aria2 下载 + +{{< hint warning >}} +需要在配置文件中启用并配置 Aria2 RPC。 +{{< /hint >}} + +通过 Aria2 下载管理器下载文件,支持 HTTP/HTTPS、FTP、BitTorrent(磁力链接、种子)等协议。 + +```json +{ + "type": "aria2", + "storage": "local", + "path": "downloads", + "params": { + "urls": ["magnet:?xt=urn:btih:..."], + "options": { "split": "4" } + } +} +``` + +| params 字段 | 类型 | 必填 | 说明 | +|---|---|---|---| +| `urls` | []string | 是 | 下载地址列表,至少 1 条 | +| `options` | map[string]string | 否 | Aria2 下载选项 | + +##### parseditem — 解析器下载 + +将 URL 交由已注册的 JS 插件或内置解析器处理后下载。 + +```json +{ + "type": "parseditem", + "storage": "local", + "path": "parsed", + "params": { + "url": "https://some-site.com/page" + } +} +``` + +| params 字段 | 类型 | 必填 | 说明 | +|---|---|---|---| +| `url` | string | 是 | 待解析的页面 URL | + +若没有任何解析器能处理该 URL,则返回 `400 task_creation_failed`。 + +##### tgfiles — Telegram 消息文件下载 + +通过 Telegram 消息链接下载文件。支持以下链接格式: + +- `https://t.me/username/123` — 公开频道/群组 +- `https://t.me/c/123456789/123` — 私有频道(数字 ID) +- `https://t.me/c/123456789/111/456` — 话题消息 +- `https://t.me/username/111/456` — 用户名频道下的话题消息 + +若消息属于媒体组(相册),默认下载整组文件。在链接末尾追加 `?single` 可强制只下载单条消息的文件。 + +```json +{ + "type": "tgfiles", + "storage": "local", + "path": "telegram", + "params": { + "message_links": [ + "https://t.me/username/123", + "https://t.me/c/1234567890/456" + ] + } +} +``` + +| params 字段 | 类型 | 必填 | 说明 | +|---|---|---|---| +| `message_links` | []string | 是 | Telegram 消息链接列表,至少 1 条 | + +##### tphpics — Telegraph 文章图片下载 + +下载 Telegra.ph 文章中的所有图片。 + +支持的链接前缀:`https://telegra.ph/`、`http://telegra.ph/`、`https://telegraph.co/`、`http://telegraph.co/` + +```json +{ + "type": "tphpics", + "storage": "local", + "path": "telegraph", + "params": { + "telegraph_url": "https://telegra.ph/Some-Article-01-01" + } +} +``` + +| params 字段 | 类型 | 必填 | 说明 | +|---|---|---|---| +| `telegraph_url` | string | 是 | Telegra.ph 文章 URL | + +##### transfer — 存储间文件传输 + +在两个存储后端之间直接传输文件,无需经过 Telegram。源存储须支持列举(list)和读取(read)操作。 + +{{< hint info >}} +`transfer` 任务中,顶层的 `storage` 字段仍然必须填写(用于通过参数校验),但实际使用的存储由 `params` 中的 `source_storage` 和 `target_storage` 决定。 +{{< /hint >}} + +```json +{ + "type": "transfer", + "storage": "local", + "params": { + "source_storage": "MyS3", + "source_path": "backups/", + "target_storage": "LocalDisk", + "target_path": "restored/" + } +} +``` + +| params 字段 | 类型 | 必填 | 说明 | +|---|---|---|---| +| `source_storage` | string | 是 | 源存储名 | +| `source_path` | string | 是 | 源存储中的路径,须包含至少一个文件 | +| `target_storage` | string | 是 | 目标存储名 | +| `target_path` | string | 是 | 目标存储中的路径 | + +--- + +### GET /api/v1/tasks — 列出所有任务 + +返回所有 API 创建的任务(仅在内存中保留,重启后清空)。 + +**响应 `200 OK`:** + +```json +{ + "tasks": [ + { + "task_id": "abc123xyz", + "type": "directlinks", + "status": "running", + "title": "file.zip", + "storage": "local", + "path": "downloads", + "error": "", + "created_at": "2026-03-11T10:00:00Z", + "updated_at": "2026-03-11T10:00:05Z", + "progress": { + "total_bytes": 10485760, + "downloaded_bytes": 5242880, + "percent": 50.0 + } + } + ], + "total": 1 +} +``` + +`progress` 字段仅在 `total_bytes > 0` 时出现。`error` 字段仅在有错误时出现。 + +--- + +### GET /api/v1/tasks/{task_id} — 查询任务 + +**路径参数:** `task_id` — 创建任务时返回的 ID。 + +**响应 `200 OK`:** 同上列表中的单个任务对象。 + +**错误响应:** +- `400 invalid_request` — 路径中未提供 task_id +- `404 task_not_found` — 任务不存在 + +--- + +### DELETE /api/v1/tasks/{task_id} — 取消任务 + +**路径参数:** `task_id` + +**响应 `200 OK`:** + +```json +{ "message": "task cancelled successfully" } +``` + +**错误响应:** +- `400 invalid_request` — 路径中未提供 task_id +- `404 task_not_found` — 任务不存在 +- `500 cancel_failed` — 取消操作失败 + +--- + +## 任务状态 + +| 状态值 | 含义 | +|---|---| +| `queued` | 已入队,等待执行 | +| `running` | 正在执行 | +| `completed` | 已成功完成 | +| `failed` | 执行失败 | +| `cancelled` | 已通过 DELETE 接口取消 | + +--- + +## Webhook 回调 + +创建任务时可设置 `webhook` 字段。当任务进入终态(`completed`、`failed`、`cancelled`)时,Bot 会向该地址发送一个 `POST` 请求。 + +**回调请求头:** + +``` +Content-Type: application/json +User-Agent: SaveAny-Bot/1.0 +``` + +**回调请求体:** + +```json +{ + "task_id": "abc123xyz", + "type": "directlinks", + "status": "completed", + "storage": "local", + "path": "downloads", + "completed_at": "2026-03-11T10:01:00Z", + "error": "" +} +``` + +`completed_at` 仅在状态为 `completed` 或 `failed` 时出现。`error` 仅在有错误时出现。 + +**重试机制:** 最多重试 3 次,重试间隔依次为 1 秒、2 秒、3 秒。每次请求超时为 30 秒。 diff --git a/docs/content/zh/usage/aria2.md b/docs/content/zh/usage/aria2.md new file mode 100644 index 0000000..d4cd9e5 --- /dev/null +++ b/docs/content/zh/usage/aria2.md @@ -0,0 +1,41 @@ +--- +title: "Aria2 下载" +weight: 6 +--- + +# Aria2 下载 + +{{< hint warning >}} +该功能需要在配置文件中启用 Aria2 并配置 RPC 连接. +{{< /hint >}} + +使用 `/aria2dl` 命令可以通过 Aria2 下载管理器下载文件, 支持 HTTP/HTTPS、FTP、BitTorrent 等多种协议. + +```bash +/aria2dl [uri2] [uri3] ... +``` + +示例: + +```bash +# 下载 HTTP 链接 +/aria2dl https://example.com/file.zip + +# 下载磁力链接 +/aria2dl magnet:?xt=urn:btih:... + +# 下载种子文件 (需要先上传 .torrent 文件) +/aria2dl https://example.com/file.torrent +``` + +配置 Aria2: + +在 `config.toml` 中添加: + +```toml +[aria2] +enable = true +url = "http://localhost:6800/jsonrpc" +secret = "your-rpc-secret" # 如果配置了 rpc-secret +remove_after_transfer = true # 转存完成后删除本地文件 +``` diff --git a/docs/content/zh/usage/directlinks.md b/docs/content/zh/usage/directlinks.md new file mode 100644 index 0000000..dd41f68 --- /dev/null +++ b/docs/content/zh/usage/directlinks.md @@ -0,0 +1,21 @@ +--- +title: "直接下载链接" +weight: 5 +--- + +# 直接下载链接 + +使用 `/dl` 命令可以直接下载一个或多个 HTTP/HTTPS 链接的文件到存储中. + +```bash +/dl [url2] [url3] ... +``` + +示例: + +```bash +/dl https://example.com/file.zip +/dl https://example.com/file1.zip https://example.com/file2.zip +``` + +Bot 会验证链接格式, 然后让你选择目标存储位置. diff --git a/docs/content/zh/usage/parsers.md b/docs/content/zh/usage/parsers.md new file mode 100644 index 0000000..a44d65b --- /dev/null +++ b/docs/content/zh/usage/parsers.md @@ -0,0 +1,15 @@ +--- +title: "转存 Telegram 之外的文件" +weight: 9 +--- + +# 转存 Telegram 之外的文件 + +除了 Telegram 上的文件, Bot 还可通过 JavaScript 插件或内置解析器来支持转存其他网站的文件. + +> 查看[贡献解析器](../contribute)文档了解详情 + +只需向 Bot 发送符合解析器要求的链接即可使用, 当前内置的解析器: + +- Twitter +- Kemono diff --git a/docs/content/zh/usage/rules.md b/docs/content/zh/usage/rules.md new file mode 100644 index 0000000..0e039c7 --- /dev/null +++ b/docs/content/zh/usage/rules.md @@ -0,0 +1,58 @@ +--- +title: "存储规则" +weight: 3 +--- + +# 存储规则 + +允许你为 Bot 在上传文件到存储时设置一些重定向规则, 用于自动整理所保存的文件. + +见: #28 + +目前支持的规则类型: + +1. FILENAME-REGEX +2. MESSAGE-REGEX +3. IS-ALBUM + +添加规则的基本语法: + +"规则类型 规则内容 存储名 路径" + +注意空格的使用, 语法正确 bot 才能解析, 以下是一条合法的添加规则命令: + +``` +/rule add FILENAME-REGEX (?i)\.(mp4|mkv|ts|avi|flv)$ MyAlist /视频 +``` + +此外, 规则中的存储名若使用 "CHOSEN" , 则表示存储到点击按钮选择的存储端的路径下 + +规则类型: + +## FILENAME-REGEX + +根据文件名正则匹配, 规则内容要求为一个合法的正则表达式, 如 + +``` +FILENAME-REGEX (?i)\.(mp4|mkv|ts|avi|flv)$ MyAlist /视频 +``` + +表示将文件名后缀为 mp4,mkv,ts,avi,flv 的文件放到名为 MyAlist 存储下的 /视频 目录内 (同时受配置文件中的 `base_path` 影响) + +## MESSAGE-REGEX + +同上, 但是是根据消息本身的文本内容正则匹配 + +## IS-ALBUM + +匹配相册消息 (media group), 规则内容只能为 `true` 或 `false`. + +规则中的路径若使用 "NEW-FOR-ALBUM" , 则表示为该组消息新建一个文件夹来存储它们. 见: https://github.com/krau/SaveAny-Bot/issues/87 + +例如: + +``` +IS-ALBUM true MyWebdav NEW-FOR-ALBUM +``` + +这将会把以 media group 形式发送的消息保存到名为 MyWebdav 的存储下, 并为每个相册新建一个文件夹(由第一个文件生成)来存储它们. diff --git a/docs/content/zh/usage/silent.md b/docs/content/zh/usage/silent.md new file mode 100644 index 0000000..4361b70 --- /dev/null +++ b/docs/content/zh/usage/silent.md @@ -0,0 +1,14 @@ +--- +title: "静默模式" +weight: 2 +--- + +# 静默模式 (silent) + +使用 `/silent` 命令可以开关静默模式. + +默认情况下不开启静默模式, Bot 会询问你每个文件的保存位置. + +开启静默模式后, Bot 会直接保存文件到默认位置, 无需确认. + +在开启静默模式之前, 需要使用 `/storage` 命令设置默认保存位置. diff --git a/docs/content/zh/usage/transfer.md b/docs/content/zh/usage/transfer.md new file mode 100644 index 0000000..2041e69 --- /dev/null +++ b/docs/content/zh/usage/transfer.md @@ -0,0 +1,50 @@ +--- +title: "存储间传输" +weight: 8 +--- + +# 存储间传输 + +使用 `/transfer` 命令可以在不同存储之间直接传输文件, 无需经过 Telegram. + +```bash +/transfer :/ [filter] +``` + +参数说明: + +- `source_storage`: 源存储名称 +- `source_path`: 源路径 +- `filter`: 可选的正则表达式过滤器, 只传输匹配的文件 + +示例: + +```bash +# 传输整个目录 +/transfer local1:/downloads + +# 传输指定路径的文件 +/transfer alist1:/media/photos + +# 只传输 mp4 文件 +/transfer webdav1:/videos ".*\.mp4$" + +# 传输图片文件 +/transfer local1:/pictures "(?i)\.(jpg|png|gif)$" +``` + +Bot 会: + +1. 列出源路径下的所有文件 +2. 应用过滤器 (如果提供) +3. 显示文件数量和总大小 +4. 让你选择目标存储 +5. 让你选择目标目录 (如果该存储配置了目录) +6. 开始传输任务 + +注意: + +- 源存储必须支持列举和读取功能 +- 目标存储必须支持写入功能 +- 传输过程显示实时进度 +- 支持取消正在进行的传输任务 diff --git a/docs/content/zh/usage/watch.md b/docs/content/zh/usage/watch.md new file mode 100644 index 0000000..d2f5495 --- /dev/null +++ b/docs/content/zh/usage/watch.md @@ -0,0 +1,36 @@ +--- +title: "监听聊天" +weight: 4 +--- + +# 监听聊天 + +{{< hint warning >}} +该功能需开启 UserBot 集成. +{{< /hint >}} + +监听指定聊天的消息, 并自动保存到默认存储中, 遵从存储规则, 并且可以设置过滤器来只保存匹配的消息. + +监听聊天: + +``` +/watch [filter] +``` + +取消监听: + +``` +/unwatch +``` + +过滤器类型: + +## msgre + +正则匹配消息文本, 例如: + +``` +/watch 12345678 msgre:.*hello.* +``` + +这将会监听 ID 为 12345678 的聊天, 并且只保存消息文本中包含 "hello" 的消息. diff --git a/docs/content/zh/usage/ytdlp.md b/docs/content/zh/usage/ytdlp.md new file mode 100644 index 0000000..2b5aef8 --- /dev/null +++ b/docs/content/zh/usage/ytdlp.md @@ -0,0 +1,40 @@ +--- +title: "yt-dlp 视频下载" +weight: 7 +--- + +# yt-dlp 视频下载 + +{{< hint warning >}} +该功能需要在系统中安装 yt-dlp 命令行工具. +{{< /hint >}} + +使用 `/ytdlp` 命令可以下载支持的视频网站的视频和音频, 支持 YouTube、Bilibili、Twitter 等 1000+ 个网站. + +```bash +/ytdlp [url2] [flags...] +``` + +示例: + +```bash +# 基本下载 +/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ + +# 下载多个视频 +/ytdlp https://www.youtube.com/watch?v=video1 https://www.youtube.com/watch?v=video2 + +# 使用自定义参数 +/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ -f best +/ytdlp https://www.youtube.com/watch?v=dQw4w9WgXcQ --extract-audio --audio-format mp3 +``` + +常用参数: + +- `-f `: 指定下载格式 (如 `best`, `worst`, `bestvideo+bestaudio`) +- `--extract-audio`: 提取音频 +- `--audio-format `: 音频格式 (如 `mp3`, `m4a`, `wav`) +- `--write-sub`: 下载字幕 +- `--write-thumbnail`: 下载缩略图 + +更多参数请参考 [yt-dlp 文档](https://github.com/yt-dlp/yt-dlp#usage-and-options).