server icon indicating copy to clipboard operation
server copied to clipboard

Please implement creation of new torrents from files

Open zackees opened this issue 3 years ago • 2 comments

Looking at using this as a replacement for centralized video file distribution. However this doesn't allow file upload, which creators could use to upload all of their videos. Or event point it to an existing directory of files and have it automatically create a torrent file side by side with the video files

zackees avatar Feb 11 '22 01:02 zackees

I'm planning on adding a way of creating torrents, but that would require the files to exist on the server. Would that work? Or are you asking for a way to upload files to PicoTorrent server and have it create a torrent from those files?

vktr avatar Feb 11 '22 08:02 vktr

Thanks for your response and you awesome library.

Let me clarify what I mean, supposed I'm running a server and I want to do decentralized video distribution of my own legal content that I created.

Assume tall my video is in folder /video

So when I start the picotorrent server I would like to do the following:

npm run serve --import /video/*.mp4 --auto-add-torrents

Which would translate roughly to...

(Psuedo code)

threads = []
for each file in import_dir:
  let torrent_file = file + ".torrent"
  if (not torrent_file.exists() or torrent_file.hash() != hash(file)):
    make_torrent(input=file, output=torrent_file)
    assert(torrent_file.exists())
  sqlite_db.add_or_replace({file: torrent_file})
  threads.add(new_seeding_thread(file, torrent_file))

if auto_add_torrents():
  while True:
     wait_for_ctrl_c(timeout=1000)  # one second
     scan_for_new_torrents(in=import_dir, out=threads)   # adds to thread array
else:
  wait_for_ctrl_c(timeout=-1)  # Wait forever

I've looked for hours and hours and nothing really does the above task well. I have to figuratively duct tape a bunch of commands together to do the above. I have to use a gui in order to start the seeding using one of the legacy clients. I get that this is a throw back to the 2006 era where most of the users were consumers that never touched the command line, but in 2022 all your users are going to be developers and that want to be able to spin up swarm downloading protocol for legal content with the minimal amount of work necessary.

Also about creating torrents, that seems to be a solved problem and you should be able to import another library to do this easily. The big part is simply bulk seeding a bunch of content, and be able to gently resume this after a system restart of the host.

This scheme could scale to terrabytes of data stored locally.

Thanks for the great software.

~Zach

zackees avatar Feb 11 '22 23:02 zackees