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
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)
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
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)
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: print( "File " + fileName + fileExtension + " is either a .torrent, has a respective .torrent or isn't of the right format, ignoring" )
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') ]) subprocess.check_call(['ln', file_name, qbt_dir])