Sign inSign up

kevinwang15/qb-scripts

By kevinwang15

•Updated almost 2 years ago

Image
0

867

kevinwang15/qb-scripts repository overview

⁠qb-scripts

qb-scripts is a collection of Node.js scripts designed to enhance and automate various tasks related to qBittorrent. These scripts provide functionality for managing upload limits, purging download directories, and interacting with the qBittorrent Web API.

⁠Features

  • Auto Upload Limiter: Automatically manages upload limits for torrents based on their upload ratio.
  • Download Directory Purge: Cleans up download directories by comparing qBittorrent data with the actual file system.

⁠Prerequisites

  • Node.js (version 20 or later)
  • qBittorrent with Web UI enabled
  • SSH access to the server hosting qBittorrent (for the purge script)

⁠Installation

  1. Clone this repository:

    git clone https://github.com/KevinWang15/qb-scripts
    cd qb-scripts
    
  2. Install dependencies:

    npm install
    
  3. Create a config.json file in the project root with your settings (see Configuration section below).

⁠Configuration

Create a config.json file in the project root. The required fields depend on which scripts you're using. Here's a comprehensive example with all possible options:

{
  "qbittorrent": {
    "url": "http://your-qbittorrent-webui-url",
    "username": "your-username",
    "password": "your-password",
    "downloadRoot": "/path/to/download/directory"
  },
  "ssh": {
    "host": "your-ssh-host",
    "username": "your-ssh-username",
    "privateKeyPath": "/path/to/your/private/key"
  },
  "uploadLimiter": {
    "uploadRatioThreshold": 3,
    "uploadLimitKBps": 100,
    "checkIntervalSeconds": 30
  },
  "proxy": {
    "type": "socks5",
    "host": "proxy-host",
    "port": 1080,
    "url": "socks5://username:password@proxy-host:1080"
  }
}
⁠Configuration Sections
  1. qbittorrent: Required for all scripts

    • url: The URL of your qBittorrent Web UI
    • username and password: Your qBittorrent Web UI credentials
    • downloadRoot: The root directory where qBittorrent stores downloads (required for purge-downloaddir.js)
  2. ssh: Required only for purge-downloaddir.js

    • host: The hostname or IP address of your SSH server
    • username: Your SSH username
    • privateKeyPath: Path to your SSH private key file
  3. uploadLimiter: Required only for auto-upload-limiter.js

    • uploadRatioThreshold: The ratio at which to start limiting upload speed
    • uploadLimitKBps: The upload speed limit in KB/s
    • checkIntervalSeconds: How often to check and adjust upload limits
  4. proxy: Optional for all scripts

    • type: The type of proxy. Can be "socks5", "http", or "https"
    • host and port: The proxy server's hostname/IP and port
    • url: An alternative way to specify the proxy (can be used instead of host and port)
⁠Proxy Configuration

The scripts support three types of proxies:

  1. SOCKS5 Proxy:

    "proxy": {
      "type": "socks5",
      "host": "proxy-host",
      "port": 1080
    }
    

    Or using the url format:

    "proxy": {
      "type": "socks5",
      "url": "socks5://username:password@proxy-host:1080"
    }
    
  2. HTTP Proxy:

    "proxy": {
      "type": "http",
      "host": "proxy-host",
      "port": 8080
    }
    

    Or using the url format:

    "proxy": {
      "type": "http",
      "url": "http://username:password@proxy-host:8080"
    }
    
  3. HTTPS Proxy:

    "proxy": {
      "type": "https",
      "host": "proxy-host",
      "port": 8443
    }
    

    Or using the url format:

    "proxy": {
      "type": "https",
      "url": "https://username:password@proxy-host:8443"
    }
    

Note: When using the url format, you don't need to specify host and port separately.

⁠Minimum Required Configuration
  • For auto-upload-limiter.js:

    {
      "qbittorrent": {
        "url": "http://your-qbittorrent-webui-url",
        "username": "your-username",
        "password": "your-password"
      },
      "uploadLimiter": {
        "uploadRatioThreshold": 3,
        "uploadLimitKBps": 100,
        "checkIntervalSeconds": 30
      }
    }
    
  • For purge-downloaddir.js:

    {
      "qbittorrent": {
        "url": "http://your-qbittorrent-webui-url",
        "username": "your-username",
        "password": "your-password",
        "downloadRoot": "/path/to/download/directory"
      },
      "ssh": {
        "host": "your-ssh-host",
        "username": "your-ssh-username",
        "privateKeyPath": "/path/to/your/private/key"
      }
    }
    

Remember to adjust the configuration according to your specific setup and requirements.

⁠Usage

⁠Auto Upload Limiter

Run the auto upload limiter script:

node auto-upload-limiter.js

This script will continuously monitor your torrents and adjust their upload limits based on the configured ratio threshold.

⁠Purge Download Directory

Run the purge script:

node purge-downloaddir.js

This script will compare the torrents in qBittorrent with the actual directories in your download folder, allowing you to clean up any discrepancies.

⁠Docker Support

A Dockerfile is provided for containerizing the application. To build and run the Docker container:

  1. Build the image:

    docker build -t qb-scripts .
    
  2. Run the container:

    docker run -v /path/to/your/config.json:/app/config.json qb-scripts /app/your-script.js
    

Make sure to mount your config.json file and any necessary SSH keys into the container.

⁠Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

⁠License

This project is licensed under the MIT License.

Tag summary

Content type

Image

Digest

sha256:9a917677e…

Size

365.7 MB

Last updated

almost 2 years ago

docker pull kevinwang15/qb-scripts