From a4ad0acb8a2cd770a23ead949bdea42fd8be2ce4 Mon Sep 17 00:00:00 2001 From: wuliaotc <372072553@qq.com> Date: Sun, 11 Dec 2022 21:43:40 +0800 Subject: [PATCH 1/2] do some change to use transmision_rpc 4.0(pre release) --- transmission-trackers.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/transmission-trackers.py b/transmission-trackers.py index bcdaaf8..33ce903 100755 --- a/transmission-trackers.py +++ b/transmission-trackers.py @@ -81,7 +81,7 @@ import sys, os, time, socket try: - from transmissionrpc import Client + from transmission_rpc import Client if 'host' in client: client['address'] = client['host'] del client['host'] @@ -237,14 +237,13 @@ def readLocalLists(): if config['status_filter'] and not t.status in config['status_filter']: dbg('{}: skipping due to status filter'.format(t.name)) continue - if t.isPrivate: + if t.is_private: dbg('{}: skipping private torrent'.format(t.name)) continue ttrk = set(()) for trk in t.trackers: - ttrk.add(trk['announce']) - + ttrk.add(trk.announce) diff = trackers - ttrk if diff: From e5c6e3f347168744fe29c701c655613c20b216ba Mon Sep 17 00:00:00 2001 From: wuliaotc <372072553@qq.com> Date: Sun, 11 Dec 2022 21:46:08 +0800 Subject: [PATCH 2/2] fix error save ip set and add try except for add tracker --- transmission-trackers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/transmission-trackers.py b/transmission-trackers.py index 33ce903..3a7aaf0 100755 --- a/transmission-trackers.py +++ b/transmission-trackers.py @@ -140,8 +140,7 @@ def validateTrackerURL(url, dns=True): if ip in ips: dbg("Host's '{}' IP '{}' is duplicate".format(h, ip)) return False - - ips.add(ip) + ips.add(ip) dbg("Approving tracker '{}'".format(url)) hosts.add(h) @@ -248,6 +247,10 @@ def readLocalLists(): if diff: lg('{}: Adding {} trackers (before: {})'.format(t.name, len(diff), len(ttrk))) - tc.change_torrent(t.id, trackerAdd=list(diff)) + try: + tc.change_torrent(t.id, trackerAdd=list(diff)) + except Exception as e: + dbg('{}: Adding trackers failed,error: {})'.format(t.name, e)) + continue else: dbg('{}: update not needed'.format(t.name))