Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qBittorrent v4.5.x+ new api workaround #187

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@ jobs:
PGID: 1000
TZ: Europe/London
WEBUI_PORT: 8080
volumes:
- /tmp/qbittorrent-latest/config:/config
ports:
- 8080:8080
- 20000:6881
@@ -114,13 +116,12 @@ jobs:
fail-fast: false
matrix:
python-version: [
"2.7",
"3.5",
"3.6",
"3.7",
"3.8",
"3.9",
"3.10"
"3.10",
"3.11",
"3.12"
]

steps:
@@ -155,6 +156,11 @@ jobs:
run: |
echo "DELUGE_2_PASSWORD=$(sudo cat /tmp/deluge-latest/config/auth | sed 's/.*:\(.*\):.*/\1/g')" >> $GITHUB_ENV
echo "DELUGE_1_PASSWORD=$(sudo cat /tmp/deluge-1/config/auth | sed 's/.*:\(.*\):.*/\1/g')" >> $GITHUB_ENV
- name: Setup passwords of qBittorrent latest
run: |
docker stop ${{ job.services.qbittorrent-latest.id }}
echo 'WebUI\Password_PBKDF2="@ByteArray(+BwJe86psDlDzA5u7ebg9Q==:yZeQKzvuRW/Mn+qL0FS8Nt91A53x5Ow8YGNOq0KusmleU9xn60RWx9kDXKOEqIe+eJX5bQ9UJ4GgR16UWprRSw==)"' | sudo tee -a /tmp/qbittorrent-latest/config/qBittorrent/qBittorrent.conf
docker start ${{ job.services.qbittorrent-latest.id }}
- name: Sleep for a while
run: |
sleep $((10 + $RANDOM % 50))
16 changes: 16 additions & 0 deletions autoremovetorrents/client/qbittorrent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#-*- coding:utf-8 -*-
import requests
import time
from packaging import version
from .. import logger
from ..torrent import Torrent
from ..clientstatus import ClientStatus
@@ -135,6 +136,21 @@ def __init__(self, host):
if self._request_handler is None:
raise IncompatibleAPIVersion('Incompatible qbittorrent client. The current API version may be unsupported.')

# Workaround for https://github.com/qbittorrent/qBittorrent/issues/18097
if self._request_handler.api_major_version() == "v2":
if version.parse(self._request_handler.client_version().text) >= version.parse("4.5.0"):
def new_delete_torrents(self, torrent_hash_list):
return self._session.post(self._host + '/api/v2/torrents/delete',
data={'hashes': '|'.join(torrent_hash_list), 'deleteFiles': False})

self.qBittorrentAPIHandlerV2.delete_torrents = new_delete_torrents

def new_delete_torrents_and_data(self, torrent_hash_list):
return self._session.post(self._host + '/api/v2/torrents/delete',
data={'hashes': '|'.join(torrent_hash_list), 'deleteFiles': True})

self.qBittorrentAPIHandlerV2.delete_torrents_and_data = new_delete_torrents_and_data

# Login to qBittorrent
def login(self, username, password):
try:
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
install_requires = [
'deluge-client',
'enum34',
'packaging',
'ply',
'' if SUPPORT_SHUTIL else 'psutil',
PYYAML_VERSION,