[Nepomuk] Retrieve "linked" artwork file
Sebastian Trüg
trueg at kde.org
Mon Oct 17 18:24:54 UTC 2011
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
More information about the Nepomuk
mailing list