Exemplo n.º 1
0
    def generate_torrent():

        print(" [*] Generating the torrent file...")

        try:

            with open('/tmp/{}.txt'.format(randname), 'w') as f:
                f.write(string_generator(20))
            f.close()

            t = Torrent(
                path='/tmp/{}.txt'.format(randname),
                trackers=[
                    'https://tracker1.{}.org:1234/announce'.format(randname),
                    'https://tracker2.{}.org:5678/announce'.format(randname)
                ],
                comment='*****@*****.**')
            t.private = True
            t.generate()
            t.write('/tmp/{}.torrent'.format(randname))

        except Exception as e:
            print(e)
            print(" [*] Failed to generate the torrent due and error.")
            sys.exit(1)

        else:
            print(" [*] Torrent generated with success!")
            return True
Exemplo n.º 2
0
def createtorrent(authkey, directory, filename, releasedata):
    t = Torrent(
        path=directory, trackers=[authkey]
    )  # Torf requires we store authkeys in a list object. This makes it easier to add multiple announce urls.
    # Set torrent to private as standard practice for private trackers
    t.private = True
    t.generate()
    ## Format releasedata to bring a suitable torrent name.
    # The reason we don't just use the directory name is because of an error in POSTING.
    # POSTS do not seem to POST hangul/jp characters alongside files.
    filename = f"{releasedata['artist']} - {releasedata['title']} [{releasedata['media']}-{releasedata['format']}].torrent"

    try:
        t.write(filename)
        print("_" * 100)
        print("Torrent creation:\n")
        print(f"{filename} has been created.")
    except:
        print("_" * 100)
        print("Torrent creation:\n")
        os.remove(filename)
        print(f"{filename} already exists, existing torrent will be replaced.")
        t.write(filename)
        print(f"{filename} has been created.")

    return filename
Exemplo n.º 3
0
from torf import Torrent

t = Torrent(path='C:/Users/Profesor/Documents/arquisoft',
            trackers=['udp://tracker.openbittorrent.com:80/announce'],
            comment='This is a comment')
t.private = False
t.generate()
t.write('C:/Users/Profesor/Documents/monitoria/nueva/torrents/ultimo.torrent')