KTorrent: Moving data in a shell script
I'm attempting to make a manuscript for my magic folder that will certainly relocate documents to a seeding directory site without KTorrent misplacing where the information is, comparable to the "Move Data" context food selection activity in the application. I've jabbed around the dbus API and also this is what I have until now:
for x in `qdbus org.ktorrent.ktorrent /core org.ktorrent.core.torrents`; do name=`qdbus org.ktorrent.ktorrent /torrent/$x org.ktorrent.torrent.name` if [ "$name" = "$1" ]; then # Tell KTorrent to move the data to the seeding directory fi done
The trouble is that I can not find anything in The API to do that, or perhaps to set the new area after relocate by hand.
I had fun with the suggestion of doing it by straight adjusting to GUI to turn on the context food selection activity (if I can get that much I would certainly be completely satisfied) and also located this:
qdbus org.ktorrent.ktorrent /ktorrent/MainWindow_1 org.kde.KMainWindow.activateAction view_move_data
Which does what I desire yet constantly for the presently picked gush, and also I can not also identify the very first step to picking the gush I in fact intend to relocate.
Any kind of suggestions?
I located a far better remedy to my trouble. As opposed to having my finished downloads relocated to a details directory site and afterwards returned when I'm performed with them, I made a KTorrent Script that captures the completed signal and also develops a symbolic link to the documents in the directory site I intend to see them in. When I'm performed with them I can simply delete the symbolic link and also never ever need to relocate the real information, which is far more reliable anyhow.
I've made the packaged manuscript and also resource readily available below:
yet I'll upload the materials of the major manuscript below simply in instance.
#!/usr/bin/env kross # -*- coding: utf-8 -*- import KTorrent import KTScriptingPlugin import Kross import os import socket class FileLinker: def __init__(self): self.link_dir = KTScriptingPlugin.readConfigEntry("downloads","completedDir",os.path.expanduser("~/"))+"/" if self.link_dir.startswith("file://"): self.link_dir = self.link_dir[7:] KTorrent.log("linkDir is "+self.link_dir) KTorrent.connect("torrentAdded(const QString &)",self.torrentAdded) tors = KTorrent.torrents() # bind to signals for each torrent for t in tors: self.torrentAdded(t) def torrentFinished(self,tor): KTorrent.log("Symlinking "+tor.pathOnDisk()+" to "+self.link_dir+tor.name()) os.symlink(""+tor.pathOnDisk(),""+self.link_dir+tor.name()) def connectSignals(self,tor): KTorrent.log("connectSignals " + tor.name()) tor.connect("finished(QObject* )",self.torrentFinished) def torrentAdded(self,ih): tor = KTorrent.torrent(ih) self.connectSignals(tor) # load settings linker = FileLinker() def unload(): global linker del linker