Skip to content

Instantly share code, notes, and snippets.

@kappa7194
Created October 21, 2012 19:23
Show Gist options
  • Save kappa7194/3928178 to your computer and use it in GitHub Desktop.
Save kappa7194/3928178 to your computer and use it in GitHub Desktop.
Fix torrent trackers
#! /usr/bin/python
import os
import re
import subprocess
def main():
torrent_path = "/home/bbf/.transmission-daemon/torrents/"
broken_torrents = set()
with open("/var/log/syslog", "rb") as log:
for line in log:
line = line.strip()
match = re.search("Unregistered torrent.", line)
if match:
line = re.sub("^[A-Z][a-z]{2} [0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2} [a-z]+ transmission-daemon\[[0-9]+\]: ", "", line)
line = re.sub(" Unregistered torrent. \(announcer\.c:(994)\)$", "", line)
broken_torrents.add(line)
for torrent in os.listdir(torrent_path):
if re.sub("\.\w+\.torrent$", "", torrent) in broken_torrents:
torrent = torrent_path + torrent
subprocess.call(["transmission-edit", "--delete", "http://bbf.redirectme.net", torrent])
subprocess.call(["transmission-edit", "--delete", "http://open.nyaatorrents.info:6544/announce", torrent])
os.chown(torrent, 1000, 1001)
if __name__ == "__main__":
main()
@shyamdhokia
Copy link

Sorry complete noob here but I'm having problems connecting to torrent trackers will this script help? also where do I save the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment