### Gopeed Default Download Configuration Example Source: https://docs.gopeed.com/install An example of setting the default download configuration within the `config.json` file. This allows specifying a default download directory when the server starts for the first time. ```json { "address": "127.0.0.1", "port": 9999, "downloadConfig": { "downloadDir": "d:/test" // Set the default download directory } } ``` -------------------------------- ### Gopeed JSON Configuration File Example Source: https://docs.gopeed.com/install An example of a `config.json` file used to configure the Gopeed web application. This file allows for setting bind address, port, authentication credentials, API token, storage directory, and download directory whitelists. ```json { "address": "", // Bind address (default "0.0.0.0") "port": 0, // Bind port (default 9999) "username": "", // HTTP Basic Auth Username (default "gopeed") "password": "", // HTTP Basic Auth Password, used with username. If both are empty, authentication is disabled "apiToken": "", // HTTP API token, when using API token without authentication enabled, the web UI is inaccessible and can only be accessed through the API "storageDir": "", // Storage directory "whiteDownloadDirs": ["/root/downloads", "/root/dir/*", "/root/dir?abc"] // Download directory whitelist, when this option is configured, all tasks downloaded to non-whitelisted folders will fail, support wildcard, rules refer to https://pkg.go.dev/path/filepath#Match } ``` -------------------------------- ### Gopeed CLI Download Magnet Link Source: https://docs.gopeed.com/install This example demonstrates how to use the Gopeed CLI to download content using a magnet link. Paste the magnet link directly as an argument to the `gopeed` command. ```shell gopeed magnet:?xt=urn:btih:xxxx ``` -------------------------------- ### Gopeed CLI Download HTTP Resource Source: https://docs.gopeed.com/install This is an example of using the Gopeed CLI to download an HTTP resource. Simply provide the URL of the file you want to download as an argument to the `gopeed` command. ```shell gopeed https://example.com/file.zip ``` -------------------------------- ### Gopeed CLI Download Torrent File Source: https://docs.gopeed.com/install This example shows how to use the Gopeed CLI to download a torrent file. Provide the local path to the `.torrent` file as an argument to the `gopeed` command. ```shell gopeed D:/Downloads/file.torrent ``` -------------------------------- ### Run Gopeed Docker Container Source: https://docs.gopeed.com/install This command runs the Gopeed Docker container with the specified name and port mapping. It's the most basic way to start Gopeed. Ensure the port 9999 is available on your host machine. ```shell docker run --name gopeed -d -p 9999:9999 liwei2633/gopeed ``` -------------------------------- ### Install Gopeed using Snap on Linux Source: https://docs.gopeed.com/install Installs Gopeed on Linux systems using the Snap package manager. This command downloads and installs the Gopeed package from the Snap Store, ensuring easy installation and updates. ```sh sudo snap install gopeed ``` -------------------------------- ### Gopeed CLI Help Source: https://docs.gopeed.com/install This command displays the help information for the Gopeed CLI, including available options and their default values. It shows how to configure concurrent connections and the download store directory. ```shell $ gopeed -h Usage of gopeed: -C int Concurrent connections. (default 16) -D string Store directory. (default "C:\\Users\\levi") ``` -------------------------------- ### Install and Build Project Dependencies Source: https://docs.gopeed.com/site/reference/index Installs project dependencies using pnpm and then builds the project. This is a common step for setting up and compiling the Javascript monorepo. ```shell pnpm install pnpm run build ``` -------------------------------- ### View Gopeed Command Line Help Source: https://docs.gopeed.com/install Displays the available command-line parameters for the Gopeed executable. This is useful for understanding all configurable options and their default values. ```shell #!/bin/bash ./gopeed.exe -h ``` -------------------------------- ### Install Gopeed Command Line Tool Source: https://docs.gopeed.com/install This command installs the Gopeed command-line interface (CLI) tool using Go modules. It requires a Go environment to be installed on your system. This command fetches the latest version of the Gopeed CLI. ```shell go install github.com/GopeedLab/gopeed/cmd/gopeed@latest ``` -------------------------------- ### Task Status Examples Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.Task Provides examples of possible string values for the 'status' property of the Task interface. ```string "ready" ``` ```string "running" ``` -------------------------------- ### Install Gopeed using Flatpak on Linux Source: https://docs.gopeed.com/install Installs Gopeed on Linux systems using the Flatpak package manager. This command installs Gopeed from the Flathub repository, providing a sandboxed and consistent installation experience. ```sh flatpak install flathub com.gopeed.Gopeed ``` -------------------------------- ### Install Gopeed using Scoop on Windows Source: https://docs.gopeed.com/install Installs or upgrades Gopeed using the Scoop package manager on Windows. This method is convenient for users who prefer command-line package management. It requires adding the 'extras' bucket first. ```powershell scoop bucket add extras scoop install extras/gopeed ``` -------------------------------- ### Configure Gopeed via Environment Variables Source: https://docs.gopeed.com/install Demonstrates how to configure Gopeed using environment variables. Each configuration option from the JSON file has a corresponding `GOPEED_` prefixed environment variable. ```shell #!/bin/bash export GOPEED_ADDRESS="0.0.0.0" export GOPEED_PORT="9999" export GOPEED_USERNAME="gopeed" export GOPEED_PASSWORD="xxx" export GOPEED_APITOKEN="" export GOPEED_STORAGEDIR="" export GOPEED_WHITEDOWNLOADDIRS="/root/downloads,/root/dir/*,/root/dir?abc" ``` -------------------------------- ### Run Gopeed Docker with Download and Storage Mounts Source: https://docs.gopeed.com/install This command runs the Gopeed Docker container, mounting both the download directory and a storage directory from the host. This is useful for managing downloaded files and application data separately. Adjust `/path/to/download` and `/path/to/storage` as needed. ```shell docker run --name gopeed -d -p 9999:9999 \ -v /path/to/download:/app/Downloads \ -v /path/to/storage:/app/storage liwei2633/gopeed ``` -------------------------------- ### Task Timestamp Example Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.Task An example of the string format for the 'createdAt' and 'updatedAt' properties of the Task interface, following ISO 8601 format. ```string "2023-03-04T19:11:01.8468886+08:00" ``` -------------------------------- ### Install Gopeed using Winget on Windows Source: https://docs.gopeed.com/install Installs Gopeed using Winget, Microsoft's official package manager for Windows. This command ensures that Gopeed is installed with the correct ID, facilitating easy updates and management. ```powershell winget install -e --id monkeyWie.Gopeed ``` -------------------------------- ### BtReqExtra Interface Example (JSON) Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.BtReqExtra An example demonstrating the structure of the BtReqExtra interface in JSON format. This interface is used to provide additional configuration for BitTorrent requests, such as specifying tracker URLs. ```json { "trackers": ["udp://tracker.opentrackr.org:1337/announce"] } ``` -------------------------------- ### Install Gopeed JS SDK Source: https://docs.gopeed.com/dev-api Installs the official JavaScript SDK for Gopeed. This library allows for programmatic interaction with the Gopeed API. ```bash npm install @gopeed/rest ``` -------------------------------- ### Resolve Download Source: https://docs.gopeed.com/site/reference/classes/_gopeed_rest.Client Resolves a download request, typically used to get download links or information before starting a download. ```APIDOC ## Resolve Download ### `resolve(request: CreateResolve): Promise` Resolves a download request to get download information. #### Parameters * **request** (CreateResolve) - Required - The request object containing details for resolving the download. ``` -------------------------------- ### Run Gopeed Docker with Download Directory Mount Source: https://docs.gopeed.com/install This command runs the Gopeed Docker container and mounts a host directory to the container's download path. This allows Gopeed to save downloaded files to a persistent location on your host system. Replace `/path/to/download` with your desired host directory. ```shell docker run --name gopeed -d -p 9999:9999 \ -v /path/to/download:/app/Downloads \ liwei2633/gopeed ``` -------------------------------- ### FileInfo Interface Example (JSON) Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.FileInfo An example demonstrating the structure of the FileInfo interface, used to represent file details such as name, path, and size. This is a common data structure for file-related operations within the Gopeed ecosystem. ```json { "name": "file.mp4", "path": "", "size": 1024 } ``` -------------------------------- ### Task Management - Get Source: https://docs.gopeed.com/site/reference/classes/_gopeed_rest.Client Methods for retrieving task information, including individual tasks, statistics, and lists of tasks. ```APIDOC ## Get Task ### `getTask(id: string): Promise` Retrieves information for a specific task. #### Parameters * **id** (string) - Required - The ID of the task to retrieve. ### `getTaskStats(id: string): Promise` Retrieves statistics for a specific task. #### Parameters * **id** (string) - Required - The ID of the task to get statistics for. ### `getTasks(id?: string[], status?: TaskStatus[], notStatus?: TaskStatus[]): Promise` Retrieves a list of tasks, with optional filtering by ID, status, or exclusion of status. #### Parameters * **id** (string[]) - Optional - An array of task IDs to retrieve. * **status** (TaskStatus[]) - Optional - An array of task statuses to filter by. * **notStatus** (TaskStatus[]) - Optional - An array of task statuses to exclude. ``` -------------------------------- ### Install Gopeed Python SDK Source: https://docs.gopeed.com/dev-api Installs the Python SDK for Gopeed, provided by a community user. This SDK facilitates interaction with the Gopeed API from Python applications. ```bash pip install gospeed_api ``` -------------------------------- ### Run Gopeed Docker with Authentication Source: https://docs.gopeed.com/install This command runs the Gopeed Docker container and enables identity authentication by setting the username and password environment variables. It also includes volume mounts for downloads and storage. Ensure you replace `admin` and `123` with your desired credentials. ```shell docker run --name gopeed -d -p 9999:9999 \ -e GOPEED_USERNAME="admin" \ -e GOPEED_PASSWORD="123" \ -v /path/to/download:/app/Downloads \ -v /path/to/storage:/app/storage \ liwei2633/gopeed ``` -------------------------------- ### Create Gopeed Extension Project (CLI) Source: https://docs.gopeed.com/dev-extension Uses npx to create a new Gopeed extension project with a Webpack template. This command initializes a project structure and installs necessary dependencies, providing commands for development and building. ```sh npx create-gopeed-ext@latest ``` -------------------------------- ### HttpReqExtra Interface Example (JSON) Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.HttpReqExtra An example demonstrating the structure of the HttpReqExtra interface in JSON format. This interface is used to provide extra options for HTTP requests, including method, headers, and body. ```json { "method": "GET", "header": { "Cookie": "xxx" } } ``` -------------------------------- ### Run Gopeed Docker with PGID and PUID Source: https://docs.gopeed.com/install This command runs the Gopeed Docker container and sets the container's process group ID (PGID) and user ID (PUID). This is important for managing file permissions when using volume mounts. Replace `100` and `1000` with your desired IDs. ```shell docker run --name gopeed -d -p 9999:9999 \ -e PGID=100 \ -e PUID=1000 \ liwei2633/gopeed ``` -------------------------------- ### Client Constructor Source: https://docs.gopeed.com/site/reference/classes/_gopeed_rest.Client Initializes a new Gopeed Client instance. The options parameter is optional and can be used to configure the client. ```APIDOC ## Constructor ### `new Client(options?: ClientOptions): Client` Initializes a new Gopeed Client instance. #### Parameters * **options** (ClientOptions) - Optional - Configuration options for the client. ``` -------------------------------- ### Task Management - Create Source: https://docs.gopeed.com/site/reference/classes/_gopeed_rest.Client Methods for creating new download tasks, individually or in batches. ```APIDOC ## Create Task ### `createTask(request: CreateTaskWithResolveResult | CreateTaskWithRequest): Promise` Creates a new download task. #### Parameters * **request** (CreateTaskWithResolveResult | CreateTaskWithRequest) - Required - The request object containing details for the new task. ### `createTaskBatch(request: CreateTaskBatch): Promise` Creates a batch of download tasks. #### Parameters * **request** (CreateTaskBatch) - Required - The request object containing details for the batch of tasks. ``` -------------------------------- ### Options Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.Options Defines the structure for download options, allowing customization of file names, save paths, and specific file selection. ```APIDOC ## Interface Options ### Description Download options for configuring file downloads. ### Method N/A (Interface definition) ### Endpoint N/A (Interface definition) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```json { "example": "N/A (Interface definition)" } ``` ### Response #### Success Response (200) N/A (Interface definition) #### Response Example ```json { "example": "N/A (Interface definition)" } ``` ## Properties ### `Optional` extra - **extra** (HttpOptsExtra) - Optional - Download extra options. ### `Optional` name - **name** (string) - Optional - Specify the file name, if not set, use the name from resource. ### `Optional` path - **path** (string) - Optional - Specify the path to save the file, if not set, use the current directory. ### `Optional` selectFiles - **selectFiles** (number[]) - Optional - Select the index of the specified file, if not set, download all files. ``` -------------------------------- ### Download Options Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_types.Options Defines the structure for configuring download parameters, including file naming, saving paths, and specific file selection. ```APIDOC ## Interface Options ### Description Download options allow for customization of how files are downloaded. ### Method N/A (Interface Definition) ### Endpoint N/A (Interface Definition) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body ##### `Optional` extra (HttpOptsExtra) - Description: Download extra options. ##### `Optional` name (string) - Description: Specify the file name. If not set, the name is derived from the resource. ##### `Optional` path (string) - Description: Specify the path to save the file. If not set, the current directory is used. ##### `Optional` selectFiles (number[]) - Description: Select the index of the specified file. If not set, all files are downloaded. ### Request Example ```json { "name": "my_download.zip", "path": "/downloads/", "selectFiles": [0, 2], "extra": {} } ``` ### Response #### Success Response (200) N/A (Interface Definition) #### Response Example N/A (Interface Definition) ``` -------------------------------- ### Interface Options - Download Configuration Source: https://docs.gopeed.com/site/reference/interfaces/gopeed.types.Options This endpoint details the configuration options for downloads, allowing customization of file names, save paths, and file selection. ```APIDOC ## Interface Options ### Description Configuration options for downloads, including file naming, saving paths, and file selection. ### Method N/A (This describes an interface/object structure, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Request Body - **extra** (HttpOptsExtra) - Optional - Download extra options. - **name** (string) - Optional - Specify the file name, if not set, use the name from the resource. - **path** (string) - Optional - Specify the path to save the file, if not set, use the current directory. - **selectFiles** (number[]) - Optional - Select the index of the specified file, if not set, download all files. ### Request Example ```json { "name": "my_download.zip", "path": "/downloads/", "selectFiles": [0, 2, 5] } ``` ### Response #### Success Response (N/A - This describes an object structure) - **extra** (HttpOptsExtra) - Download extra options. - **name** (string) - The specified file name. - **path** (string) - The specified path to save the file. - **selectFiles** (number[]) - The selected file indices. #### Response Example ```json { "extra": {}, "name": "my_download.zip", "path": "/downloads/", "selectFiles": [0, 2, 5] } ``` ``` -------------------------------- ### Task Management - Continue Source: https://docs.gopeed.com/site/reference/classes/_gopeed_rest.Client Methods for continuing tasks, either individually or in batches. ```APIDOC ## Continue Task ### `continueTask(id: string): Promise` Continues a specific task. #### Parameters * **id** (string) - Required - The ID of the task to continue. ### `continueTasks(id?: string[], status?: TaskStatus[], notStatus?: TaskStatus[]): Promise` Continues a batch of tasks, with optional filtering by ID, status, or exclusion of status. #### Parameters * **id** (string[]) - Optional - An array of task IDs to continue. * **status** (TaskStatus[]) - Optional - An array of task statuses to filter by. * **notStatus** (TaskStatus[]) - Optional - An array of task statuses to exclude. ``` -------------------------------- ### Configure HTTP Download Extra Options (HttpOptsExtra) Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.HttpOptsExtra The HttpOptsExtra interface allows configuration of extra options for HTTP downloads. It includes settings for automatically downloading torrent files after completion and specifying the number of concurrent connections for the download. This is useful for customizing download behavior. ```json { "connections": 32 } ``` -------------------------------- ### Create Task with Gopeed JS SDK Source: https://docs.gopeed.com/dev-api Demonstrates how to create a download task using the Gopeed JavaScript SDK. It initializes a client and calls the createTask method with a download URL. ```javascript import { Client } from "@gopeed/rest"; (async function () { // Create a client const client = new Client(); // Create a task const res = await client.createTask({ req: { url: "https://example.com/file.zip", }, }); })(); ``` -------------------------------- ### Resource API Documentation Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_types.Resource Provides details on the Resource interface, its properties, and associated file information. ```APIDOC ## Resource API ### Description This API provides information about resources, which can be resolved from requests and may contain multiple files. It details the properties of a resource, including its files, hash, name, range support, and size. ### Method GET ### Endpoint /websites/gopeed/resource ### Parameters #### Query Parameters - **resource_identifier** (string) - Required - Identifier for the resource to retrieve. ### Request Example ```json { "message": "Example request for resource details" } ``` ### Response #### Success Response (200) - **files** (FileInfo[]) - Resource files list. Contains multiple files if the resource is a folder, otherwise a single file. - **hash** (string) - Optional - The hash of the resource file. - **name** (string) - Optional - The name of the resource. If not blank, it indicates a folder resource and this is the folder name. - **range** (boolean) - Whether the resource supports breakpoint continuation. - **size** (number) - The total size of the resource in bytes. #### Response Example ```json { "files": [ { "hash": "abcdef123456", "name": "example.txt", "range": true, "size": 1024 } ], "name": "MyFolder", "range": true, "size": 2048 } ``` ### Error Handling - **404 Not Found**: If the specified resource identifier does not exist. - **500 Internal Server Error**: If there is a server-side issue processing the request. ``` -------------------------------- ### CreateResolve Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.CreateResolve Details the CreateResolve interface, its hierarchy, and properties. ```APIDOC ## Interface CreateResolve ### Description Represents the options and request object for creating a resolution in Gopeed. ### Hierarchy * CreateResolve ### Properties #### `Optional` opts `opts?: Options` Download options. #### req `req: Request` Download request. ``` -------------------------------- ### CreateResolve Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_types.CreateResolve Details about the CreateResolve interface, its hierarchy, and properties. ```APIDOC ## Interface CreateResolve ### Description Represents the structure for creating a resolve function, likely used in a download or request processing context. ### Hierarchy * CreateResolve ### Properties #### `Optional` opts - **opts** (Options) - Optional - Download options. #### `Required` req - **req** (Request) - Required - Download request details. ``` -------------------------------- ### CreateTaskWithRequest Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_types.CreateTaskWithRequest Interface for creating a task with request options. ```APIDOC ## CreateTaskWithRequest ### Description Interface for creating a task with request options. ### Method (Not specified, typically POST or PUT for creation) ### Endpoint (Not specified) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **opts** (Options) - Optional - Download options - **req** (Request) - Required - Download request ### Request Example ```json { "opts": { "download_path": "/path/to/download" }, "req": { "url": "http://example.com/file.zip", "method": "GET" } } ``` ### Response #### Success Response (200) (Response structure not specified) #### Response Example ```json { "task_id": "123e4567-e89b-12d3-a456-426614174000" } ``` ``` -------------------------------- ### Storage API Source: https://docs.gopeed.com/site/reference/interfaces/gopeed.Storage This section details the methods available for interacting with the Gopeed storage. These methods allow for the management of key-value pairs within the storage. ```APIDOC ## Storage API ### Description Provides methods to manage key-value pairs in the Gopeed storage. ### Methods #### clear() ##### Description Removes all key/value pairs that match the given key. ##### Method `void` ##### Parameters None ##### Returns `void` #### get(key: string) ##### Description Returns the current value associated with the given key, or null if the key does not exist. ##### Method `string` ##### Parameters - **key** (string) - The key to retrieve the value for. ##### Returns `string` | `null` #### keys() ##### Description Returns all keys currently stored in the storage. ##### Method `string[]` ##### Parameters None ##### Returns `string[]` #### remove(key: string) ##### Description Removes the key/value pair with the given key, if it exists. ##### Method `void` ##### Parameters - **key** (string) - The key of the pair to remove. ##### Returns `void` #### set(key: string, value: string) ##### Description Sets the value of the pair identified by key to value, creating a new key/value pair if none existed. ##### Method `void` ##### Parameters - **key** (string) - The key of the pair to set. - **value** (string) - The value to associate with the key. ##### Returns `void` ``` -------------------------------- ### CreateTaskBatch Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.CreateTaskBatch Details about the CreateTaskBatch interface, its optional 'opts' and required 'reqs' properties. ```APIDOC ## CreateTaskBatch Interface ### Description Represents a batch creation request for tasks within the Gopeed library. It includes optional download options and a list of required download requests. ### Method N/A (Interface Definition) ### Endpoint N/A (Interface Definition) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **opts** (Options) - Optional - Download options for the batch. - **reqs** (Request[]) - Required - A list of download requests to be processed in the batch. ### Request Example ```json { "opts": { "download_speed_limit": 1024, "upload_speed_limit": 512 }, "reqs": [ { "url": "http://example.com/file1.zip", "path": "/downloads/file1.zip" }, { "url": "http://example.com/file2.zip", "path": "/downloads/file2.zip" } ] } ``` ### Response #### Success Response (200) This interface definition does not specify a direct response. It is used as a request payload for an API endpoint that would handle task batch creation. #### Response Example ```json { "message": "Task batch creation initiated successfully.", "batch_id": "abc123xyz789" } ``` ``` -------------------------------- ### HttpOptsExtra Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.HttpOptsExtra Details the properties available for configuring extra HTTP download options. ```APIDOC ## Interface HttpOptsExtra HTTP download extra options ### Properties #### `Optional` autoTorrent `autoTorrent?: boolean` When task download complete, and it is a .torrent file, it will be auto create a new task for the torrent file #### `Optional` connections `connections?: number` Concurrent connections ### Request Example ```json { "connections": 32 } ``` ``` -------------------------------- ### CreateTaskBatch Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_types.CreateTaskBatch Details about the CreateTaskBatch interface, its properties, and usage within the Gopeed Library. ```APIDOC ## CreateTaskBatch Interface ### Description Represents a batch creation of tasks within the Gopeed Library. ### Method N/A (This is an interface definition, not an API endpoint) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body This interface defines the structure for creating tasks in batches. - **opts** (Options) - Optional - Download options for the batch. - **reqs** (Request[]) - Required - A list of download requests to be processed in the batch. ### Request Example ```json { "opts": { "downloadLocation": "/path/to/downloads" }, "reqs": [ { "url": "http://example.com/file1.zip", "fileName": "file1.zip" }, { "url": "http://example.com/file2.zip", "fileName": "file2.zip" } ] } ``` ### Response #### Success Response (200) This interface does not directly define a response. The success response would depend on the API endpoint that utilizes this interface. #### Response Example ```json { "message": "Tasks created successfully", "taskIds": ["task123", "task456"] } ``` ``` -------------------------------- ### HttpOptsExtra Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_types.HttpOptsExtra The HttpOptsExtra interface defines additional options for HTTP downloads in Gopeed, such as concurrent connections and automatic torrent handling. ```APIDOC ## Interface HttpOptsExtra HTTP download extra options ### Properties #### `Optional` autoTorrent `autoTorrent?: boolean` When task download complete, and it is a .torrent file, it will be auto create a new task for the torrent file #### `Optional` connections `connections?: number` Concurrent connections ### Example ```json { "connections": 32 } ``` ``` -------------------------------- ### Task Interface Properties Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.Task This snippet details the properties of the Task interface, including their types and descriptions. It covers fields like createdAt, id, meta, name, progress, protocol, size, status, updatedAt, and uploading. ```typescript interface Task { createdAt: string; id: string; meta: { opts: Options; req: Request; res: Resource; }; name: string; progress: TaskProgress; protocol: Protocol; size: number; status: TaskStatus; updatedAt: string; uploading: boolean; } ``` -------------------------------- ### Manual Gopeed Extension Project Structure Source: https://docs.gopeed.com/dev-extension Illustrates the basic file structure for a manually created Gopeed extension. It requires an index.js file for logic and a manifest.json file for extension metadata. ```sh ├── index.js ├── manifest.json ``` -------------------------------- ### Request Interface Documentation Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.Request Details the structure and properties of the Request interface used for download requests in the Gopeed library. ```APIDOC ## Request Interface ### Description Represents a download request, including the URL and optional parameters like extra options and labels. ### Method N/A (This is an interface definition) ### Endpoint N/A (This is an interface definition) ### Properties #### `Optional` extra - **extra** (ReqExtra) - Optional - Extra request options. #### `Optional` labels - **labels** (object) - Optional - Request labels. The keys are strings and the values are strings. - Type declaration: `[key: string]: string` #### `Required` url - **url** (string) - Required - The URL for the download. Supports http(s), magnet links, and local torrent files. ### Request Example ```json { "url": "https://example.com/file.mp4" } ``` ### Response (This section is not applicable as it describes an interface, not an API endpoint) ### Error Handling (This section is not applicable as it describes an interface, not an API endpoint) ``` -------------------------------- ### BtReqExtra Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.BtReqExtra This section details the BtReqExtra interface, which allows for specifying extra options for BitTorrent requests, such as tracker URLs. ```APIDOC ## BtReqExtra Interface ### Description Bt request extra options. ### Properties #### Optional `trackers` - **trackers** (string[]) - Optional - Tracker url list ### Request Example ```json { "trackers": ["udp://tracker.opentrackr.org:1337/announce"] } ``` ### Response (No specific response structure defined for this interface, as it's typically used within request bodies.) Generated using TypeDoc ``` -------------------------------- ### Gopeed Settings API Source: https://docs.gopeed.com/site/reference/types/gopeed.Settings Allows retrieval and modification of Gopeed settings. ```APIDOC ## GET /websites/gopeed/settings ### Description Retrieves the current settings for the Gopeed application. ### Method GET ### Endpoint /websites/gopeed/settings ### Parameters None ### Request Example None ### Response #### Success Response (200) - **settings** (object) - An object containing key-value pairs of the current settings. The structure is dynamic and can contain any string keys with unknown values. #### Response Example { "settings": { "theme": "dark", "language": "en", "notifications": true } } ## PUT /websites/gopeed/settings ### Description Updates the settings for the Gopeed application. ### Method PUT ### Endpoint /websites/gopeed/settings ### Parameters #### Request Body - **settings** (object) - Required - An object containing the settings to update. The structure is dynamic and can contain any string keys with unknown values. ### Request Example ```json { "settings": { "theme": "light", "language": "fr" } } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the settings have been updated. #### Response Example { "message": "Settings updated successfully." } ``` -------------------------------- ### Resource API Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.Resource This section details the structure and properties of a Resource object as defined by the Gopeed Library. ```APIDOC ## Resource Object ### Description Represents a resource, which can contain multiple files. Information is resolved from the request. ### Hierarchy * Resource ### Properties #### files `files`: FileInfo[] Resource files list. This will contain multiple files only when the resource is a folder resource; otherwise, it will contain only one file. #### hash `hash?`: string Optional hash of the file. #### name `name`: string When the name is not blank, it indicates that the resource is a folder resource, and the name is the folder name. #### range `range`: boolean Indicates whether the resource supports breakpoint continuation. #### size `size`: number Total size of the resource in bytes. ``` -------------------------------- ### Request Interface Definition (TypeScript) Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_types.Request Defines the structure of a download request object. It includes optional 'extra' and 'labels' for advanced configurations and a mandatory 'url' property specifying the resource to download. Supports HTTP(S), magnet links, and local torrent files. ```typescript interface ReqExtra {} interface Request { extra?: ReqExtra; labels?: { [key: string]: string; }; url: string; } ``` -------------------------------- ### BtReqExtra Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_types.BtReqExtra Details the BtReqExtra interface, which provides extra options for BitTorrent requests, specifically the optional 'trackers' field. ```APIDOC ## BtReqExtra Interface ### Description Bt request extra options. This interface allows for additional configuration for BitTorrent requests. ### Properties #### Optional `trackers` - **trackers** (string[]) - Optional - A list of tracker URLs to be used for the BitTorrent request. ### Request Example ```json { "trackers": ["udp://tracker.opentrackr.org:1337/announce"] } ``` ### Response Example ```json { "trackers": ["udp://tracker.opentrackr.org:1337/announce"] } ``` ``` -------------------------------- ### TaskProgress Interface Definition Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.TaskProgress Defines the structure for tracking download and upload progress. It includes properties for downloaded size, current download speed, upload speed, uploaded size, and the time elapsed during the download process. ```typescript interface TaskProgress { downloaded: number; speed: number; uploadSpeed: number; uploaded: number; used: number; } ``` -------------------------------- ### Registering onResolve Event in Gopeed JavaScript Source: https://docs.gopeed.com/dev-extension This snippet demonstrates how to register an 'onResolve' event handler in a Gopeed extension script. The handler receives a context object 'ctx' and is responsible for populating 'ctx.res' with the list of files to be downloaded. It shows how to define a file with its name and request URL. ```javascript gopeed.events.onResolve((ctx) => { ctx.res = { name: "example", files: [ { name: "index.html", req: { url: "https://example.com", }, }, ], }; }); ``` -------------------------------- ### Compile Webpack Project for Gopeed Extension Source: https://docs.gopeed.com/dev-extension Compiles a webpack project created by the scaffolding for extension development. This command is typically run using npm. ```shell npm run build ``` -------------------------------- ### Gopeed Repository Configuration Source: https://docs.gopeed.com/dev-extension Defines the Git repository where the extension's source code is hosted. This is crucial for Gopeed's decentralized extension management and for enabling updates. The 'directory' attribute can specify a subdirectory if the repository contains multiple projects. ```json { "url": "https://github.com/gopeed/gopeed-extension-demo" } ``` ```json { "url": "https://github.com/GopeedLab/gopeed-extension-samples", "directory": "github-contributor-avatars-sample" } ``` -------------------------------- ### Access Extension Settings in JavaScript Source: https://docs.gopeed.com/dev-extension This JavaScript code demonstrates how to access user-defined settings within a Gopeed extension's script. It shows how to retrieve values for 'cookie' and 'quality' settings using the `gopeed.settings` object during the `onResolve` event. ```javascript gopeed.events.onResolve((ctx) => { // Access cookie setting console.log(gopeed.settings.cookie); // Access quality setting console.log(gopeed.settings.quality); }); ``` -------------------------------- ### TaskProgress Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_types.TaskProgress Details of the TaskProgress interface, including its properties and their descriptions. ```APIDOC ## Interface TaskProgress ### Description The TaskProgress interface provides information about the progress of a download or upload task. ### Properties - **downloaded** (number) - Downloaded size in bytes. - **speed** (number) - Current download speed in bytes per second. - **uploadSpeed** (number) - Current upload speed in bytes per second. - **uploaded** (number) - Uploaded size in bytes. - **used** (number) - Download usage time in nanoseconds. ### Example Usage (Conceptual) ```javascript interface TaskProgress { downloaded: number; speed: number; uploadSpeed: number; uploaded: number; used: number; } // Example of how TaskProgress might be used: function displayProgress(progress: TaskProgress) { console.log(`Downloaded: ${progress.downloaded} bytes`); console.log(`Download Speed: ${progress.speed} bytes/s`); } ``` ``` -------------------------------- ### Persist Data with Extension Storage API in JavaScript Source: https://docs.gopeed.com/dev-extension This JavaScript snippet illustrates using Gopeed's storage API to persist data, such as authentication tokens, within an extension. It shows how to retrieve a token using `gopeed.storage.get` and set it using `gopeed.storage.set` if it doesn't exist. ```javascript gopeed.events.onResolve((ctx) => { // Get the token, if it not exists, then login const token = gopeed.storage.get("token"); if(!token){ const token = await login(); gopeed.storage.set("token",token) } // Then do something with the token // ... }); ``` -------------------------------- ### Task Management - Pause Source: https://docs.gopeed.com/site/reference/classes/_gopeed_rest.Client Methods for pausing tasks, either individually or in batches. ```APIDOC ## Pause Task ### `pauseTask(id: string): Promise` Pauses a specific task. #### Parameters * **id** (string) - Required - The ID of the task to pause. ### `pauseTasks(id?: string[], status?: TaskStatus[], notStatus?: TaskStatus[]): Promise` Pauses a batch of tasks, with optional filtering by ID, status, or exclusion of status. #### Parameters * **id** (string[]) - Optional - An array of task IDs to pause. * **status** (TaskStatus[]) - Optional - An array of task statuses to filter by. * **notStatus** (TaskStatus[]) - Optional - An array of task statuses to exclude. ``` -------------------------------- ### Task Object Properties Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_types.Task This section details the properties available for a Task object in the Gopeed system. ```APIDOC ## Task Object Properties ### Description Provides detailed information about the properties of a Task object. ### Properties - **createdAt** (string) - Required - Task created time, ISO 8601 format. #### Example ``` "2023-03-04T19:11:01.8468886+08:00" ``` - **id** (string) - Required - Task ID. - **meta** (object) - Required - Task metadata. - **opts** (Options) - Options for the task. - **req** (Request) - Request details. - **res** (Resource) - Resource details. - **name** (string) - Required - Task display name. - **progress** (TaskProgress) - Required - Task progress. - **protocol** (Protocol) - Required - Protocol type. - **size** (number) - Required - Task total size in bytes. - **status** (TaskStatus) - Required - Task status. #### Example ``` "ready" ``` #### Example ``` "running" ``` - **updatedAt** (string) - Required - Task updated time, ISO 8601 format. #### Example ``` "2023-03-04T19:11:01.8468886+08:00" ``` - **uploading** (boolean) - Required - Indicates if the task is currently uploading. ``` -------------------------------- ### Logger Interface Methods Source: https://docs.gopeed.com/site/reference/interfaces/gopeed.Logger The Logger interface provides methods for different levels of logging: debug, error, info, and warn. Each method accepts an optional message and a variable number of additional parameters. ```APIDOC ## Logger Interface ### Description The Logger interface in the Gopeed library provides methods for logging messages at different severity levels. ### Methods #### debug(message?, ...optionalParams): void * **Description**: Logs a debug message. * **Parameters**: * `message` (unknown) - Optional: The main message to log. * `...optionalParams` (unknown[]) - Optional: Additional parameters to include in the log. * **Returns**: void #### error(message?, ...optionalParams): void * **Description**: Logs an error message. * **Parameters**: * `message` (unknown) - Optional: The main message to log. * `...optionalParams` (unknown[]) - Optional: Additional parameters to include in the log. * **Returns**: void #### info(message?, ...optionalParams): void * **Description**: Logs an informational message. * **Parameters**: * `message` (unknown) - Optional: The main message to log. * `...optionalParams` (unknown[]) - Optional: Additional parameters to include in the log. * **Returns**: void #### warn(message?, ...optionalParams): void * **Description**: Logs a warning message. * **Parameters**: * `message` (unknown) - Optional: The main message to log. * `...optionalParams` (unknown[]) - Optional: Additional parameters to include in the log. * **Returns**: void ### Request Example ```javascript // Example usage of the logger const logger = gopeed.logger; // Assuming logger is accessible like this logger.debug('User logged in', { userId: 123 }); logger.error('Database connection failed'); logger.info('Server started on port 8080'); logger.warn('Low disk space detected'); ``` ### Response All logger methods return `void`. ``` -------------------------------- ### Type Alias: EventOnStart (TypeScript) Source: https://docs.gopeed.com/site/reference/types/gopeed.EventOnStart Defines the EventOnStart type alias, representing a function that can be asynchronous or synchronous and takes an OnStartContext object. This is commonly used for defining startup event handlers in the Gopeed library. ```typescript type EventOnStart = (ctx: OnStartContext) => Promise | void; ``` -------------------------------- ### HttpReqExtra Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_types.HttpReqExtra The HttpReqExtra interface defines optional parameters for customizing HTTP requests, such as method, headers, and body. ```APIDOC ## Interface HttpReqExtra HTTP request extra options ### Properties #### `Optional` body `body?: string` HTTP request body #### `Optional` header `header?: HttpHeader` HTTP request header #### `Optional` method `method?: HttpMethod` HTTP request method ### Example ```json { "method": "GET", "header": { "Cookie": "xxx" } } ``` ``` -------------------------------- ### Gopeed Extension Settings Configuration Source: https://docs.gopeed.com/dev-extension Declares the settings that users can configure for the extension. Gopeed uses this to generate a settings page. It supports various types like string and number, with options for predefined choices. ```json [ { "name": "cookie", "title": "网站 Cookie", "description": "Cookie 可以通过浏览器开发者工具获取", "type": "string" }, { "name": "quality", "title": "默认画质", "type": "number", "value": "1080", "options": [ { "label": "1080P", "value": "1080" }, { "label": "720P", "value": "720" }, { "label": "480P", "value": "480" } ] } ] ``` -------------------------------- ### Gopeed Extension Manifest File (manifest.json) Source: https://docs.gopeed.com/dev-extension The manifest.json file is the core configuration file for a Gopeed extension. It describes the extension's metadata, scripts, and settings. This JSON structure is essential for Gopeed to recognize and manage the extension. ```json { "name": "gopeed-extention-demo", "author": "", "title": "gopeed extention demo title", "description": "gopeed extention demo description", "icon": "", "version": "1.0.0", "homepage": "", "repository": { "url": "" }, "scripts": [ { "event": "onResolve", "match": { "urls": ["*://github.com/*"] }, "entry": "dist/index.js" } ], "settings": [] } ``` -------------------------------- ### OnErrorContext Interface Source: https://docs.gopeed.com/site/reference/interfaces/gopeed.OnErrorContext Details the OnErrorContext interface, its hierarchy, and properties. ```APIDOC ## Interface OnErrorContext ### Hierarchy * OnErrorContext ### Properties #### error error: Error #### task task: ExtensionTask ``` -------------------------------- ### FileInfo Interface Source: https://docs.gopeed.com/site/reference/interfaces/_gopeed_rest.types.FileInfo Defines the structure for file information within the Gopeed library. ```APIDOC ## Interface FileInfo File info ### Properties - **name** (string) - Required - File name - **path** (string) - Required - File path, relative to the resource, e.g. "path/to" - **req** (Request) - Optional - Specify the request for this file - **size** (number) - Required - File size (byte) ### Example ```json { "name": "file.mp4", "path": "", "size": 1024 } ``` ``` -------------------------------- ### Define Extension Settings in JSON Source: https://docs.gopeed.com/dev-extension This JSON structure defines configuration items for a Gopeed extension, allowing users to customize settings like cookies or video quality. The 'type' field dictates the input element, and 'options' can render a dropdown for selection. ```json { "settings": [ { "name": "cookie", "title": "网站 Cookie", "description": "Cookie 可以通过浏览器开发者工具获取", "type": "string" }, { "name": "quality", "title": "默认画质", "type": "number", "value": "1080", "options": [ { "label": "1080P", "value": "1080" }, { "label": "720P", "value": "720" }, { "label": "480P", "value": "480" } ] } ] } ```