def showSearchResults(results): matches = 0 for i in results: provider = i.get('provider') resultList = core.sortDictList(i.get('searchResults'), 'title') if not resultList: logger.warn('Empty search results for: {0}'.format(provider)) break matches = len(resultList) item = core.listItem( label='[B][COLOR springgreen] --- {0}: Found {1} matches[/B][/COLOR]' .format(provider.capitalize(), matches)) core.addDirectoryItem(core.handle, None, item, False) for m in resultList: params = { 'mediaId': m.get('mediaId'), 'provider': provider, 'media': m.get('media') } m.update({'mediatype': 'video'}) url = core.getURL(params) listItem = core.listItem(label=m.get('title').encode('utf8')) m.pop('aired') if not m.get('year'): m.pop('year') listItem.setInfo('video', m) listItem.setArt(m) core.addDirectoryItem(core.handle, url, listItem, True)
def episodeMenu(params): mediaId = params.get('mediaId') episodeId = params.get('episodeId') localParams = dict(params) # Just to setup images, plot and such on the links as well.. mediaDict = getAnimeData(mediaId) episodeDict = getEpisodeData(mediaId, episodeId) if not episodeDict.get('plot'): # If we have a plot for the episode page => update the DB. Note: It doesn't seem that episodes have different plots, so this is just duplicating the anime one.. episodeDict.update({'plot': mediaDict.get('plot')}) mediaDict.pop('year') mediaDict.pop('aired') mediaDict.update(episodeDict) # setArt fails with the servers object... dumb stuff mediaDict.pop('servers') for server in episodeDict.get('servers'): ### List servers localParams.update({'streamId': server, 'action': 'play'}) url = core.getURL(localParams) listItem = core.listItem(server.upper()) listItem.setInfo('video', mediaDict) listItem.setArt(mediaDict) #listItem.setProperty( 'IsPlayable', 'true' ) ### NEED CONFIRMATION core.addDirectoryItem(core.handle, url, listItem, False)
def mainMenu(params): localParams = dict(params) for provider in providers.providersControllers.keys(): listItem = core.listItem(label=provider.capitalize()) localParams.update({'provider': provider}) url = core.getURL(localParams) core.addDirectoryItem(core.handle, url, listItem, True)
def genresMenu(params): localParams = dict(params) localParams.update({'action': 'list'}) # cosmetic... genre = localParams.get('genre') if genre: genreMenu(params) else: for genre in settings._genreList: localParams.update({'genre': genre}) url = core.getURL(localParams) listItem = core.listItem(label=genre.capitalize()) core.addDirectoryItem(core.handle, url, listItem, True) core.endOfDirectory(core.handle, cacheToDisc=True)
def mainMenu(): for mediaType, mediaId in controllers.mediaTypes.items(): params = {'media': mediaId} url = core.getURL(params) listItem = core.listItem(label=mediaType) listItem.setArt(core.defaultArt) isFolder = True core.addDirectoryItem(core.handle, url, listItem, isFolder) core.addSeparator() addTools() url = core.getURL({'action': 'test'}) listItem = core.listItem('Play from Temp') core.addDirectoryItem(core.handle, url, listItem, False)
def addAnimeItem(animeId, params): localParams = dict(params) localParams.update({'mediaId': animeId}) animeData = getAnimeData(animeId) if animeData: url = core.getURL(localParams) animeData.update({'mediatype': 'video'}) listItem = core.listItem(label=animeData.get('title')) animeData.pop('aired') if not animeData.get('year'): animeData.pop('year') listItem.setInfo('video', animeData) listItem.setArt(animeData) core.addDirectoryItem(core.handle, url, listItem, True) else: msg = 'Error loading anime data: {0}. Check logs'.format(animeId) logger.error(msg) core.popupError('Error loading anime data', msg)
def mediaMenu(params): localParams = dict(params) # Pre-populate a dict with info about the Anime for the header and plot animeId = params.get('mediaId') listItemDict = { 'mediatype': 'video', 'mediaId': animeId, 'title': '', 'plot': '', 'thumb': '', 'icon': '', 'fanart': '', 'year': '', 'genre': '', 'aired': '' } db.updateDict(settings.mediaTable, listItemDict) mediaAired = listItemDict.pop('aired') mediaPlot = listItemDict.get('plot') + '\n{0}'.format(mediaAired) if not listItemDict.get('year'): listItemDict.pop('year') header = core.listItem( label='--- [B][COLOR springgreen]{0}[/B][/COLOR]:'.format( listItemDict.get('title'))) core.addDirectoryItem(core.handle, None, header, False) ret = list() episodeList = getEpisodeList(animeId) for ep in episodeList: # Update the anime (with images, plot, etc) with data for the episode listItemDict.update(ep) # Setup and add item to the directory/menu listItem = core.listItem(label=listItemDict.get('title')) localParams.update({ 'mediaId': animeId, 'episodeId': listItemDict.get('episodeId'), 'action': 'list' }) url = core.getURL(localParams) listItem.setInfo('video', listItemDict) listItem.setArt(listItemDict) core.addDirectoryItem(core.handle, url, listItem, True)
def mainMenu(params): localParams = dict(params) # Add a search core.addSearch(localParams) core.addSeparator() # Genres option localParams.update({'action': 'list', 'path': 'genres'}) url = core.getURL(localParams) listItem = core.listItem(label='Genres') core.addDirectoryItem(core.handle, url, listItem, True) # Trending option localParams.update({'action': 'list', 'path': 'trending'}) url = core.getURL(localParams) listItem = core.listItem(label='Trending') core.addDirectoryItem(core.handle, url, listItem, True) # Releases option localParams.update({'action': 'list', 'path': 'releases'}) url = core.getURL(localParams) listItem = core.listItem(label='Releases') core.addDirectoryItem(core.handle, url, listItem, True)
def toolsMenu(params): action = params.get('action') localParams = dict(params) if action == 'list': # View Logfile localParams = { 'media': 'tools', 'action': 'read', 'file': core.logPath } url = core.getURL(localParams) listItem = core.listItem(label='View Log - {0}'.format(core.logFile)) core.addDirectoryItem(core.handle, url, listItem, False) # Clear log localParams = { 'media': 'tools', 'action': 'clear-log', 'file': core.logPath } url = core.getURL(localParams) listItem = core.listItem(label='Clear Log - {0}'.format(core.logFile)) core.addDirectoryItem(core.handle, url, listItem, False) # Clear temp dir localParams = { 'media': 'tools', 'action': 'clear-temp', 'tempdir': core.tmpDataPath } url = core.getURL(localParams) fileNum = len(os.listdir(core.tmpDataPath)) listItem = core.listItem( label='Clear Temp Dir - {0} files'.format(fileNum)) core.addDirectoryItem(core.handle, url, listItem, False) # Clear search history for media in controllers.mediaControllers.keys(): localParams = { 'media': 'tools', 'action': 'clear-search', 'histfile': media } url = core.getURL(localParams) listItem = core.listItem(label='Clear search history for: {0}'. format(media.capitalize())) core.addDirectoryItem(core.handle, url, listItem, False) elif action == 'clear-search': histfile = core.getSearchFile(params.get('histfile')) if os.path.exists(histfile): os.unlink(histfile) core.execbuiltin( 'Notification("Search cleared", "{0} cleared")'.format( params.get('histfile'))) elif action == 'read': filePath = params.get('file') core.displayTextFile(core.logFile, filePath) elif action == 'clear-temp': tmpDir = localParams.get('tempdir') count = 0 for f in os.listdir(tmpDir): count += 1 fullPath = os.path.join(tmpDir, f) if os.path.isdir(fullPath): shutil.rmtree(fullPath) else: os.unlink(fullPath) core.execbuiltin( 'Notification("TempDir cleared", "{0} files removed")'.format( count)) elif action == 'clear-log': filePath = params.get('file') with open(filePath, 'w') as f: f.write('') core.execbuiltin( 'Notification("Log cleared", "The logfile has been truncated")') return
def addTools(): localParams = {'action': 'list', 'media': 'tools'} url = core.getURL(localParams) listItem = core.listItem(label='Quantum Tools') listItem.setArt(core.defaultArt) core.addDirectoryItem(core.handle, url, listItem, True)