0

I want to create torrents, based on daemon that checks the folder for updates and creates new torrents when new *.mp4 file is added in the folder. Here is my snippet of code, daemon works correctly, it's the torrent part that doesn't work. I'm using Torf Library to create torrents, and transmission-rpc to interface with running transmission-daemon:

def on_created(self, event):
    name = Path(event.src_path).stem
    torrent = Torrent(event.src_path, name)
    torrent.generate()
    self.transmission_client.add_torrent(str(torrent.magnet()), download_dir="/home/neverovskii/torrent_dir")

Download directory is the same, in which .mp4 files are. Torrent adds without problems, but it can't check that the data is here and can't start seeding. Transmission Web shows this: it correctly identifies file name, file size and pieces and gets info_hash, but doesn't work properly. What have I done wrong?

Braiam
  • 1
  • 11
  • 47
  • 78

1 Answers1

0

The client says "Have: 0B" which means the client does know about the data you already have.

Since Path(event.src_path) and download_dir="/home/neverovskii torrent_dir" are not necessarily the same this most likely is because you're pointing the client to a location where the files currently aren't. In other words in addition to telling it about the metadata you also need to tell it about the files.

Additionally .add_torrent(str(torrent.magnet()), will be a problem because magnet links contain less information than a .torrent file. The extra information in a torrent file can be used by a client to start seeding pre-existing data rather than having to fetch data from another client. In other words it is needed when you want to be the initial seeder of a torrent.

So you should pass the entire torrent file to the client instead and point it to the correct location where the data can be found. Then you may have to tell it to re-check the data and start seeding.

the8472
  • 40,999
  • 5
  • 70
  • 122
  • Well, instead of using download_dir='string', to ensure that the download path is the same I decided to create the variable that holds path to the folder in question. For me it was folder_path = '/home/neverovskii/Documents'. I scan it, and then direct new torrents to this location. Then, I changed the code to create .torrent files and use them instead. These two fixes didn't work. But what worked is using transmission-create command instead of torf library. Transmission immediately verified files and began seeding. I'll update the question when I research how to use torf correctly. – Nikita Neverovskii Aug 13 '21 at 12:30