Friday, December 24, 2010

Checking-In at GetGlue with MythTV



GetGlue is a leading social network for entertainment. Fans use GetGlue apps to check-in while consuming entertainment to share with friends. I wrote a Python script that enables MythTV to automatically check-in to GetGlue with the recording you are watching.

GetGlue provides an application programming interface (API) that uses OAuth for authorization.

NOTE/RANT: I don't think I'm supposed to share my oAuth developer keys. I don't know how the architects of oAuth expected us to deliver scripts. I guess they assume everything would be web based. Until someone tells me different I'm not going to release my oAuth keys. So, I guess you'll need to apply for developer keys and plug them in to my python script.
To obtain a GetGlue developer key, please e-mail api@getglue.com with your name, company name, app name, and OAuth callback (not needed for this), as well as a short description of the application.

Below are the high level steps to get this working and its accompanying video tutorial. These steps were performed on an Ubuntu 10.04 MythTV frontend PC.



  • Download my python script.
  • Apply and receive developer keys from emailing a request to api@getglue.com. See rant above.
  • Copy and paste your oAuth developer keys in my script variables CONSUMER_KEY and CONSUMER_SECRET.
  • Install Python Setup tools - sudo apt-get install python-setuptools
  • Download and install OAuth library. - sudo python setup.py
  • Authorize the app one time in a terminal - python MythTVGetGlueCheckin4.py testtest
  • Copy the OAuth token file in to the mythtv user's directory.  sudo cp ~/.MythTVGetGlueCheckin /home/mythtv/.
  • Change owner to mythtv user. sudo chown mythtv /home/mythtv/.MythTVGetGlueCheckin
  • Change group to mythtv user. sudo chgrp mythtv /home/mythtv/.MythTVGetGlueCheckin
  • Set MythTV system event - Playback started
  • Watch some TV recordings and MythTV will automatically check-in to GetGlue. See my GetGlue profile for an example.





    http://www.youtube.com/watch?v=z_vWfWa7Ls0
  • 5 comments:

    Noah said...

    Pat thank you for this.

    Is there anyway you can add logic to parse shows with ampersands (&) and colons

    I tried this

    python /usr/local/bin/MythTVGetGlueCheckins4.py 'Kimora: Life in the Fab Lane'

    302InvalidObjectUnable to find object: tv_shows/kimora_life_in_the_fab_lane

    python /usr/local/bin/MythTVGetGlueCheckins4.py 'Brandy & Ray J: A Family Business'


    302

    InvalidObjectUnable to find object: tv_shows/brandy_

    Patrick L Archibald said...

    Hi Noah

    My method of composing the object name is a hack but the only method I could get working. I've posted a new version of MythTVGetGlueCheckin4.py that includes some more hacks for the 2 shows you had trouble with. Just replace the fixupTitle() method with the latest version.

    I wanted to use the MythTV programid to look up the show at Zap2it.com but unfortunately you need the show title at Zap2it.com too.

    So, feel free to hack on the fixupTitle() method as you see fit.

    How long have you been a MythTV user?

    Rock on, PLA

    Noah said...

    Thanks. I've been using Mythtv since
    July 19, 2005.

    http://www.mythtv.org/wiki/User:Nswint

    Chimo said...

    Hi Patrick,
    You might know this by now but some OAuth implementations (ex: Google's and StatusNet's) allow for "anonymous" consumer key/secret.

    I don't know if GetGlue supports this or not, but it might come in handy for anyone reading this later.

    More information here: http://code.google.com/apis/accounts/docs/OAuth_ref.html#SigningOAuth

    And here: http://www.ioncannon.net/programming/1443/google-oauth-for-installed-apps-php-example/

    Unknown said...

    Hi,
    how can I get consumer key and secret from getglue? They want to know the app, the company ecc ecc... But I only want to use your python script for automatic check in.
    Thank you in advance