From 5990cf2f50405fe90ea3fde0026cdce88e7148a5 Mon Sep 17 00:00:00 2001 From: Anna-Maria Meriniemi Date: Wed, 22 Nov 2017 10:02:22 +0200 Subject: [PATCH] Remove tracker limit and always add our trackers (#417) With all trackers.txt trackers being included in generated .torrents, we can now be certain the magnet (which use trackers.txt) and the .torrent uses will not be split up in different swarms in case the main announce dies. (That is, if uploaders add enough of their own trackers and additional trackers were deemed unnecessary (at least 5 already), the magnet and .torrent would only share the main site announce) --- nyaa/torrents.py | 9 +++------ trackers.txt | 3 +++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nyaa/torrents.py b/nyaa/torrents.py index a088c6c..1644123 100644 --- a/nyaa/torrents.py +++ b/nyaa/torrents.py @@ -11,16 +11,13 @@ from nyaa import bencode USED_TRACKERS = OrderedSet() -# Limit the amount of trackers added into .torrent files -MAX_TRACKERS = 5 - def read_trackers_from_file(file_object): USED_TRACKERS.clear() for line in file_object: line = line.strip() - if line: + if line and not line.startswith('#'): USED_TRACKERS.add(line) return USED_TRACKERS @@ -104,7 +101,7 @@ def create_default_metadata_base(torrent, trackers=None, webseeds=None): metadata_base = { 'created by': 'NyaaV2', 'creation date': int(time.time()), - 'comment': 'NyaaV2 Torrent #' + str(torrent.id), # Throw the url here or something neat + 'comment': 'NyaaV2 Torrent #' + str(torrent.id), # 'encoding' : 'UTF-8' # It's almost always UTF-8 and expected, but if it isn't... } @@ -112,7 +109,7 @@ def create_default_metadata_base(torrent, trackers=None, webseeds=None): metadata_base['announce'] = trackers[0] if len(trackers) > 1: # Yes, it's a list of lists with a single element inside. - metadata_base['announce-list'] = [[tracker] for tracker in trackers[:MAX_TRACKERS]] + metadata_base['announce-list'] = [[tracker] for tracker in trackers] # Add webseeds if webseeds: diff --git a/trackers.txt b/trackers.txt index 3478755..1e0bb13 100644 --- a/trackers.txt +++ b/trackers.txt @@ -1,3 +1,6 @@ +# These trackers will be added to all generated torrents, +# to ensure the torrents' continued life in case one or two die. +# One tracker per line, lines starting with # are disregarded udp://open.stealth.si:80/announce udp://tracker.opentrackr.org:1337/announce udp://tracker.coppersurfer.tk:6969/announce