Пример #1
0
def removeFromPlaylist(video):
	OmniUtil.validStart()
	gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_PLAYLIST_FEED % OmniUtil.__urlParse__(selectPlaylist('Remove <%s> from which playlist?' % video)).query.split('=')[1])
	if gdataResults:
		for i in gdataResults:
			if i['media$group']['yt$videoid']['$t'] == OmniUtil.__urlParse__(video).query.split('=')[1].split('&')[0]:
				for j in i['link']:
					if j['rel'] == 'self':
						requests.delete(j['href'], data = '', headers = OmniUtil.postLoad())
						OmniUtil.displayNotification(OmniUtil.TITLE, 'Removed video from playlist', '', '')
	else:
		OmniUtil.cocoaMsgBox('Could not delete video from playlist', 'Sorry, but an error occured during the deletion process.', '%sWarning.png' % OmniUtil.ICONS)
Пример #2
0
def addToPlaylist(video):
    OmniUtil.validStart()
    if video[0] == "'":
        video = video[1:-1]
    postLoad = OmniUtil.postLoad()
    postLoad['Content-Length'] = '1'
    requests.post(
        OmniUtil.BASE_PLAYLIST_FEED % OmniUtil.__urlParse__(
            selectPlaylist(
                'Add <%s> to which playlist?' % video)).query.split('=')[1],
        data=
        '<?xml version="1.0" encoding="UTF-8"?>\n<entry xmlns="http://www.w3.org/2005/Atom"\n\txmlns:yt="http://gdata.youtube.com/schemas/2007">\n<id>%s</id>\n<yt:position>1</yt:position>\n</entry>'
        % OmniUtil.__urlParse__(video).query.split('=')[1].split('&')[0],
        headers=postLoad)
    OmniUtil.displayNotification(OmniUtil.TITLE, 'Added video to playlist', '',
                                 '')
Пример #3
0
def removePlaylist(query):
	OmniUtil.validStart()
	playlistId = OmniUtil.__urlParse__(query).query.split('=')[1]
	query = '%s/%s' % (OmniUtil.BASE_USER_PLAYLIST, playlistId)
	if OmniUtil.cocoaYesNoBox('Deleting Playlist!', 'Are you sure you want to delete this playlist?', '%sWarning.png' % OmniUtil.ICONS):
		requests.delete(query, data = '', headers = OmniUtil.postLoad())
		OmniUtil.displayNotification(OmniUtil.TITLE, 'Deleted Playlist', playlistId, '')
Пример #4
0
def addWatchLater(query):
	OmniUtil.validStart()
	query = OmniUtil.__urlParse__(query).query.split('v=')[-1].split('&')[0]
	OmniUtil.postLoad()['Content-Length'] = '1'
	requests.post(OmniUtil.BASE_WATCHLATER,
		data = '<?xml version="1.0" encoding="UTF-8"?>\n<entry xmlns="http://www.w3.org/2005/Atom"\nxmlns:yt="http://gdata.youtube.com/schemas/2007">\n<id>%s</id>\n<yt:position>1</yt:position>\n</entry>' % query,
		headers = OmniUtil.postLoad())
	OmniUtil.displayNotification(OmniUtil.TITLE, 'Added to Watch Later', '', '')
Пример #5
0
def addFavorite(query):
	OmniUtil.validStart()
	query = OmniUtil.__urlParse__(query).query.split('v=')[-1].split('&')[0]
	OmniUtil.postLoad()['Content-Length'] = '1'
	requests.post(OmniUtil.BASE_FAVORITES, 
		data = '<?xml version="1.0" encoding="UTF-8"?>\n<entry xmlns="http://www.w3.org/2005/Atom">\n<id>%s</id>\n</entry>' % query,
		headers = OmniUtil.postLoad())
	OmniUtil.displayNotification(OmniUtil.TITLE, 'Added to Favorites', '', '')	
Пример #6
0
def addToPlaylist(video):
	OmniUtil.validStart()
	if video[0] == "'":
		video = video[1:-1]
	postLoad = OmniUtil.postLoad()
	postLoad['Content-Length'] = '1'
	requests.post(OmniUtil.BASE_PLAYLIST_FEED % OmniUtil.__urlParse__(selectPlaylist('Add <%s> to which playlist?' % video)).query.split('=')[1],
		data = '<?xml version="1.0" encoding="UTF-8"?>\n<entry xmlns="http://www.w3.org/2005/Atom"\n\txmlns:yt="http://gdata.youtube.com/schemas/2007">\n<id>%s</id>\n<yt:position>1</yt:position>\n</entry>' % OmniUtil.__urlParse__(video).query.split('=')[1].split('&')[0],
		headers = postLoad)
	OmniUtil.displayNotification(OmniUtil.TITLE, 'Added video to playlist', '', '')
Пример #7
0
def removeWatchLater(query):
	OmniUtil.validStart()
	gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_WATCHLATER)
	if gdataResults:
		for i in gdataResults:
			if i['media$group']['yt$videoid']['$t'] == OmniUtil.__urlParse__(query).query.split('v=')[-1].split('&')[0]:
				query = i['id']['$t'].split(':')[-1]
		requests.delete('%s/%s' % (OmniUtil.BASE_FAVORITES, query), data = '', headers = OmniUtil.postLoad())
		OmniUtil.displayNotification(OmniUtil.TITLE, 'Removed from Watch Later', '', '')
	else:
		OmniUtil.displayNotification(OmniUtil.TITLE, 'Could not remove from "Watch Later"', '<unkown error occured>', '')
Пример #8
0
def addFavorite(query):
    OmniUtil.validStart()
    query = OmniUtil.__urlParse__(query).query.split('v=')[-1].split('&')[0]
    OmniUtil.postLoad()['Content-Length'] = '1'
    requests.post(
        OmniUtil.BASE_FAVORITES,
        data=
        '<?xml version="1.0" encoding="UTF-8"?>\n<entry xmlns="http://www.w3.org/2005/Atom">\n<id>%s</id>\n</entry>'
        % query,
        headers=OmniUtil.postLoad())
    OmniUtil.displayNotification(OmniUtil.TITLE, 'Added to Favorites', '', '')
Пример #9
0
def removePlaylist(query):
    OmniUtil.validStart()
    playlistId = OmniUtil.__urlParse__(query).query.split('=')[1]
    query = '%s/%s' % (OmniUtil.BASE_USER_PLAYLIST, playlistId)
    if OmniUtil.cocoaYesNoBox(
            'Deleting Playlist!',
            'Are you sure you want to delete this playlist?',
            '%sWarning.png' % OmniUtil.ICONS):
        requests.delete(query, data='', headers=OmniUtil.postLoad())
        OmniUtil.displayNotification(OmniUtil.TITLE, 'Deleted Playlist',
                                     playlistId, '')
Пример #10
0
def addWatchLater(query):
    OmniUtil.validStart()
    query = OmniUtil.__urlParse__(query).query.split('v=')[-1].split('&')[0]
    OmniUtil.postLoad()['Content-Length'] = '1'
    requests.post(
        OmniUtil.BASE_WATCHLATER,
        data=
        '<?xml version="1.0" encoding="UTF-8"?>\n<entry xmlns="http://www.w3.org/2005/Atom"\nxmlns:yt="http://gdata.youtube.com/schemas/2007">\n<id>%s</id>\n<yt:position>1</yt:position>\n</entry>'
        % query,
        headers=OmniUtil.postLoad())
    OmniUtil.displayNotification(OmniUtil.TITLE, 'Added to Watch Later', '',
                                 '')
Пример #11
0
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
Пример #12
0
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
Пример #13
0
def removeFromPlaylist(video):
    OmniUtil.validStart()
    gdataResults = OmniUtil.gdataLoad(
        OmniUtil.BASE_PLAYLIST_FEED % OmniUtil.__urlParse__(
            selectPlaylist('Remove <%s> from which playlist?' %
                           video)).query.split('=')[1])
    if gdataResults:
        for i in gdataResults:
            if i['media$group']['yt$videoid']['$t'] == OmniUtil.__urlParse__(
                    video).query.split('=')[1].split('&')[0]:
                for j in i['link']:
                    if j['rel'] == 'self':
                        requests.delete(j['href'],
                                        data='',
                                        headers=OmniUtil.postLoad())
                        OmniUtil.displayNotification(
                            OmniUtil.TITLE, 'Removed video from playlist', '',
                            '')
    else:
        OmniUtil.cocoaMsgBox(
            'Could not delete video from playlist',
            'Sorry, but an error occured during the deletion process.',
            '%sWarning.png' % OmniUtil.ICONS)
Пример #14
0
def removeWatchLater(query):
    OmniUtil.validStart()
    gdataResults = OmniUtil.gdataLoad(OmniUtil.BASE_WATCHLATER)
    if gdataResults:
        for i in gdataResults:
            if i['media$group']['yt$videoid']['$t'] == OmniUtil.__urlParse__(
                    query).query.split('v=')[-1].split('&')[0]:
                query = i['id']['$t'].split(':')[-1]
        requests.delete('%s/%s' % (OmniUtil.BASE_FAVORITES, query),
                        data='',
                        headers=OmniUtil.postLoad())
        OmniUtil.displayNotification(OmniUtil.TITLE,
                                     'Removed from Watch Later', '', '')
    else:
        OmniUtil.displayNotification(OmniUtil.TITLE,
                                     'Could not remove from "Watch Later"',
                                     '<unkown error occured>', '')
Пример #15
0
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
Пример #16
0
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