Example #1
0
    def create_new_torrent(self):
        from dottorrent import Torrent

        report.info(ui_text.new_tor)
        t = Torrent(self.torrent_folder_path, private=True)
        t.generate()

        # dottorrent creates dict with string keys.
        # Following code will add bytes keys. and key type must be uniform for bencoder to encode.
        utils.dict_stringkeys_to_bytes(t.data)
        return t.data
def make_torrent(location, comment):
    try:
        t = Torrent(location,
                    trackers=['udp://bucketvids.com:2255'],
                    private=True,
                    comment=comment,
                    include_md5=True)

        logger.info("Generating torrent for location : %s ... " % (location))
        t.generate()

        filename = location.split('/')[-1] + '.torrent'
        path = os.path.join(os.getcwd(), filename)
        print(path)
        logger.info("Torrent file be saved in path : %s" % (path))

        with open(path, 'wb') as fp:
            t.save(fp)
            logger.info("Torrent saved! Enjoy seeding ...")
        return True

    except FileNotFoundError:
        logger.error("File(s) not found")
        return False
    except Exception as e:
        raise e
Example #3
0
def createTorrent(videoFile):
    torrent = Torrent(path=str(videoFile), trackers=[trackerUrl], private=True)
    print(torrent.get_info())
    print("Starting Torrent...")
    if torrent.generate(progressCallback) == True:
        print("Torrent generated succesful!")
        with open('%s.torrent' % (videoFile), 'wb') as file:
            torrent.save(file)
Example #4
0
def generate_torrent(path):
    """Call the dottorrent function to generate a torrent."""
    click.secho("Generating torrent file...", fg="yellow", nl=False)
    t = Torrent(path, trackers=[RED_API.announce], private=True, source="RED")
    t.generate()
    tpath = os.path.join(tempfile.gettempdir(), f"{os.path.basename(path)}.torrent")
    with open(tpath, "wb") as tf:
        t.save(tf)
    click.secho(" done!", fg="yellow")
    return tpath, open(tpath, "rb")
def make_torrent(location):
	try:
		t = Torrent(
			location,
			trackers = ['udp://192.168.10.109:3535'],
			private = True,
			comment = "Download made available by Datahut",
			include_md5 = True
			)

		t.generate()

		filename = location.split('/')[-1] + '.torrent'
		path = os.path.join(os.getcwd(),filename)
		print("Path : ",path)

		with open(path, 'wb') as fp:
			t.save(fp)

	except FileNotFoundError:
		print("File not found")
		return False
	except Exception as e:
		raise e
Example #6
0
from dottorrent import Torrent

t = Torrent('VIDEO FILES/djbill265.mp4', trackers=['http://tracker.openbittorrent.com:80/announce'])
t.generate()
with open('mydata.torrent', 'wb') as f:
        t.save(f)
rootDir = "Vods/"  # The root directory for the files

if not os.path.isdir(rootDir):
    sys.exit("rootDir is not a valid directory")

for root, directories, files in os.walk(rootDir):
    for file in files:
        filePath = rootDir + os.path.join(os.path.relpath(root, rootDir), file)
        fileName, fileExtension = os.path.splitext(filePath)
        if fileExtension != '.torrent' and (
            (os.path.splitext(file)[0] + '.torrent')
                not in files) and file.endswith(tuple(videoFormats)):
            # Torrent library documentation can be found here https://dottorrent.readthedocs.io/en/latest/library.html
            torrent = Torrent(filePath,
                              trackers=trackerList,
                              creation_date=datetime.now(),
                              comment="Jefmajor vod " + fileName,
                              private=False)
            if not torrent.generate():
                print("Error generating torrent for " + filePath +
                      fileExtension)
                continue

            torrentPath = fileName + ".torrent"  # Just adjusting the .torrent file name to be file - extension + .torrent

            # Saving torrent
            torrentFile = open(torrentPath, 'wb')
            torrent.save(torrentFile)
            torrentFile.close()
            print("Created .torrent for " + fileName + fileExtension)
        else:
Example #8
0
    file_name = path.join(csv_dir,
                          'mediathek-{:%Y%m%d-%H%M%S}.csv'.format(today))

    with open(file_name, mode='w', newline='') as csv_file:
        db.export_streams(csv_file)

    # Compress CSV file using XZ
    subprocess.check_call(['xz', '-z', file_name])

    file_name += '.xz'

    logging.info("Exported streams to '%s'.", file_name)

    # Create torrent of compressed CSV file
    torrent = Torrent(path=file_name,
                      trackers=[tracker_url],
                      creation_date=today)
    torrent.generate()

    file_name += '.torrent'

    with open(file_name, mode='wb') as torrent_file:
        torrent.save(torrent_file)

    logging.info("Created torrent at '%s'.", file_name)

    # Publish torrent via HTTP and qBt
    subprocess.check_call([
        'ln', '-f', file_name,
        path.join(www_dir, 'mediathek.csv.xz.torrent')
    ])