diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..16d3c4d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.cache diff --git a/transmission-trackers-auto-cron.sh b/transmission-trackers-auto-cron.sh old mode 100644 new mode 100755 index 7aca918..b4cc0e7 --- a/transmission-trackers-auto-cron.sh +++ b/transmission-trackers-auto-cron.sh @@ -1,13 +1,14 @@ #!/bin/bash +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)" # If you are using transmission-daemon directly on system the below code will ensure that trackers script run only when it is running if [ "$(systemctl is-active transmission-daemon)" = "active" ] then -/usr/bin/python3 [path]]/transmission-trackers.py +/usr/bin/python3 $DIR/transmission-trackers.py fi -# If you are using docker for transmission use the following. Replace 'docker-container-name' with the appropriate name -if [ "$( docker container inspect -f '{{.State.Running}}' 'docker-container-name' )" = "true" ] -then -/usr/bin/python3 [path]]/transmission-trackers.py -fi \ No newline at end of file +# If you are using docker for transmission use the following. Replace 'docker-container-name' with the appropriate name and uncomment the following +#if [ "$( docker container inspect -f '{{.State.Running}}' 'docker-container-name' )" = "true" ] +#then +#/usr/bin/python3 $DIR/transmission-trackers.py +#fi diff --git a/transmission-trackers.py b/transmission-trackers.py index 01a9d30..203ec20 100755 --- a/transmission-trackers.py +++ b/transmission-trackers.py @@ -21,6 +21,11 @@ # If empty - will affect all torrents 'status_filter': (), + # Ignore torrents that contain any of these trackers. + # This is useful, e.g., for excluding torrents from private trackers. + # trackers are matched by substring, so you can cover https://my.site/announce with just my.site + 'tracker_filter': [], + # A list of URLs where to get the tracker lists from. # The lists are combined into one with duplicates removed. # The trackers from these lists are checked by looking up the URL's hostname in DNS. @@ -49,7 +54,7 @@ 'silent': False, # Debug output - 'debug': False + 'debug': True } cache_file = None # Universal scope @@ -248,6 +253,11 @@ def readLocalLists(): for trk in t.trackers: ttrk.add(getattr(trk, 'fields', trk).get('announce')) + # Use .get() to avoid error if key doesn't exist + if any(tracker in url for url in ttrk for tracker in config.get('tracker_filter', [])): + dbg('{}: skipping due to tracker filter'.format(t.name)) + continue + diff = trackers - ttrk if diff: