Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/cehbz/qbittorrent

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/cehbz/qbittorrent

  • v1.6.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

qBittorrent Go Client Library

A Go client library for interacting with the qBittorrent Web API.

Features

  • Authentication: Log in to the qBittorrent Web API.
  • Torrent Management:
    • Add new torrents.
    • Delete existing torrents.
    • Export torrent files.
    • Retrieve torrent information.
    • Manage torrent force-start settings.
  • Tracker Information: Fetch tracker details for specific torrents.

Installation

To install the package, run:

go get github.com/cehbz/qbittorrent

Usage

Importing the Package

import (
    "github.com/cehbz/qbittorrent"
)

Initializing the Client

client, err := qbittorrent.NewClient("username", "password", "localhost", "8080")
if err != nil {
    log.Fatalf("Failed to create client: %v", err)
}
  • username: Your qBittorrent Web UI username. Empty if none.
  • password: Your qBittorrent Web UI password. Empty if none.
  • addr: The address where qBittorrent is running (e.g., "127.0.0.1").
  • port: The port number of the qBittorrent Web UI (e.g., "8080").

Adding a Torrent

torrentData, err := os.ReadFile("path/to/your.torrent")
if err != nil {
    log.Fatalf("Failed to read torrent file: %v", err)
}

err = client.TorrentsAdd("your.torrent", torrentData)
if err != nil {
    log.Fatalf("Failed to add torrent: %v", err)
}

Deleting a Torrent

err := client.TorrentsDelete("torrent-hash")
if err != nil {
    log.Fatalf("Failed to delete torrent: %v", err)
}

Exporting a Torrent File

data, err := client.TorrentsExport("torrent-hash")
if err != nil {
    log.Fatalf("Failed to export torrent: %v", err)
}

err = os.WriteFile("exported.torrent", data, 0644)
if err != nil {
    log.Fatalf("Failed to write exported torrent file: %v", err)
}

Retrieving Torrent Information

torrents, err := client.TorrentsInfo()
if err != nil {
    log.Fatalf("Failed to retrieve torrents info: %v", err)
}

for _, torrent := range torrents {
    fmt.Printf("Name: %s, Progress: %.2f%%
", torrent.Name, torrent.Progress*100)
}

Fetching Tracker Information

trackers, err := client.TorrentsTrackers("torrent-hash")
if err != nil {
    log.Fatalf("Failed to get trackers: %v", err)
}

for _, tracker := range trackers {
    fmt.Printf("URL: %s, Status: %d
", tracker.URL, tracker.Status)
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contribution

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

Acknowledgments

FAQs

Package last updated on 27 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc