GithubHelp home page GithubHelp logo

ch3p4ll3 / qbittorrentbot Goto Github PK

View Code? Open in Web Editor NEW
64.0 2.0 28.0 753 KB

This bot can control qbittorrent easily from Telegram! You can add magnet or torrent files, have a list of active downloads, delete, pause and restart downloads.

Home Page: https://ch3p4ll3.github.io/QBittorrentBot/

License: GNU General Public License v3.0

Python 99.76% Dockerfile 0.24%
telegram bot torrent qbittorrent telegrambot docker docker-image dockerfile dockerhub pyrogram

qbittorrentbot's Introduction

GitHub License Codacy Badge GitHub Workflow Status (with event) Docker Pulls

All Contributors

QBittorrentBot

With this bot telegram you can manage your qbittorrent with a few simple clicks. Thanks to QBittorrentBot you can have a list of all the files in download / upload, add torrents and magnets.
You can add more magnets by simply placing one link per line, e.g.

magnet:?xt=...  
magnet:?xt=...  

You can also pause, resume, delete and add/remove and modify categories.

Table Of Contents

Warning!

Since version V2, the mapping of the configuration file has been changed. Make sure you have modified it correctly before starting the bot

Configuration

Retrieve Telegram API ID and API HASH

With the change of library to pyrogram you will need the API_ID and API_HASH. Check here to find out how to recover them.

JSON Configuration

Edit the config.json.template file and rename it to config.json. The config file is stored in the mounted /app/config/ volume

{
    "client": {
        "type": "qbittorrent",
        "host": "http://192.168.178.102:8080",
        "user": "admin",
        "password": "admin"
    },
    "telegram": {
        "bot_token": "1111111:AAAAAAAA-BBBBBBBBB",
        "api_id": 1111,
        "api_hash": "aaaaaaaa",
        "proxy": {  // optional
            "scheme": "http",
            "hostname": "myproxy.local",
            "port": 8080,
            "username": "admin",  // optional
            "password": "admin"  // optional
        }
    },

    "users": [
        {
            "user_id": 123456,
            "notify": false,
            "locale": "en",  // optional, default "en"
            "role": "administrator"  // optional, default "administrator"
        },
        {
            "user_id": 78910,
            "notify": true,
            "locale": "it",
            "role": "administrator"
        }
    ]
}

Note: If notify is true then the user will receive a notification whenever a torrent has finished downloading

Running

Pull and run the image with: docker run -d -v /home/user/docker/QBittorrentBot:/app/config:rw --name qbittorrent-bot ch3p4ll3/qbittorrent-bot:latest

Build docker

  • Clone this repo git clone https://github.com/ch3p4ll3/QBittorrentBot.git
  • Move in the project directory
  • Create a config.json file
  • Run docker build -t qbittorrent-bot:latest . && docker run -d -v /home/user/docker/QBittorrentBot:/app/config:rw --name qbittorrent-bot qbittorrent-bot:latest

Running without docker

  • Clone this repo git clone https://github.com/ch3p4ll3/QBittorrentBot.git
  • Move in the project directory
  • Install dependencies with pip3 install -r requirements.txt
  • Create a config.json file
  • Start the bot with python3 main.py

Contributing Translations on Transifex

QBittorrentBot is an open-source project that relies on the contributions of its community members to provide translations for its users. If you are multilingual and would like to help us make QBittorrentBot more accessible to a wider audience, you can contribute by adding new translations or improving existing ones using Transifex:

  • Visit the QBittorrentBot Transifex Project.

  • If you don't have a Transifex account, sign up for one. If you already have an account, log in.

  • Navigate to the "Languages" tab to view the available languages. Choose the language you want to contribute to.

  • Locate the specific string you wish to translate. Please note that the text between "${" and "}" should not be edited, as they are placeholders for dynamic content.

  • Click on the string you want to translate, enter your translation in the provided field, and save your changes.

  • If your language is not listed, you can request its addition.

  • Once you have completed your translations, submit them for review. The project maintainers will review and approve your contributions.

Thank you for helping improve QBittorrentBot with your valuable translations!

How to enable the qBittorrent Web UI

For the bot to work, it requires qbittorrent to have the web interface active. You can activate it by going on the menu bar, go to Tools > Options qBittorrent WEB UI

  • In the new window, choose Web UI option
  • Check the Enable the Web User Interface (Remote control) option
  • Choose a port (by default 8080)
  • Set username and password (by default username: admin / password: adminadmin)

Click on Ok to save settings.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Bogdan
Bogdan

💻
joey00797
joey00797

🌍

This project follows the all-contributors specification. Contributions of any kind welcome!

Star History

Star History Chart

qbittorrentbot's People

Contributors

