Something Way Less Dry: TV Shows


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:

About these ads

33 thoughts on “Something Way Less Dry: TV Shows

  1. 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)

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

  3. 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!

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

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

  6. 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!

  7. Pingback: A Little Drier But Not That Dry: Extracting Websites From Nepomuk Resources | Trueg's Blog

  8. Pingback: A Little Bit Of Query Optimization | Trueg's Blog

  9. 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 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?

          • 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!)

  10. Pingback: More Fun With TV Shows | Trueg's Blog

  11. Well, I reported the missing headers as a bug against Kubuntu and got this reply:

    Those headers/that library are not part of any public Nepomuk API. The
    Nepomuk build itself doesn’t install the files at all, so it’s not a
    packaging issue.

    ** Package changed: kubuntu-meta (Ubuntu) => kdebase-runtime (Ubuntu)

    ** Changed in: kdebase-runtime (Ubuntu)
    Status: Confirmed => Invalid

    I’ll post what you’ve written above as a reply.

    • This ended up being bounced back to KDE as a bug:
      Bug 293662 – nepomuk library unversioned but headers are shipped

      it was requested that we ship the nepomuk headers that are installed by
      kde-runtime. The reason we don’t do that currently is that we can’t guarantee a
      stable ABI for the package. While libnepomukcommon.so doesn’t seem to have any
      public headers, libnepomukdatamanagement.so does but without a properly
      versioned SONAME.
      While we have no versioned library we’re not going to ship the headers as we
      need that for the ABI checks.

  12. Pingback: A Fun Release: Nepomuk TV Namer 0.2 | Trueg's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s