def update_playlist(type=''): id = vars.args['id'][0] xbmcgui.Dialog().notification(vars.__addonname__, 'Updating '+dev.typeName(type)+' Playlist '+id, vars.__icon__, 3000) service.update_playlist(id, type=type) xbmcgui.Dialog().notification(vars.__addonname__, 'Done updating '+dev.typeName(type)+' Playlist '+id, vars.__icon__, 3000) #Should we also update the video library? if vars.update_videolibrary == "true": update_dir = vars.tv_folder_path if type == 'musicvideo': update_dir = vars.musicvideo_folder_path dev.log('Updating video library is enabled. Updating librarys directory %s' % update_dir, True) xbmc.executebuiltin('xbmc.updatelibrary(Video,'+update_dir+')')
def update_playlist(id, type=''): xbmcgui.Dialog().notification(vars.__addonname__, 'Updating '+dev.typeName(type)+' Playlist '+id, vars.__icon__, 3000) service.update_playlist(id, type=type) xbmcgui.Dialog().notification(vars.__addonname__, 'Done updating '+dev.typeName(type)+' Playlist '+id, vars.__icon__, 3000) #Should we also update the video library? if vars.update_videolibrary == "true": update_dir = vars.tv_folder_path if type == 'musicvideo': update_dir = vars.musicvideo_folder_path elif type == 'movies': update_dir = vars.movies_folder_path dev.log('Updating video library is enabled. Updating librarys directory %s' % update_dir, True) xbmc.executebuiltin('xbmc.updatelibrary(Video,'+update_dir+')')
def update_playlists(type=''): xbmcgui.Dialog().notification(vars.__addonname__, 'Updating Youtube '+dev.typeName(type)+' Playlists...', vars.__icon__, 3000) dev.log('Updating All '+type+' Youtube Playlists') scan_interval = 'service_interval' if type == 'musicvideo': scan_interval = 'service_interval_musicvideo' m_xml.xml_get(type=type) pl = m_xml.document.findall('playlists/playlist') if pl is not None: for child in pl: #Loop through each playlist if child.attrib['enabled'] == 'yes': #Playlist has to be enabled #Check when this playlist was last updated, and if it is time for this playlist to be updated again import datetime try: s = child.attrib['scansince'] scansince = datetime.datetime.strptime(s,"%d/%m/%Y %H:%M:%S") except: scansince = datetime.datetime.now() - datetime.timedelta(days=3*365) timenow = datetime.datetime.now() dev.log('Playlist last scanned on: '+str(scansince)+', now: '+str(timenow), 1) #diff = (timenow-scansince).total_seconds() diff = dev.timedelta_total_seconds(timenow-scansince) dev.log('Difference is '+str(diff)) if diff < (int(vars.__settings__.getSetting(scan_interval)) * 60 * 60): dev.log('Difference '+str(diff)+' was not enough, '+str(int(vars.__settings__.getSetting("service_interval")) * 60 * 60)+' seconds needed. This Playlist will not be updated now.') continue update_playlist(child.attrib['id'], type=type) #Update the nfo & strm files for this playlist xbmcgui.Dialog().notification(vars.__addonname__, 'Done Updating Youtube '+dev.typeName(type)+' Playlists', vars.__icon__, 3000) #Should we also update the video library? if vars.update_videolibrary == "true" and type=='': update_dir = vars.tv_folder_path if type == 'musicvideo': update_dir = vars.musicvideo_folder_path dev.log('Updating video library is enabled. Updating librarys directory %s' % update_dir, True) xbmc.executebuiltin('xbmc.updatelibrary(Video,'+update_dir+')')
def searched_playlist(result, type='', pagetoken=''): response = ytube.search_playlist(result, type, pagetoken) if isinstance(response['items'], list): # Go through each playlist and display the playlist for playlist in response['items']: #videos.append(search_result) title = playlist['snippet']['title'] url = dev.build_url({ 'mode': 'addPlaylist', 'id': playlist['id']['playlistId'], 'type': type }) dev.adddir(title, url, dev.playlist_highest_thumbnail(playlist), fanart=dev.playlist_highest_thumbnail(playlist), description=dev.lang(31010) + ' ' + dev.typeName(type) + ' \n--------\nPlaylist Description:\n' + playlist['snippet']['description']) if 'prevPageToken' in response: if response['prevPageToken'] is not None: url = dev.build_url({ 'mode': 'searchedplaylist', 'search': result, 'type': type, 'pagetoken': response['prevPageToken'] }) dev.adddir( '<< Prev Page', url, description='Go to the previous page of available playlists') if 'nextPageToken' in response: if response['nextPageToken'] is not None: url = dev.build_url({ 'mode': 'searchedplaylist', 'search': result, 'type': type, 'pagetoken': response['nextPageToken'] }) dev.adddir( 'Next Page >>', url, description='Go to the next page of available playlists') xbmcplugin.endOfDirectory( vars.addon_handle) #Adds a playlist & loads the view to edit it
def show_playlists_by_channel(Channelid, type=''): search_response = ytube.yt_get_channel_info(Channelid) #Grab the playlists from the response playlists = search_response['items'][0]['contentDetails']['relatedPlaylists'] # Go through each playlist and display the playlist for key, value in playlists.iteritems(): #Grab the number of videos to pl = ytube.yt_get_playlist_info(value) number_vids = str(pl['items'][0]['contentDetails']['itemCount']) #videos.append(search_result) url = dev.build_url({'mode': 'addPlaylist', 'id': value, 'type': type}) dev.adddir(key.capitalize()+' ('+number_vids+')', url, search_response['items'][0]['snippet']['thumbnails']['high']['url'], fanart=search_response['items'][0]['snippet']['thumbnails']['high']['url'], description=dev.lang(31010)+' '+dev.typeName(type)+' \n--------\nPlaylist Description:\n'+search_response['items'][0]['snippet']['description']) # Grab other playlists this user has created to response = ytube.yt_get_playlists_by_channel(Channelid) if isinstance(response, list): # Go through each playlist and display the playlist for playlist in response: #videos.append(search_result) title = playlist['snippet']['title']+' ('+str(playlist['contentDetails']['itemCount'])+')' url = dev.build_url({'mode': 'addPlaylist', 'id': playlist['id'], 'type': type}) dev.adddir(title, url, playlist['snippet']['thumbnails']['high']['url'], fanart=playlist['snippet']['thumbnails']['high']['url'], description=dev.lang(31010)+' '+dev.typeName(type)+' \n--------\nPlaylist Description:\n'+playlist['snippet']['description']) xbmcplugin.endOfDirectory(vars.addon_handle)#Adds a playlist & loads the view to edit it
def search_channel(type=''): result = dev.user_input('', 'Search for '+dev.typeName(type)+' Channel') if len(result) > 0: ytube.search_channel(result, type) xbmcplugin.endOfDirectory(vars.addon_handle)
def show_playlists_by_channel(Channelid, type='', pagetoken='default'): if pagetoken == 'default' or pagetoken == '': search_response = ytube.yt_get_channel_info(Channelid) #Grab the playlists from the response playlists = search_response['items'][0]['contentDetails'][ 'relatedPlaylists'] # Go through each playlist and display the playlist for key, value in playlists.iteritems(): if value == 'WL' or value == 'HL': continue #The watch later and watch history playlists are not giving their normal id's, so skip them #Grab the number of videos to pl = ytube.yt_get_playlist_info(value) number_vids = str(pl['items'][0]['contentDetails']['itemCount']) #videos.append(search_result) url = dev.build_url({ 'mode': 'addPlaylist', 'id': value, 'type': type }) dev.adddir(key.capitalize() + ' (' + number_vids + ')', url, dev.playlist_highest_thumbnail( search_response['items'][0]), fanart=dev.playlist_highest_thumbnail( search_response['items'][0]), description=dev.lang(31010) + ' ' + dev.typeName(type) + ' \n--------\nPlaylist Description:\n' + search_response['items'][0]['snippet']['description']) # Grab other playlists this user has created to response = ytube.yt_get_playlists_by_channel(Channelid, pagetoken) if isinstance(response['items'], list): # Go through each playlist and display the playlist for playlist in response['items']: #videos.append(search_result) title = playlist['snippet']['title'] + ' (' + str( playlist['contentDetails']['itemCount']) + ')' url = dev.build_url({ 'mode': 'addPlaylist', 'id': playlist['id'], 'type': type }) dev.adddir(title, url, dev.playlist_highest_thumbnail(playlist), fanart=dev.playlist_highest_thumbnail(playlist), description=dev.lang(31010) + ' ' + dev.typeName(type) + ' \n--------\nPlaylist Description:\n' + playlist['snippet']['description']) if 'prevPageToken' in response: if response['prevPageToken'] is not None: url = dev.build_url({ 'mode': 'pickedChannel', 'id': Channelid, 'type': type, 'pagetoken': response['prevPageToken'] }) dev.adddir( '<< Prev Page', url, description='Go to the previous page of available playlists') if 'nextPageToken' in response: if response['nextPageToken'] is not None: url = dev.build_url({ 'mode': 'pickedChannel', 'id': Channelid, 'type': type, 'pagetoken': response['nextPageToken'] }) dev.adddir( 'Next Page >>', url, description='Go to the next page of available playlists') xbmcplugin.endOfDirectory( vars.addon_handle) #Adds a playlist & loads the view to edit it
def search_playlist(type=''): result = dev.user_input('', 'Search for ' + dev.typeName(type) + ' Playlist') if len(result) > 0: searched_playlist(result, type)
def search_channel(type=''): result = dev.user_input('', 'Search for ' + dev.typeName(type) + ' Channel') if len(result) > 0: ytube.search_channel(result, type) xbmcplugin.endOfDirectory(vars.addon_handle)
def show_playlists_by_channel(Channelid, type='', pagetoken='default'): if pagetoken == 'default' or pagetoken == '': search_response = ytube.yt_get_channel_info(Channelid) #Grab the playlists from the response playlists = search_response['items'][0]['contentDetails']['relatedPlaylists'] # Go through each playlist and display the playlist for key, value in playlists.iteritems(): if value == 'WL' or value == 'HL': continue #The watch later and watch history playlists are not giving their normal id's, so skip them #Grab the number of videos to pl = ytube.yt_get_playlist_info(value) number_vids = str(pl['items'][0]['contentDetails']['itemCount']) #videos.append(search_result) url = dev.build_url({'mode': 'addPlaylist', 'id': value, 'type': type}) dev.adddir(key.capitalize()+' ('+number_vids+')', url, dev.playlist_highest_thumbnail(search_response['items'][0]), fanart=dev.playlist_highest_thumbnail(search_response['items'][0]), description=dev.lang(31010)+' '+dev.typeName(type)+' \n--------\nPlaylist Description:\n'+search_response['items'][0]['snippet']['description']) # Grab other playlists this user has created to response = ytube.yt_get_playlists_by_channel(Channelid, pagetoken) if isinstance(response['items'], list): # Go through each playlist and display the playlist for playlist in response['items']: #videos.append(search_result) title = playlist['snippet']['title']+' ('+str(playlist['contentDetails']['itemCount'])+')' url = dev.build_url({'mode': 'addPlaylist', 'id': playlist['id'], 'type': type}) dev.adddir(title, url, dev.playlist_highest_thumbnail(playlist), fanart= dev.playlist_highest_thumbnail(playlist), description=dev.lang(31010)+' '+dev.typeName(type)+' \n--------\nPlaylist Description:\n'+playlist['snippet']['description']) if 'prevPageToken' in response: if response['prevPageToken'] is not None: url = dev.build_url({'mode': 'pickedChannel', 'id': Channelid, 'type': type, 'pagetoken': response['prevPageToken']}) dev.adddir('<< Prev Page', url, description='Go to the previous page of available playlists') if 'nextPageToken' in response: if response['nextPageToken'] is not None: url = dev.build_url({'mode': 'pickedChannel', 'id': Channelid, 'type': type, 'pagetoken': response['nextPageToken']}) dev.adddir('Next Page >>', url, description='Go to the next page of available playlists') xbmcplugin.endOfDirectory(vars.addon_handle)#Adds a playlist & loads the view to edit it
def searched_playlist(result, type='', pagetoken=''): response = ytube.search_playlist(result, type, pagetoken) if isinstance(response['items'], list): # Go through each playlist and display the playlist for playlist in response['items']: #videos.append(search_result) title = playlist['snippet']['title'] url = dev.build_url({'mode': 'addPlaylist', 'id': playlist['id']['playlistId'], 'type': type}) dev.adddir(title, url, dev.playlist_highest_thumbnail(playlist), fanart=dev.playlist_highest_thumbnail(playlist), description=dev.lang(31010)+' '+dev.typeName(type)+' \n--------\nPlaylist Description:\n'+playlist['snippet']['description']) if 'prevPageToken' in response: if response['prevPageToken'] is not None: url = dev.build_url({'mode': 'searchedplaylist', 'search': result, 'type': type, 'pagetoken': response['prevPageToken']}) dev.adddir('<< Prev Page', url, description='Go to the previous page of available playlists') if 'nextPageToken' in response: if response['nextPageToken'] is not None: url = dev.build_url({'mode': 'searchedplaylist', 'search': result, 'type': type, 'pagetoken': response['nextPageToken']}) dev.adddir('Next Page >>', url, description='Go to the next page of available playlists') xbmcplugin.endOfDirectory(vars.addon_handle)#Adds a playlist & loads the view to edit it
def search_playlist(type=''): result = dev.user_input('', 'Search for '+dev.typeName(type)+' Playlist') if len(result) > 0: searched_playlist(result, type)