From 66aec5b0ecccdd271f0021035d1fd04166dcb420 Mon Sep 17 00:00:00 2001 From: bobokun <12660469+bobokun@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:10:35 -0400 Subject: [PATCH] 4.1.9 (#647) --- CHANGELOG | 18 +++------------- VERSION | 2 +- modules/util.py | 4 +--- scripts/edit_passkey.py | 47 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 scripts/edit_passkey.py diff --git a/CHANGELOG b/CHANGELOG index c2bdb4a6..b61f94f6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,16 +1,4 @@ -# Requirements Updated -- qbittorrent-api==2024.8.65 -- croniter==3.0.3 -- humanize==4.10.0 - -# New Updates -- Adds `force_auto_tmm_ignore_tags` feature to ignore tags when force_auto_tmm is enabled (#634) - # Bug Fixes -- Fixes Print the schedule and delay before starting the sleep (Closes [#605](https://github.com/StuffAnThings/qbit_manage/issues/605)) -- Fixes noHL counting symlinks as part of its logic (Closes [#608](https://github.com/StuffAnThings/qbit_manage/issues/608)) -- Fix typos in documentation (#627) -- Extended logging to explain why torrent files were not deleted (#625) - -Special thanks to @ineednewpajamas, @glicholas, @Minituff, @Dark3clipse, @TJZine for their contributions! -**Full Changelog**: https://github.com/StuffAnThings/qbit_manage/compare/v4.1.7...v4.1.8 +- Fixes Blutopia torrents being deleted due to passkeys being invalid (#646) +- Adds edit_passkey.py script +**Full Changelog**: https://github.com/StuffAnThings/qbit_manage/compare/v4.1.8...v4.1.9 diff --git a/VERSION b/VERSION index a7c00da3..18837e70 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.1.8 +4.1.9 diff --git a/modules/util.py b/modules/util.py index c4684686..52aab3d4 100755 --- a/modules/util.py +++ b/modules/util.py @@ -94,10 +94,8 @@ class TorrentMessages: IGNORE_MSGS = [ "YOU HAVE REACHED THE CLIENT LIMIT FOR THIS TORRENT", - "MISSING PASSKEY", + "PASSKEY", # Any mention of passkeys should be a clear sign it should NOT be deleted "MISSING INFO_HASH", - "PASSKEY IS INVALID", - "INVALID PASSKEY", "EXPECTED VALUE (LIST, DICT, INT OR STRING) IN BENCODED STRING", "COULD NOT PARSE BENCODED DATA", "STREAM TRUNCATED", diff --git a/scripts/edit_passkey.py b/scripts/edit_passkey.py new file mode 100644 index 00000000..13346d52 --- /dev/null +++ b/scripts/edit_passkey.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +# This standalone script is used to edit passkeys from one tracker. +# Needs to have qbittorrent-api installed +# pip3 install qbittorrent-api +import sys + +# --DEFINE VARIABLES--# +qbt_host = "qbittorrent:8080" +qbt_user = None +qbt_pass = None +TRACKER = "blutopia" # Part of the tracker URL, e.g., "blutopia" or "your-tracker.com" +OLD_PASSKEY = "OLD_PASSKEY" +NEW_PASSKEY = "NEW_PASSKEY" +# --DEFINE VARIABLES--# +# --START SCRIPT--# + +try: + from qbittorrentapi import APIConnectionError + from qbittorrentapi import Client + from qbittorrentapi import LoginFailed +except ModuleNotFoundError: + print('Requirements Error: qbittorrent-api not installed. Please install using the command "pip install qbittorrent-api"') + sys.exit(1) + + +if __name__ == "__main__": + try: + client = Client(host=qbt_host, username=qbt_user, password=qbt_pass) + except LoginFailed: + raise ("Qbittorrent Error: Failed to login. Invalid username/password.") + except APIConnectionError: + raise ("Qbittorrent Error: Unable to connect to the client.") + except Exception: + raise ("Qbittorrent Error: Unable to connect to the client.") + torrent_list = client.torrents.info(sort="added_on", reverse=True) + + for torrent in torrent_list: + for x in torrent.trackers: + if TRACKER in x.url and OLD_PASSKEY in x.url: + try: + newurl = x.url.replace(OLD_PASSKEY, NEW_PASSKEY) + print(f"Updating passkey for torrent name: {torrent.name}\n") + torrent.remove_trackers(urls=x.url) + torrent.add_trackers(urls=newurl) + except Exception as e: + print(f"Error updating tracker for {torrent.name}: {e}") + print("Passkey update completed.")