diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aad04f5..df4c460 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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)) diff --git a/autoremovetorrents/client/qbittorrent.py b/autoremovetorrents/client/qbittorrent.py index c09ca59..2161b4e 100644 --- a/autoremovetorrents/client/qbittorrent.py +++ b/autoremovetorrents/client/qbittorrent.py @@ -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: diff --git a/setup.py b/setup.py index 118c1af..5660cb7 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ install_requires = [ 'deluge-client', 'enum34', + 'packaging', 'ply', '' if SUPPORT_SHUTIL else 'psutil', PYYAML_VERSION,