allcontributors[bot] avatar bushig avatar ch3p4ll3 avatar dependabot[bot] avatar transifex-integration[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

qbittorrentbot's Issues

Add Torrent (Error)

2024-02-06 16:48:11,420 - pyrogram.dispatcher - ERROR - inject_user..wrapper() takes 2 positional arguments but 3 were given
Traceback (most recent call last):
File "/home/krutofa/.local/lib/python3.11/site-packages/pyrogram/dispatcher.py", line 240, in handler_worker
await handler.callback(self.client, *args)
File "/home/krutofa/scripts/QBittorrentBot/src/utils.py", line 79, in wrapper
await func(client, message, user)
File "/home/krutofa/scripts/QBittorrentBot/src/bot/plugins/callbacks/category/category_callbacks.py", line 120, in category
await add_torrent_callback(client, callback_query, user)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Filter Notification for Some Categories

Some config to filter notifications only for some categories.

For example, I have the following categories: Movies, Series, Games, Trainning.... and I don't wanna be notified for add or finish some download in Games, only for Series and Movies.

If we have some feature to filter those kind of notification it will be nice.

windows 11 support?

can i get this thing run in windows?
really instrested to get this to work.

Some problem

bolshukhin_roman@NETTOP-SQUARE:/opt/qbittorrent-bot$ python3 /opt/qbittorrent-bot/main.py
Traceback (most recent call last):
File "/opt/qbittorrent-bot/main.py", line 1, in
from src.bot import app, scheduler
ModuleNotFoundError: No module named 'src'
bolshukhin_roman@NETTOP-SQUARE:/opt/qbittorrent-bot$

× qbittorrent-bot.service - qBittorrent-bot
Loaded: loaded (/etc/systemd/system/qbittorrent-bot.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2023-06-07 18:02:59 MSK; 7s ago
Process: 3658 ExecStart=python3 /opt/qbittorrent-bot/main.py (code=exited, status=1/FAILURE)
Main PID: 3658 (code=exited, status=1/FAILURE)

Jun 07 18:02:59 NETTOP-SQUARE systemd[1]: Started qBittorrent-bot.
Jun 07 18:02:59 NETTOP-SQUARE python3[3658]: Traceback (most recent call last):
Jun 07 18:02:59 NETTOP-SQUARE python3[3658]: File "/opt/qbittorrent-bot/main.py", line 1, in
Jun 07 18:02:59 NETTOP-SQUARE python3[3658]: from src.bot import app, scheduler
Jun 07 18:02:59 NETTOP-SQUARE python3[3658]: ModuleNotFoundError: No module named 'src'
Jun 07 18:02:59 NETTOP-SQUARE systemd[1]: qbittorrent-bot.service: Main process exited, code=exited, status=1/FAILURE
Jun 07 18:02:59 NETTOP-SQUARE systemd[1]: qbittorrent-bot.service: Failed with result 'exit-code'.

What I must to do? Thanks

Stats error

Thank you for your wonderful bot, how to cure the problem?
when entering a command /stats, such an error occurs in the log

'coretemp'

Traceback (most recent call last):

  File "/usr/local/lib/python3.10/site-packages/pyrogram/dispatcher.py", line 242, in handler_worker

    await self.loop.run_in_executor(

  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run

    result = self.fn(*self.args, **self.kwargs)

  File "/app/src/bot.py", line 116, in stats_command

    f"**CPU температура:** {psutil.sensors_temperatures()['coretemp'][0].current}°C\n" \

KeyError: 'coretemp'

bug

you have a languages ​​button, is it in the plans or is there something wrong with it because it doesn’t work.
and what does the reset settings button do? I don't think she does anything...

PRIMARY KEY size exception

I running tg bot in docker image and got exception in log while sending command to the bot:

2024-01-10 13:02:20,514 - pyrogram.dispatcher - ERROR - Value 6XXXXXXXXX of attr Support.id is greater than the maximum allowed value 2147483647
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyrogram/dispatcher.py", line 240, in handler_worker
    await handler.callback(self.client, *args)
  File "/app/src/bot/plugins/on_message.py", line 19, in on_text
    action = db_management.read_support(message.from_user.id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/db_management.py", line 25, in read_support
    return Support[chat_id].Action
           ~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pony/orm/core.py", line 3991, in __getitem__
    return entity._find_one_(kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pony/orm/core.py", line 4105, in _find_one_
    avdict[attr] = attr.validate(val, None, entity, from_db=False)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pony/orm/core.py", line 2534, in validate
    val = Attribute.validate(attr, val, obj, entity, from_db)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pony/orm/core.py", line 2205, in validate
    val = converter.validate(val, obj)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pony/orm/dbapiprovider.py", line 546, in validate
    throw(ValueError, 'Value %r of attr %s is greater than the maximum allowed value %r'
  File "/usr/local/lib/python3.11/site-packages/pony/utils/utils.py", line 99, in throw
    raise exc
ValueError: Value 6XXXXXXXXX of attr Support.id is greater than the maximum allowed value 2147483647

In src/db_management.py your declaration of Support type is:

class Support(db.Entity):
    id = PrimaryKey(int)
    Action = Required(str, 255)

Seems that ponyorm interpret PK size as 32 by default. From SQLite docs: In SQLite, a column with type INTEGER PRIMARY KEY is an alias for the ROWID (except in WITHOUT ROWID tables) which is always a 64-bit signed integer.

It can be fixed by adding optional attribute size to PrimaryKey declaration:

class Support(db.Entity):
    id = PrimaryKey(int, size=64)
    Action = Required(str, 255)

ImportError: cannot import name 'StrEnum' from 'enum' Python3.10 windows

Describe the bug
Trying to run the cloned program with proper valid config.json.
Platform: Windows 11, wsl2 - Ubuntu
Python 3.10

Bot started Traceback (most recent call last): File "/mnt/d/Projs/QBittorrentBot/main.py", line 30, in <module> app.run() File "/mnt/d/Projs/QBittorrentBot/.venv/lib/python3.10/site-packages/pyrogram/methods/utilities/run.py", line 84, in run self.start() File "/mnt/d/Projs/QBittorrentBot/.venv/lib/python3.10/site-packages/pyrogram/sync.py", line 66, in async_to_sync_wrap return loop.run_until_complete(coroutine) File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete File "/mnt/d/Projs/QBittorrentBot/.venv/lib/python3.10/site-packages/pyrogram/methods/utilities/start.py", line 74, in start await self.initialize() File "/mnt/d/Projs/QBittorrentBot/.venv/lib/python3.10/site-packages/pyrogram/methods/auth/initialize.py", line 46, in initialize self.load_plugins() File "/mnt/d/Projs/QBittorrentBot/.venv/lib/python3.10/site-packages/pyrogram/client.py", line 689, in load_plugins module = import_module(module_path) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/mnt/d/Projs/QBittorrentBot/src/bot/plugins/callbacks/add_torrents_callbacks.py", line 6, in <module> from ....translator import Translator, Strings File "/mnt/d/Projs/QBittorrentBot/src/translator/__init__.py", line 2, in <module> from .strings import Strings File "/mnt/d/Projs/QBittorrentBot/src/translator/strings.py", line 1, in <module> from enum import StrEnum ImportError: cannot import name 'StrEnum' from 'enum' (/usr/lib/python3.10/enum.py)

Tried python3.12, TgCrypto package is still not available, python 3.6 few packages wont install.

Any help to fix this is appreciated.

ModuleNotFoundError: No module named 'src'

Hi, when i run python3 main.py, i see this error:
qbittorrent@qbittorrent:/opt/qbittorrent-bot$ python3 main.py
Traceback (most recent call last):
File "/opt/qbittorrent-bot/main.py", line 1, in
from src.bot import app, scheduler
ModuleNotFoundError: No module named 'src'

What can i do?
OS: Ubuntu 22.04

Thanks in advance.

pony.orm.core.ObjectNotFound

Pull container from dockerhub. The logs show an error:

Support[MY_USER_ID]
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/pyrogram/dispatcher.py", line 242, in handler_worker
    await self.loop.run_in_executor(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/app/src/bot.py", line 375, in on_text
    action = db_management.read_support(message.from_user.id)
  File "/app/src/db_management.py", line 23, in read_support
    return Support[chat_id].Action
  File "/usr/local/lib/python3.10/site-packages/pony/orm/core.py", line 3991, in __getitem__
    return entity._find_one_(kwargs)
  File "/usr/local/lib/python3.10/site-packages/pony/orm/core.py", line 4115, in _find_one_
    if obj is None: throw(ObjectNotFound, entity, pkval)
  File "/usr/local/lib/python3.10/site-packages/pony/utils/utils.py", line 99, in throw
    raise exc
pony.orm.core.ObjectNotFound: Support[MY_USER_ID]

Feature request - tgDownloader & simple file downloader

Is your feature request related to a problem? Please describe.
I would like a couple of requests to be added to the bot as features:

  • I would like to forward a file to the bot and download to the set location in the server, with periodic updates on progress.
  • Would like to send a link and download the file using a simple download manager (not in the QBitTorrent context, just a simple file downloader).

Down the line when you have free time or if these requests are worth implementing, please do give a thought on em.

'QbittorrentManager' object does not support the context manager protocol during torrent finish event

Hi,

I've just got the following error in log, when the bot tried to notify about a completed downlod.

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/apscheduler/executors/base_py3.py", line 30, in run_coroutine_job
    retval = await job.func(*job.args, **job.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/utils.py", line 15, in torrent_finished
    with QbittorrentManager() as qb:
TypeError: 'QbittorrentManager' object does not support the context manager protocol

I'm using the latest image from Docker hub.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.