Esempio 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
Esempio 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
def create_torrent(resource, torrent, trackers, name=None, comment=""):
    t = Torrent(
        path=resource,
        trackers=trackers,
        comment=comment,
        name=name,
    )
    t.generate()
    t.write(torrent)
Esempio n. 4
0
def make_torrent(content_path, tracker, output_name):
    t = Torrent(path=content_path, trackers=[tracker], comment='-')
    t.generate()

    torrent_path = output_name + ".torrent"

    if os.path.exists(torrent_path):
        os.remove(torrent_path)
    t.write(torrent_path)
    return torrent_path
Esempio n. 5
0
def create_torrent_file(torrent, f, name):
    fpath = getwritepath(f.sha256)
    t = Torrent(path=fpath,
                name=name,
                trackers=["%s:5555/announce" % fhost_url()])
    t.generate()
    tpath = "%s.torrent" % fpath
    t.write(tpath)
    torrent.magnet = str(t.magnet())

    # TODO: Check for errors here and don't hardcode the paths.
    subprocess.run([
        "transmission-remote",
        "transmission:9091",
        "-N",
        "/app/config/transmission.netrc",
        "-x",
        "-y",
        "-a",
        tpath,
        "--find",
        "/downloads",
    ])
        "domaine": "millegrilles.domaines.GrosFichiers.torrent",
        "estampille": 1575149613,
        "hachage-contenu": "A7Y96fpsP8YNLLCrXO31qHLihY3CFUBgcjqiv+JVWho=",
        "uuid-transaction": "0e6d9632-13b9-11ea-afcd-00155d011f09",  # UUID du torrent/collection figee
        "version": 6
    },
    "securite": '1.public',  # Niveau de securite global du torrent
    'catalogue': {
        '11656060-0ba4-11ea-8f37-0dcce7873a80.dat': {  # version / nom fichier dans archive
            # Contenu equivalent a une transaction millegrilles.domaines.GrosFichiers.nouvelleVersion.metadata
            # La millegrille qui recoit ce torrent va agir de la meme facon quelle le ferait avec une nouvelle
            # transaction (qui sera extraite et soumise sur reception du torrent).
            'uuid': '9e589c55-e2ce-4ef1-9770-b0a9b58cc8b8',  # uuid fichier
            'fuuid': '11656060-0ba4-11ea-8f37-0dcce7873a80',  # fuuid version
            'nom': 'AmazonFreeTierEC2.pdf',
            'mimetype': 'application/pdf',
            "taille": 5478,
            'sha256': '9cb0e10c033a0e1bab62596d5dc68a7d3df4b558aa103b74e5b1b409a377b695',
        }
    },
    'commentaires': "J'aime bian les torrents",
}

# Signature de sha256, par cert key_fingerprint
t.metainfo['_signature'] = 'U6OVWPkPk7ojx0Kz1xQCX02pR3w/EJuFMzvGTY42/kdpVyNjlJ7d+irh2u/fgMO3MOLZieyCWgamkHOauydIk3dtzorBtHvIemtBID482tSC815TTDTDpN3A7pzfyh/dnimR98izMROcsCdUnU0yupJOgDR/Qz+OjNb7HeowdW01EWrKOMzTcdDn2MvyK29K6nEDAAiAeUbpX7PXvxi2XkvBfwrnXeW66OGErtSg0FzxKFWp+r008G4S4Y8sk6w5LlKKh+qp92KvkY2y3VdTz6okf1PCfe4LrWsj4PKQ+YR5/6DEtS7Ff2JhnmT94wG9s7+omnu5b4GIiMA1yS2S8A=='

# t.private = True

t.generate()
t.write('/home/mathieu/tmp/dev3_archive_20191011UTC.torrent')
Esempio n. 7
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')