[Nepomuk] Retrieve "linked" artwork file
daitheflu at free.fr
daitheflu at free.fr
Tue Oct 18 08:54:28 UTC 2011
Hi,
Thanks Sebastian, that helped me *a lot*.
I checked with NepomukShell and discovered that my artwork Resource had no NIE:url !
I thought that the constructor would have automatically set it but it didn't, and it does not.
Since the following wasn't sufficient :
img = Nepomuk.Resource(coverpath, OntologiesUrls.image())
I just added :
img = Nepomuk.Resource(coverpath, OntologiesUrls.image())
img.setProperty(OntologiesUrls.url(), coverpath)
And that did the trick :)
It's now working like a charm !
As for your Python tool that generate ontologies, that could be very interesting.
I could have write one by myself, but I was too lazy. So I just hardcoded the one I needed.
If yours is not too difficult to understand and if you're OK, I could maybe maintain it.
Thanks again for your help.
Cheers,
--
François
----- Mail original -----
De: "Sebastian Trüg" <trueg at kde.org>
À: nepomuk at kde.org
Envoyé: Lundi 17 Octobre 2011 20:24:54
Objet: Re: [Nepomuk] Retrieve "linked" artwork file
On 10/17/2011 04:20 PM, daitheflu at free.fr wrote:
> Hi guys,
>
> Me again. I'd like my application to link some file as an artwork for a Movie Type Resource.
> The artwork consists in a .png file, stored in some directory (that's not the important point).
>
> Here is how I "link" the file to the artwork "property" of the Movie Resource (Python code, but you'll understand) :
>
> ***
>
> # self.artwork is a QPixmap containg the artwork.
>
> if not self.artwork.isNull():
> # SNIP : saves the cover to `coverpath`.
> # `coverpath` is a KUrl instance.
>
> # Build a Resource of type NFO:image from the saved picture :
> img = Nepomuk.Resource(coverpath, OntologiesUrls.image())
This reminds me that I have a python tool somewhere which generates
ontology methods for python... have to look for it...
> # "Links" that NFO:image Resource to the NMM:artwork property of my Movie Resource :
> resource.setProperty(OntologiesUrls.artwork(), Nepomuk.Variant(img))
>
> ***
>
>
> The problem is to get the .png file back. Here is what I tried :
>
>
> ***
>
> # Get the Resource linked by the NMM:artwork property :
> artwork = resource.property(OntologiesUrls.artwork())
>
> if artwork.isValid():
> imgResource = artwork.toResource()
> res.artwork = PictureLoader.load_pixmap(imgResource.toFile().url())
>
> ***
>
> The problem is that `imgResource.toFile().url()` returns an empty KUrl.
>
> Am I missing something ? What did I misunderstood ? How can I retrieve and load the linked artwork file ?
it looks correct. Maybe use nepomukshell to look at the resources to
make sure. You can use a query like "select * where { ?r nmm:artwork ?v
. }" and then double-click on the resource.
Cheers,
Sebastian
_______________________________________________
Nepomuk mailing list
Nepomuk at kde.org
https://mail.kde.org/mailman/listinfo/nepomuk
More information about the Nepomuk
mailing list