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.
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:
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: