After my rather boring blog about change notifications I will now to write about something that I wanted every since I started developing Nepomuk. But only now has Nepomuk reached a point where it provides all the necessary pieces. I am talking about TV Show management – obviously I mean the rips from the DVD boxes I own.
So what about it? Well, I wrote a little tool called nepomuktvnamer (inspired by the great python tool tvnamer) which works a bit like our nepomukindexer except that it does not extract meta-data from the file but tries to fetch information about TV Shows from thetvdb.com. You can run the tool on a single file or recursively on a whole directory. It will then use a set of regular expressions (based on the ones from tvnamer) to analyze the file names and extract the show title, season and episode numbers.

The nepomuktvnamer will ask the user in case multiple matches have been found and cannot be filtered according to season and episode numbers
It will then save that information into Nepomuk through our powerful Data Management API. The code looks a bit as follows ignoring code to store actors, banners and the like.
const Tvdb::Series series = getSeriesForName(name); Nepomuk::NMM::TVSeries seriesRes; seriesRes.setTitle(series.name()); seriesRes.addDescription(series.overview()); Nepomuk::NMM::TVShow episodeRes(url); episodeRes.setEpisodeNumber(episode); episodeRes.setSeason(season); episodeRes.setTitle(series[season][episode].name()); episodeRes.setSynopsis(series[season][episode].overview()); episodeRes.setReleaseDate(QDateTime(series[season][episode].firstAired(), QTime(), Qt::UTC)); episodeRes.setGenres(series.genres()); seriesRes.addEpisode(episodeRes.uri()); episodeRes.setSeries(seriesRes.uri()); Nepomuk::SimpleResourceGraph graph; graph << episodeRes << seriesRes; Nepomuk::storeResources(graph, Nepomuk::IdentifyNew, Nepomuk::OverwriteProperties)
(This code uses my very own LibTvdb which is essentially a Qt’ish wrapper around the thetvdb.org API.)
The result of this can be seen in Dolphin:
Here we see the actors, the series, the synopsis and so on. Clicking on an actor will bring up all they played in, clicking on the series will bring up all the episodes from that series, and so on.
Now let us have a look at the series itself using my beefed up version of the Nepomuk KIO slave:
As we can see the nepomuktvnamer also fetched a banner which is stored as nie:depiction. (A reason why to compile nepomuktvnamer you need the git master version of shared-desktop-ontologies. Oh, and also nepomuktvnamer is linked against libnepomukcore from nepomuk-core instead of libnepomuk. So you either have to install nepomuk-core which cab be a bit tricky or quickly change the CMakeLists.txt to link to libnepomuk instead.)
We can of course also query the newly created information. Simple queries in Dolphin could be “series:Sherlock” or “sherlock season=1″. Well, things to play with.
I also created the smallest Nepomuk service to date: the nepomuktvnamerservice uses the ResourceWatcher to listen for newly created nfo:Video resources and simply calls the nepomuktvnamer on the related file.
Last but not least the git repository contains a python script which checks for each existing series if a new episode has been aired. The output looks a bit like this:
White Collar - New episode "Withdrawal" (02x01) first aired 13 July 2010. Freaks and Geeks - No new episode found. The Mentalist - Upcoming episode "Red is the New Black" (04x13) will air 02 February 2012.
Now obviously this is more a task for a Plasma applet. So if anyone out there is interested in doing that – please go ahead. I think it could be a cool thing. One basically only has to update whenever a new nmm:TVShow is created or when the new day dawns.
And the cherry on top is of course Bangarang:

