rndusr / torf

Python module to create, parse and edit torrent files and magnet links
GNU General Public License v3.0
180 stars 17 forks source link

How can I make it not create a directory #26

Closed NercoLive closed 1 year ago

NercoLive commented 1 year ago

I'm struggling to make a torrent that does not create a directory for the download

for example I have video.mp4 in files : path='files/video.mp4' #Relative path from the script

When people download the torrent, I want them to only have video.mp4 in their download folder, not files/video.mp4

My files folder always contains only 1 video, but the video name can change so I prefer not to hardcode the filename in the program

Is it possible to do this ?

rndusr commented 1 year ago

You need to pass the file path, otherwise torf will create a directory torrent, regardless of how many files are in it.

You can use os.listdir() to get the name of the video file and os.path.join() to append it to the directory path.

https://docs.python.org/3/library/os.html#os.listdir https://docs.python.org/3/library/os.path.html#os.path.join

Hope that helps.