This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Referencing files in torrent from KTorrent scripting

Tags: None
(comma "," separated)
OliverHallam
Registered Member
Posts
1
Karma
0
I am trying to write a script for KTorrent in python.

However, I am having trouble locating the files in a torrent. My first attempt (from reading the API) was to use the tor.numFiles() and tor.filePathOnDisk() functions, but for some reason when a torrent contains only a single file tor.numFiles() and tor.filePathOnDisk(0) do not return a value.

As far as I can tell the only way to do this is to use tor.name() to get the file name and tor.dataDir() to get the folder location.

My function to retrieve the files in a folder looks like this:

Code: Select all
def getFiles(tor):
   count = tor.numFiles()
   if count == 0:
      return [os.path.join(tor.dataDir(), tor.name())]
   else:
      return [tor.filePathOnDisk(i) for i in range(0, count)]


Yet this still does not work. For some torrents tor.dataDir() returns "/", but I cannot work out why?

Is this a bug, or is the API just poorly documented? How else can I find the path to the data of a single file torrent in a script?
George
Moderator
Posts
5421
Karma
1
It seems the dataDir of some torrents has been corrupted, this should not happen.

However you are right I need to add a call to get the path on disk of the torrent.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot]