Skip to content

Commit

Permalink
enhance: qBittorrent v4.5.x+ new api workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
amefs committed Apr 4, 2024
1 parent f87c821 commit 1a59c73
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
install_requires = [
'deluge-client',
'enum34',
'packaging',
'ply',
'' if SUPPORT_SHUTIL else 'psutil',
PYYAML_VERSION,
Expand Down

0 comments on commit 1a59c73

Please sign in to comment.