That’s really cool! Thigns are coming together!
For even more fun, you could try to map the IDs of things from TheTVDB to TvTropes/DbTropes (http://dbtropes.org) – and you enable lots of weird searches, like show me all episodes that are “so bad it’s horrible” or an “evil genius” character.
(Your link to tvdb is broken btw – it’s thetvdb.COM)
I have one comment for you: http://dbtropes.org/resource/Main/BeardOfEvil :D
And yes, this is something I will most certainly play with. Looks like tons of fun.
i just love you.
Bangarang actually already does quite some of the described things and isn’t only usable to display these information.
- Extract series name, season and episode from filenames
- Fetch additional information from TVDB (or other sources).
It looks like your approach is a little more advanced and more tightly integrated with DMS and the filewatch service, but I’m pretty sure Bangarang and Nepomuk could quite profit from each other to make this feature even more streamlined and seamlessly integrated into KDE.
so now bangarang can fetch informations by itself? nice to know, i must try it again :-)
Awesome Sebastian!!
Ohh this is the seamless desktop experience that crashed into my brain the day I became aware of nepomuk and started working on Bangarang. Looks like there a couple properties (synopsis, backlinks, etc.) to coordinate on but easy enough to fix!
Cool stuff!
I think it is mostly nmm:synopsis (although I am not entirely sure of its actual usefulness) and depiction. The latter I will release in an SDO update soon.
Hi. Nice to read this! Does this also fix my problem indexing my tv series (avi files)? I wrote you some (german) emails about that. Do you remember?
No, sorry. This is unrelated. The avi indexing needs to be fixed in libstreamanalyzer.
I wish that XBMC could leverage this or tracker. I tinkered a bit with pulling metadata out of xbmc and putting it into tracker, but it just didn’t come together fluidly. Thanks for providing a resolution to my previous rants (http://clockwerx.blogspot.com/2011/01/xbmc-vs-boxee-vs-file-browsers.html)
Does this mean, that it has become relatively simple to automatically add metadata for movies and songs via themoviedb.org and musicbrainz.org as well?
Thanks for working on this
Sure, it is the same thing basically.
That is awesome! First of all, finally gives a nice, practical explanation to those who don’t understand the point of this nepomuk service that’s always running. Second, it’s something I’ve been looking for myself. And, third, I hope this blog post gets publicized. It’d be great to have a plasmoid to search this and/or edit. And it’d be great to see it integrated into XMB or Plex or something.
The link redirects to nepomuk-tvnamer and last change is “Wed, 08 Jun 2011 16:07:21 +0000″ but there is other project nepomuktvnamer and last change is “Fri, 27 Jan 2012 16:15:29 +0000″ so I assumed that the right one is the second project.
But as you explain I can’t compile because I’m using official openSUSE KDE 4.8.0 packages.
You are of course correct. I updated the link and removed the outdated repository.
I also changed the build system do it links to kdelibs instead of nepomuk-core. You should be able to use it now.
Thank you very much :).
Now compile and installs but LibTvdb git version is required too because project don’t compile with version 0.2.1.
This is a terrific use case to nepomuk and even I don’t need to do any changes to nepoogle, this is great!. So I added an entry to my nepomuk’s service menu and now I have a more comfortable method to add metadata to my media files than lauching Bangarang. I think that it’s a shame that Bangarang fetchers are not implemented externally like this one.
Without doubt this is the type of use for Nepomuk I imagined when I heard about it first when KDE 4.0 was released.
Great job!
I just released LibTvdb 0.3.0. Now the only thing missing is an SDO release which I will do shortly.
Pingback: A Little Drier But Not That Dry: Extracting Websites From Nepomuk Resources | Trueg's Blog
Pingback: A Little Bit Of Query Optimization | Trueg's Blog
I’m having a problem building this; I’ve had the same problem before building Nepomuk based stuff…
tvnamer.h:34:36: fatal error: nepomuk/simpleresource.h: No such file or directory
Previously that was because I had an older KDE build, but I’m using Kubuntu (KDE 4.8, Ubuntu 11.10); I have /usr/include/nepomuk but no ‘simpleresource.h’.
I can see it in the KDE 4.6 API Reference at api.kde.org.
Is this a packaging bug or am I missing something obvious…?
I suppose you need kde-runtime-devel or something like that.
I have the same problem in ubuntu. The kdebase-runtime-dev package does not exist and the headers instaled with kdelibs correspond to the old “resource” api.
I tried to compile nepomuk-core but it seems to break things. Could you make a post on how nepomuk-core kdelibs/nepomuk and kde-runtime/nepomuk are suposed to interact together?
Compiling nepomuk-core does not help. You need the development files from kde-runtime. I am not familiar enough with Kubuntu to tell you how to install those.
Ok, thanks for the confirmation Luis, I’m not (in this case) crazy or stupid.
Thanks, Sebastian, I’m guessing packaging bug if you expect the headers to be in the main KDE includes.
I have tried installing pretty much all of the kde-dev-xxx modules in Kubuntu, including some experimental stuff; none have the Nepomuk headers (although, I’m sure they were in there at some point around 4.6 transition – I can’t find the posts at kde.org I wrote at that time).
I’ll go and hassle the Kubuntu folks – they’re responsive if someone reports the problem (ie: it took a while but they finally put the right libstreamanalyzer into the distro and that made life much better!)
It’s on launchpad as question #186847 if any Kubuntu folks are wandering by… I’m hoping I don’t have to do another dist-upgrade because my internet connection is puny.
These headers were introduced in KDE 4.7 and were always a part of kde-runtime due to the freeze of kdelibs. They are also part of nepomuk-core but installing that along-side kdelibs is a bit ugly at the moment.
Pingback: More Fun With TV Shows | Trueg's Blog
Well, I reported the missing headers as a bug against Kubuntu and got this reply:
I’ll post what you’ve written above as a reply.
Pingback: A Fun Release: Nepomuk TV Namer 0.2 | Trueg's Blog