Tuesday, August 14, 2012

Party Playlist Picker: An experimental project written in Python

When Google+ first came out, we were really excited about the idea of writing some open source code to showcase how you could integrate YouTube with Google+. After some brainstorming, we came up with the idea of letting people collaboratively edit a playlist in realtime, and we started hacking!

We started working on Party Playlist Picker in early 2011. We’ve always wanted to release our experiment as an open source project, and you can now download the code to see one example of integrating Google+ functionality to enrich a YouTube application.

Party Playlist Picker is a Google App Engine application written in Python. It uses a Google+ share button so that partygoers can invite their friends to come edit a playlist in realtime. That feature is based on the Google App Engine channel API. It makes use of the gdata-python-client library to talk to YouTube and the google-api-python-client library to talk to Google+. It’s currently using version 1 of the YouTube API (because that’s what gdata-python-client uses), and we used OAuth 2 for authentication. In fact, we made good use of the Python client library to manage the OAuth 2 tokens for us automatically.

There’s also a lot of jQuery-based JavaScript goodness. For instance, you can search for videos without reloading the page, and you can simply drag them to add them to the playlist. If multiple people edit the page at the same time, the list of videos is updated in realtime whenever a change is made. You can also watch videos right on the page. Last of all, it keeps track of who’s edited the playlist, and whether they’re currently editing it.

There are a bunch of subtle HTML5 tricks thrown in as well. For instance, the application supports voice search, and we made a clever use of gradients to fade overflow text in the video descriptions.

Here’s a screenshot of the application:
If you’re interested in learning more, you can play around with a running version of it, or you can download the source code and hack away! If you have any questions, post them to our developer forum.

Update: Watch JJ, Jeff, and Danny Hermes (from the App Engine Developer Relations team) talk about Party Playlist Picker as part of YouTube Developers Live:


Cheers,
--Shannon -jj Behrens and Jeffrey Posnick, YouTube API Team