Registered Member
|
How do I write scripts that perform nepomuk searches?
Is there any command line tool for performing nepomuk searches? Or do I need to write some C/java/perl code using a nepomuk library? What I wanna do is to make "best of" directories of my photos for each of ten tags. So all photos that has both a certain tag and 5 stars should be copied to a "best of" directory. This should be done for all ten tags, therefore I want to write a script to update the "best of" directories... |
Administrator
|
Assuming you have the appropriate nepomuksearch:/ url's for your search terms, then you can use kioclient to perform the copying.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
I'm not familiar to neither kioclient nor nepomuksearch url's.
As a start, I tried to list the search result of a nepomuk search for items having the tag called my_tag using this command:
But that didn't work, the only output I had was this:
What does this mean? Is it a syntax error in the nepomuk search URL? (edit: The nepomuk search URL works fine for searches in Dolphin) Or can't it find any tag called my_tag? Or am I using kioclient in the wrong way? |
Registered Member
|
Are you sure nepomuksearch:/ is not Dolphin specific? I copy the nepomuk URL into konqueror and it cannot find the KIO slave.
connect(post, SIGNAL(readSignature()), qapp, SLOT(quit()));
|
Registered Member
|
I have no idea, I'm new to nepomuk searches.
I also tried this nepomuk search:
This search also worked in Dolphin, but gave similar output with kioclient:
|
Registered Member
|
I think using kioclient here is wrong because it only retrieves readable data. A search result is not readable in the sense kioclient requires.
These queries should fail: kioclient cat file:/// kioclient cat nepomuksearch:/?query=+hasTag:my_tag But, this works, tested on Konsole: 1. Type 'kioclient cat ' in Konsole (notice the space at the end) 2. From Dolphin's search result, drag and drop a file to the terminal. This should put a long nepomuk url. 3. Press Enter. Now the file should be print in the terminal. How to do scripting? Ruby or Python bindings Example in Ruby that should get you a starting point:
connect(post, SIGNAL(readSignature()), qapp, SLOT(quit()));
|
Registered Member
|
Well, this do print the file, but when using drag-and-drop I get the path to that specific file. Then the point of doing the search is gone... |
Registered Member
|
Actually, I had some success. Before, I tried to use 'kioclient cat', which I thought would list the matching files. But it's not listing, its printing the content assuming it's text. So I changed it to 'kioclient copy' to copy the matching files, which is what I want really.
I did like this:
I still get almost the same output, but this time it actually copies the files! Now I only have to figure out how to search for items with a certain rating... |
Registered Member
|
Now I have figured it out. I found some info on the search string syntax on this page: http://techbase.kde.org/Development/Tutorials/Metadata/Nepomuk/QueryService
With that info I figured out the search string I wanted for finding all images that are both tagged with my_tag and rated with at least 4 stars:
Then the search string has to be escaped so that ' ' becomes '%20' and '>' becomes '%3E'. So, this was my final command for copying all matching files to /tmp/best_of/:
|
Registered Member
|
What would be nice and useful is a `kiols` program. I wrote one in Ruby but it always crashes. Ideally it should be written in C++ and included in KDE runtime.
connect(post, SIGNAL(readSignature()), qapp, SLOT(quit()));
|
Registered users: bancha, Bing [Bot], Google [Bot], Sogou [Bot]