From 5aed85d8cdc3301c9f9a68d89d21ae7b1bf1658f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Wed, 15 Mar 2023 20:26:21 +0100 Subject: added env var TTL COOLDOWN TOOMUCH --- travnik.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'travnik.py') diff --git a/travnik.py b/travnik.py index 672ed00..5b273f8 100644 --- a/travnik.py +++ b/travnik.py @@ -14,6 +14,7 @@ class Torrent(): self.files = {} self.type = Type.UNDEF self.cache = None + self.hadpieces = False def file(self, f): self.parse(open(f, "rb").read()) def parse(self, b): @@ -23,6 +24,7 @@ class Torrent(): self.dict = decode(b) if b'pieces' in self.dict.get(b'info'): self.dict.get(b'info').pop(b'pieces') + self.hadpieces = True if b'files' in self.dict.get(b'info').keys(): self.type = Type.V1 for file in self.dict.get(b'info').get(b'files'): @@ -43,6 +45,7 @@ class Torrent(): if self.type is Type.V1: self.type = Type.HYBRID else: + self.type = Type.V2 def filetree(names): r = {} for key in names.keys(): @@ -56,6 +59,8 @@ class Torrent(): self.type = Type.V1 self.files[self.dict.get(b'info').get(b'name')] = self.dict.get(b'info').get(b'length') first_filename = [i for i in self.files.keys()][0] + if self.type == Type.V2 and self.hadpieces: + self.type = Type.HYBRID; if len(self.files) == 1 and self.files[first_filename] == {}: print("fixed bad single file torrent", self.sha1.hex()) self.files[first_filename] = self.dict.get(b'info').get(b'length') -- cgit v1.2.3