Created
October 21, 2012 19:23
-
-
Save kappa7194/3928178 to your computer and use it in GitHub Desktop.
Fix torrent trackers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry complete noob here but I'm having problems connecting to torrent trackers will this script help? also where do I save the script.