Wednesday, March 4, 2009

Project Report: LibraryCompare

LibraryCompare is a new XBMC Plugin that K-- and I started last Friday.

In a sense, it's an old project (meeting the needs that initially drove us to design Movie Hoard), but the methodology is new.

Movie Hoard, as I explained before, was intended to provide us with an easily searchable list of the media in each of our personal libraries. To do this, it relied on an Indexer that would crawl our media files, research the files it found (by parsing the file and folder names and scraping webpages like IMDb and TVGuide.com for details), and then add them to a faux database we'd designed.

In my last project report on Movie Hoard I suggested that our goals for it were to convert it to a real SQL database and then implement the browser within XBMC as a plugin, using XBMC's menu and display capabilities to handle user interface.

As we researched that, though, we kept running into documentation that referred to XBMC's video library. We finally took some time to investigate that, and were impressed with the indexing and web-scraping functionality already built into XBMC. Rather than duplicate that functionality by porting our existing code, we spent some time over the weekend learning how to access XBMC's built-in database, and then query for the information we need and share it remotely.

XBMC already has all the tools we need for this project, thanks to their robust HTTP API, which lets an XBMC installation receive network queries and process them as native client commands (and then generate a response in the form of an easily-parsed HTML page).

To get LibraryCompare up and running, we had to:
  • Develop a functional HTML parser
  • Learn how to authenticate to XBMC (because we want to password-protect our XBMC installs if we're going to expose them to the web)
  • Learn the database design for XBMC's video library and develop useful queries

We spent several days of trial-and-error before we came to a satisfactory solution on all three of those, but ultimately we were able to develop a function that takes in a SQL query and login credentials, authenticates to a remote XBOX, passes it the SQL query and receives back an HTML page, parses the HTML, and builds a Python list, which it returns. Once that function was finished, network communication became trivial.

Beyond that, the only real challenge was display. Within a couple hours (before we'd even figured out authentication) we had a simple list display, but XBMC has extensive tools for browsing media files of precisely the sort we're using, and the database we're drawing from already stores all the details needed to showcase that functionality, so it's just a matter of tracking down exactly what we need and implementing it.

In case that wasn't a terribly clear paragraph, we've got the core browsing functionality done, but we're still working on aesthetic improvements. Once we've finished with those, I'll be able to launch the plugin and browse through K--'s TV shows and movie files with exactly the same interface I would use to browse through the ones I have stored locally. In fact, plugin automatically filters out any items that exist in the local database, so I'm only browsing the ones he has that I don't. It's very cool.

Of course, I won't be able to play files this way -- they are far too large and our upload limits far too small to stream these videos across the internet -- but it's still quite cool to be able to tell at a glance who has what. We've been able to do this in a fairly generic manner, with no fancy packages and very little customization, so we should ultimately be able to share this plugin with the XBMC community. I'm looking forward to that.

Status: In development

No comments:

Post a Comment