@@ -0,0 +1,1127 @@
+from gdata.youtube.service import YouTubeService, YouTubeVideoQuery%0A%0Aclass YoutubeMusic:%0A    def __init__(self):%0A        self.service = YouTubeService()%0A%0A    def search(self, artist):%0A        query = YouTubeVideoQuery()%0A        query.vq = artist%0A        query.orderby = 'viewCount'%0A        query.racy = 'exclude'%0A        query.categories.append(%22/Music%22)%0A        feed = self.service.YouTubeQuery(query)%0A        results = %5B%5D%0A        for entry in feed.entry:%0A            if not self.is_valid_entry(artist, entry):%0A                continue%0A            results.append(%7B%0A                'url': entry.media.player.url,%0A                'duration': int(entry.media.duration.seconds),%0A                'rating': float(entry.rating.average),%0A            %7D)%0A        return results%0A%0A    def is_valid_entry(self, artist, entry):%0A        duration = int(entry.media.duration.seconds)%0A        if float(entry.rating.average) %3C 3:%0A            return False%0A        if duration %3C (2 * 60) or duration %3E (9 * 60):%0A            return False%0A        if artist.lower() not in entry.media.title.text.lower():%0A            return False%0A        return True%0A

Query youtube w/ gdata.youtube