def getWatchLater(): feed = OmniUtil.Feedback() gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_WATCHLATER) if gdataResults: for i in gdataResults: feed.add_item( i['title']['$t'], '%s - %s' % (i['media$group']['media$credit'][0]['yt$display'], OmniUtil.secondsToHuman( int(i['media$group']['yt$duration']['seconds']))), 'http://www.youtube.com/watch?v=%s' % i['media$group']['yt$videoid']['$t'], '', '', '%sListBlock.png' % OmniUtil.ICONS) else: feed.add_item('No Results', 'No videos from "Watch Later" could be found', '', '', '', '%sX.png' % OmniUtil.ICONS) return feed
def getUploads(): OmniUtil.validStart() feed = OmniUtil.Feedback() gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_UPLOADS) if gdataResults: for i in gdataResults: feed.add_item( i['title']['$t'], '%s - %s' % (i['author'][0]['name']['$t'], OmniUtil.secondsToHuman( int(i['media$group']['yt$duration']['seconds']))), 'http://www.youtube.com/watch?v=%s' % i['media$group']['yt$videoid']['$t'], '', '', '%sListBlock.png' % OmniUtil.ICONS) else: feed.add_item('No Results', 'No videos from your uploads could be found', '', '', '', '%sX.png' % OmniUtil.ICONS) return feed
def getPlaylists(): OmniUtil.validStart() feed = OmniUtil.Feedback() gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_USER_PLAYLIST) feed.add_item(u'\u2329 New Playlist \u232A', '', "{'key':'newplaylist'}", '', '', '%sAddList.png' % OmniUtil.ICONS) if gdataResults: for i in gdataResults: feed.add_item( i['title']['$t'], '%s - %s videos' % (i['author'][0]['name']['$t'], i['yt$countHint']['$t']), 'http://www.youtube.com/playlist?list=%s' % i['yt$playlistId']['$t'], '', '', '%sListBlock.png' % OmniUtil.ICONS) else: feed.add_item('No Results', 'No playlists on your account could be found', '', '', '', '%sX.png' % OmniUtil.ICONS) return feed
def getHistory(): OmniUtil.validStart() feed = OmniUtil.Feedback() gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_HISTORY) if gdataResults: feed.add_item(u'\u2329 Clear History \u232A', '', "{'key':'wipehistory'}", '', '', '%sErase.png' % OmniUtil.ICONS) for i in gdataResults: feed.add_item( i['title']['$t'], '%s - %s' % (i['media$group']['media$credit'][0]['yt$display'], OmniUtil.secondsToHuman( int(i['media$group']['yt$duration']['seconds']))), 'http://www.youtube.com/watch?v=%s' % i['media$group']['yt$videoid']['$t'], '', '', '%sListBlock.png' % OmniUtil.ICONS) else: feed.add_item('No Results', 'No videos in your history could be found', '', '', '', '%sX.png' % OmniUtil.ICONS) return feed
def queryPlaylist(query): OmniUtil.validStart() feed = OmniUtil.Feedback() gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_PLAYLIST, param1={ 'max-results': '9', 'q': query }) if gdataResults: for i in gdataResults: feed.add_item( i['title']['$t'], '%s - %s videos' % (i['author'][0]['name']['$t'], i['yt$countHint']['$t']), 'http://www.youtube.com/playlist?list=%s' % i['yt$playlistId']['$t'], '', '', '%sListBlock.png' % OmniUtil.ICONS) else: feed.add_item('No Results', 'No results for "%s" could be found' % query, '', '', '', '%sX.png' % OmniUtil.ICONS) return feed
def getSubscriptions(): OmniUtil.validStart() feed = OmniUtil.Feedback() gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_SUBSCRIPTIONS) if gdataResults: for i in gdataResults: if not os.path.exists( '%s%s.jpg' % (OmniUtil.SUBSCRIPTIONS, i['yt$channelId']['$t'])): OmniUtil.retrieveThumb(i['yt$channelId']['$t']) feed.add_item( i['yt$username']['display'], '%s videos' % i['yt$countHint']['$t'], 'http://www.youtube.com/channel/%s' % i['yt$channelId']['$t'], '', '', '%s%s.jpg' % (OmniUtil.SUBSCRIPTIONS, i['yt$channelId']['$t'])) else: feed.add_item('No Results', 'No results for your subscriptions could be found', '', '', '', '%sX.png' % OmniUtil.ICONS) return feed
def getPlaylistFeed(query): OmniUtil.validStart() feed = OmniUtil.Feedback() gdataResults = OmniUtil.gdataLoad( OmniUtil.BASE_PLAYLIST_FEED % OmniUtil.__urlParse__(query).query.split('=')[1]) if gdataResults: for i in gdataResults: feed.add_item( i['title']['$t'], '%s - %s' % (i['media$group']['media$credit'][0]['yt$display'], OmniUtil.secondsToHuman( int(i['media$group']['yt$duration']['seconds']))), 'http://www.youtube.com/watch?v=%s' % i['media$group']['yt$videoid']['$t'], '', '', '%sListBlock.png' % OmniUtil.ICONS) else: feed.add_item('No Results', 'No feed results for "%s" could be found' % query, '', '', '', '%sX.png' % OmniUtil.ICONS) return feed
def getFeed(): OmniUtil.validStart() feed = OmniUtil.Feedback() gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_FEED) if gdataResults: for i in gdataResults: if not os.path.exists( '%s%s.jpg' % (OmniUtil.SUBSCRIPTIONS, i['author'][0]['yt$userId']['$t'])): OmniUtil.retrieveThumb(i['author'][0]['yt$userId']['$t']) feed.add_item( i['title']['$t'], '%s - %s' % (i['author'][0]['name']['$t'], OmniUtil.secondsToHuman( int(i['media$group']['yt$duration']['seconds']))), 'http://www.youtube.com/watch?v=%s' % i['media$group']['yt$videoid']['$t'], '', '', '%s%s.jpg' % (OmniUtil.SUBSCRIPTIONS, i['author'][0]['yt$userId']['$t'])) else: feed.add_item('No Results', 'No videos in your feed could be found', '', '', '', '%sX.png' % OmniUtil.ICONS) return feed
def getChannelFeed(query): OmniUtil.validStart() feed = OmniUtil.Feedback() gdataResults = OmniUtil.gdataLoad( OmniUtil.BASE_USER_UPLOADS % OmniUtil.__urlParse__(query).path.split('/')[-1], param1={'orderby': 'published'}) if gdataResults: for i in gdataResults: feed.add_item( i['title']['$t'], '%s - %s' % (i['media$group']['media$credit'][0]['yt$display'], OmniUtil.secondsToHuman( int(i['media$group']['yt$duration']['seconds']))), 'http://www.youtube.com/watch?v=%s' % i['media$group']['yt$videoid']['$t'], '', '', '%sListBlock.png' % OmniUtil.ICONS) else: feed.add_item('No Results', 'No feed results for "%s" could be found' % query, '', '', '', '%sX.png' % OmniUtil.ICONS) return feed
def queryChannel(query): OmniUtil.validStart() feed = OmniUtil.Feedback() gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_CHANNEL, param1={ 'max-results': '9', 'q': query }) if gdataResults: for i in gdataResults: channelSummary = i['summary']['$t'] channelLink = 'http://www.youtube.com/channel/%s' % i[ 'yt$channelId']['$t'] if len(channelSummary) <= 0: channelSummary = channelLink feed.add_item(i['author'][0]['name']['$t'], channelSummary, channelLink, '', '', '%sListBlock.png' % OmniUtil.ICONS) else: feed.add_item('No Results', 'No results for "%s" could be found' % query, '', '', '', '%sX.png' % OmniUtil.ICONS) return feed
def queryVideo(query): OmniUtil.validStart() feed = OmniUtil.Feedback() gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_VIDEO, param1={ 'orderby': 'relevance', 'q': query }) if gdataResults: for i in gdataResults: feed.add_item( i['title']['$t'], '%s - %s' % (i['author'][0]['name']['$t'], OmniUtil.secondsToHuman( int(i['media$group']['yt$duration']['seconds']))), 'http://www.youtube.com/watch?v=%s' % i['media$group']['yt$videoid']['$t'], '', '', '%sListBlock.png' % OmniUtil.ICONS) else: feed.add_item('No Results', 'No results for "%s" could be found' % query, '', '', '', '%sX.png' % OmniUtil.ICONS) return feed
def getProfile(): OmniUtil.validStart() def filterFeeds(gdataResults, rel): count = 0 for i in gdataResults['gd$feedLink']: if i['rel'] == rel: return count else: count += 1 feed = OmniUtil.Feedback() i = OmniUtil.jsonLoad(OmniUtil.BASE_PROFILE)['entry'] if not os.path.exists( '%s%s.jpg' % (OmniUtil.SUBSCRIPTIONS, i['link'][0]['href'].split('/')[-1])): OmniUtil.retrieveThumb(i['link'][0]['href'].split('/')[-1]) feed.add_item( i['author'][0]['name']['$t'], '%s years old [%s]' % (i['yt$age']['$t'], i['yt$username']['$t']), i['link'][0]['href'], '', '', '%s%s.jpg' % (OmniUtil.SUBSCRIPTIONS, i['link'][0]['href'].split('/')[-1])) feed.add_item( 'Subscriptions %s' % i['gd$feedLink'][filterFeeds( i, 'http://gdata.youtube.com/schemas/2007#user.subscriptions')] ['countHint'], '', '{\'key\':\'subscriptions\'}', '', '', '%sGroup.png' % OmniUtil.ICONS) feed.add_item('Subscribers %s' % i['yt$statistics']['subscriberCount'], '', '{\'key\':\'subscribers\'}', '', '', '%sGroupG.png' % OmniUtil.ICONS) feed.add_item( 'Uploads %s' % i['gd$feedLink'][filterFeeds( i, 'http://gdata.youtube.com/schemas/2007#user.uploads')] ['countHint'], '', '{\'key\':\'uploads\'}', '', '', '%sMulti.png' % OmniUtil.ICONS) try: feed.add_item( 'Playlists %s' % OmniUtil.jsonLoad(OmniUtil.BASE_USER_PLAYLIST) ['feed']['openSearch$totalResults']['$t'], '', '{\'key\':\'playlists\'}', '', '', '%sList.png' % OmniUtil.ICONS) except ValueError: feed.add_item( u'\uFFFD Playlists \uFFFD', 'Sorry, for some reason your playlists could not be found', '', '', '', '%sList.png' % OmniUtil.ICONS) try: feed.add_item( 'Favorites %s' % OmniUtil.jsonLoad(OmniUtil.BASE_FAVORITES)['feed'] ['openSearch$totalResults']['$t'], '', '{\'key\':\'favorites\'}', '', '', '%sHeart.png' % OmniUtil.ICONS) except ValueError: feed.add_item( u'\uFFFD Favorites \uFFFD', 'Sorry, for some reason your Favorites could not be found', '', '', '', '%sHeart.png' % OmniUtil.ICONS) try: feed.add_item( 'Watch Later %s' % OmniUtil.jsonLoad(OmniUtil.BASE_WATCHLATER) ['feed']['openSearch$totalResults']['$t'], '', '{\'key\':\'watchlater\'}', '', '', '%sClock.png' % OmniUtil.ICONS) except ValueError: feed.add_item( u'\uFFFD Watch Later \uFFFD' 'Sorry, for some reason your Watch Later could not be found', '', '', '', '%sClock.png' % OmniUtil.ICONS) return feed