def addFavourite(meta, content, query): try: item = dict() meta = json.loads(meta) imdb = item['imdb'] = meta['imdb'] if 'title' in meta: title = item['title'] = meta['title'] if 'tvshowtitle' in meta: title = item['title'] = meta['tvshowtitle'] if 'year' in meta: item['year'] = meta['year'] if 'poster' in meta: item['poster'] = meta['poster'] if 'fanart' in meta: item['fanart'] = meta['fanart'] if 'tmdb' in meta: item['tmdb'] = meta['tmdb'] if 'tvdb' in meta: item['tvdb'] = meta['tvdb'] if 'tvrage' in meta: item['tvrage'] = meta['tvrage'] control.makeFile(control.dataPath) dbcon = database.connect(control.favouritesFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS %s (""id TEXT, ""items TEXT, ""UNIQUE(id)"");" % content) dbcur.execute("DELETE FROM %s WHERE id = '%s'" % (content, imdb)) dbcur.execute("INSERT INTO %s Values (?, ?)" % content, (imdb, repr(item))) dbcon.commit() if query == None: control.refresh() control.infoDialog(control.lang(30411).encode('utf-8'), heading=title) except: return
def movies(title, year, imdb, watched): traktMode = False if trakt.getTraktCredentials() == False else True watched = int(watched) try: if traktMode == True: raise Exception() from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('movie', title, year=year) metaget.change_watched('movie', '', imdb, season='', episode='', year='', watched=watched) except: pass try: if traktMode == False: raise Exception() if watched == 7: trakt.markMovieAsWatched(imdb) else: trakt.markMovieAsNotWatched(imdb) trakt.syncMovies() except: pass control.refresh()
def movies(title, year, imdb, watched): traktMode = False if trakt.getTraktCredentials() == False else True watched = int(watched) try: if traktMode == True: raise Exception() from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta("movie", title, year=year) metaget.change_watched("movie", "", imdb, season="", episode="", year="", watched=watched) except: pass try: if traktMode == False: raise Exception() if watched == 7: trakt.markMovieAsWatched(imdb) else: trakt.markMovieAsNotWatched(imdb) trakt.syncMovies() except: pass control.refresh()
def deleteFavourite(meta, content): try: meta = json.loads(meta) imdb = meta['imdb'] if 'title' in meta: title = meta['title'] if 'tvshowtitle' in meta: title = meta['tvshowtitle'] try: dbcon = database.connect(control.favouritesFile) dbcur = dbcon.cursor() dbcur.execute("DELETE FROM %s WHERE id = '%s'" % (content, imdb)) dbcon.commit() except: pass try: dbcon = database.connect(control.databaseFile) dbcur = dbcon.cursor() dbcur.execute("DELETE FROM favourites WHERE imdb_id = '%s'" % imdb) dbcon.commit() except: pass control.refresh() control.infoDialog(control.lang(30412).encode('utf-8'), heading=title) except: return
def episodes(imdb, tvdb, season, episode, watched): traktMode = False if trakt.getTraktCredentials() == False else True watched = int(watched) try: if traktMode == True: raise Exception() from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta("tvshow", "", imdb_id=imdb) metaget.get_episode_meta("", imdb, season, episode) metaget.change_watched("episode", "", imdb, season=season, episode=episode, year="", watched=watched) except: pass try: if traktMode == False: raise Exception() if watched == 7: trakt.markEpisodeAsWatched(tvdb, season, episode) else: trakt.markEpisodeAsNotWatched(tvdb, season, episode) trakt.syncTVShows() except: pass control.refresh()
def episodes(imdb, tvdb, season, episode, watched): traktMode = False if trakt.getTraktCredentials() == False else True watched = int(watched) control.log('>>> Watched %s' % watched) try: if traktMode == True: raise Exception() from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('tvshow', '', imdb_id=imdb) metaget.get_episode_meta('', imdb, season, episode) metaget.change_watched('episode', '', imdb, season=season, episode=episode, year='', watched=watched) except: pass try: if traktMode == False: raise Exception() if watched == 7: trakt.markEpisodeAsWatched(tvdb, season, episode) else: trakt.markEpisodeAsNotWatched(tvdb, season, episode) trakt.syncTVShows() except: pass control.refresh()
def episodes(imdb, tvdb, season, episode, watched): try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, episode) else: trakt.markEpisodeAsNotWatched(tvdb, season, episode) trakt.cachesyncTVShows() control.refresh() except: pass try: from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('tvshow', name='', imdb_id=imdb) metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode) metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched)) if trakt.getTraktIndicatorsInfo() == False: control.refresh() except: pass
def tvshows(tvshowtitle, year, imdb, tvdb, season, watched): traktMode = False if trakt.getTraktCredentials() == False else True watched = int(watched) try: if traktMode == True: raise Exception() from metahandler import metahandlers from resources.lib.indexers import episodes metaget = metahandlers.MetaData(preparezip=False) dialog = control.progressDialog dialog.create(control.addonInfo('name'), str(tvshowtitle)) dialog.update(0, str(tvshowtitle), control.lang(30451).encode('utf-8') + '...') metaget.get_meta('tvshow', '', imdb_id=imdb) items = episodes.episodes().get(tvshowtitle, year, imdb, '0', tvdb, '0', idx=False) try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))] except: pass items = [ {'name': i['name'], 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items] for i in range(len(items)): if xbmc.abortRequested == True: return sys.exit() if dialog.iscanceled(): return dialog.close() dialog.update(int((100 / float(len(items))) * i), str(tvshowtitle), str(items[i]['name'])) season, episode = items[i]['season'], items[i]['episode'] metaget.get_episode_meta('', imdb, season, episode) metaget.change_watched('episode', '', imdb, season=season, episode=episode, year='', watched=watched) try: dialog.close() except: pass except: try: dialog.close() except: pass try: if traktMode == False: raise Exception() if watched == 7: trakt.markTVShowAsWatched(tvdb) else: trakt.markTVShowAsNotWatched(tvdb) trakt.syncTVShows() except: pass control.refresh()
def clear(self): control.window.clearProperty(property + '.status') control.window.clearProperty(property + '.name') control.window.clearProperty(property + '.image') control.window.clearProperty(property + '.percent') control.window.clearProperty(property + '.speed') control.window.clearProperty(property + '.size') control.refresh()
def movies(title, year, imdb, watched): watched = int(watched) try: from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('movie', title ,year=year) metaget.change_watched('movie', '', imdb, season='', episode='', year='', watched=watched) except: pass control.refresh()
def tvshows(tvshowtitle, imdb, tvdb, season, watched): try: import sys,xbmc if not trakt.getTraktIndicatorsInfo() == False: raise Exception() from metahandler import metahandlers from resources.lib.indexers import episodes metaget = metahandlers.MetaData(preparezip=False) name = control.addonInfo('name') dialog = control.progressDialogBG dialog.create(str(name), str(tvshowtitle)) dialog.update(0, str(name), str(tvshowtitle)) metaget.get_meta('tvshow', name='', imdb_id=imdb) items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0','0', idx=False) try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))] except: pass items = [{'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items] for i in range(len(items)): if xbmc.abortRequested == True: return sys.exit() dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label'])) season, episode = items[i]['season'], items[i]['episode'] metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode) metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched)) try: dialog.close() except: pass except Exception as e: control.log('playcount %s' % e) try: dialog.close() except: pass try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if int(watched) == 7: trakt.markTVShowAsWatched(tvdb) else: trakt.markTVShowAsNotWatched(tvdb) trakt.cachesyncTVShows() except: pass control.refresh()
def episodes(imdb, tvdb, season, episode, watched): watched = int(watched) try: from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('tvshow', '', imdb_id=imdb) metaget.get_episode_meta('', imdb, season, episode) metaget.change_watched('episode', '', imdb, season=season, episode=episode, year='', watched=watched) except: pass control.refresh()
def removeDownload(url): try: def download(): return [] result = cache.get(download, 600000000, table='rel_dl') if result == '': result = [] result = [i for i in result if not i['url'] == url] if result == []: result = '' def download(): return result result = cache.get(download, 0, table='rel_dl') control.refresh() except: control.infoDialog('You need to remove file manually', 'Can not remove from Queue')
def tvshows(tvshowtitle, year, imdb, tvdb, season, watched): traktMode = False if trakt.getTraktCredentials() == False else True watched = int(watched) try: if traktMode == True: raise Exception() from metahandler import metahandlers from resources.lib.indexers import episodes metaget = metahandlers.MetaData(preparezip=False) dialog = control.progressDialog dialog.create(control.addonInfo('name'), str(tvshowtitle)) dialog.update(0, str(tvshowtitle), control.lang(30451).encode('utf-8') + '...') metaget.get_meta('tvshow', '', imdb_id=imdb) items = episodes.episodes().get(tvshowtitle, year, imdb, '0', tvdb, '0', idx=False) try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))] except: pass items = [{'name': i['name'], 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items] for i in range(len(items)): if xbmc.abortRequested == True: return sys.exit() if dialog.iscanceled(): return dialog.close() dialog.update(int((100 / float(len(items))) * i), str(tvshowtitle), str(items[i]['name'])) season, episode = items[i]['season'], items[i]['episode'] metaget.get_episode_meta('', imdb, season, episode) metaget.change_watched('episode', '', imdb, season=season, episode=episode, year='', watched=watched) try: dialog.close() except: pass except: try: dialog.close() except: pass try: if traktMode == False: raise Exception() if watched == 7: trakt.markTVShowAsWatched(tvdb) else: trakt.markTVShowAsNotWatched(tvdb) trakt.syncTVShows() except: pass control.refresh()
def libForPlayback(self): try: if self.DBID == None: raise Exception() if self.content == 'movie': rpc = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid" : %s, "playcount" : 1 }, "id": 1 }' % str( self.DBID) elif self.content == 'episode': rpc = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetEpisodeDetails", "params": {"episodeid" : %s, "playcount" : 1 }, "id": 1 }' % str( self.DBID) control.jsonrpc(rpc) control.refresh() except: pass
def movies(title, year, imdb, watched): watched = int(watched) try: from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('movie', title, year=year) metaget.change_watched('movie', '', imdb, season='', episode='', year='', watched=watched) except: pass control.refresh()
def movies(imdb, watched): try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if int(watched) == 7: trakt.markMovieAsWatched(imdb) else: trakt.markMovieAsNotWatched(imdb) trakt.cachesyncMovies() control.refresh() except: pass try: from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('movie', name='', imdb_id=imdb) metaget.change_watched('movie', name='', imdb_id=imdb, watched=int(watched)) if trakt.getTraktIndicatorsInfo() == False: control.refresh() except: pass
def setWatchedStatus(self): if self.content == 'movie': try: control.jsonrpc('{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid" : %s, "playcount" : 1 }, "id": 1 }' % str(self.DBID)) if not self.folderPath.startswith('plugin://'): control.refresh() except: pass try: from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('movie', self.title ,year=self.year) metaget.change_watched(self.content, '', self.imdb, season='', episode='', year='', watched=7) except: pass try: if trakt.getTraktAddonMovieInfo() == False: trakt.markMovieAsWatched(self.imdb) trakt.syncMovies() except: pass elif self.content == 'episode': try: control.jsonrpc('{"jsonrpc": "2.0", "method": "VideoLibrary.SetEpisodeDetails", "params": {"episodeid" : %s, "playcount" : 1 }, "id": 1 }' % str(self.DBID)) if not self.folderPath.startswith('plugin://'): control.refresh() except: pass try: from metahandler import metahandlers metaget = metahandlers.MetaData(preparezip=False) metaget.get_meta('tvshow', self.tvshowtitle, imdb_id=self.imdb) metaget.get_episode_meta(self.tvshowtitle, self.imdb, self.season, self.episode) metaget.change_watched(self.content, '', self.imdb, season=self.season, episode=self.episode, year='', watched=7) except: pass try: if trakt.getTraktAddonEpisodeInfo() == False: trakt.markEpisodeAsWatched(self.tvdb, self.season, self.episode) trakt.syncTVShows() except: pass
def clearSearch(): cache.clear('rel_srch') control.refresh()
elif action == 'tvWidget': from resources.lib.indexers import episodes episodes.episodes().widget() elif action == 'episodeFavourites': from resources.lib.indexers import episodes episodes.episodes().favourites() elif action == 'calendars': from resources.lib.indexers import episodes episodes.episodes().calendars() elif action == 'refresh': from resources.lib.libraries import control control.refresh() elif action == 'queueItem': from resources.lib.libraries import control control.queueItem() elif action == 'openPlaylist': from resources.lib.libraries import control control.openPlaylist() elif action == 'openSettings': from resources.lib.libraries import control control.openSettings(query) elif action == 'moviePlaycount': from resources.lib.libraries import playcount
def personalizeSettings(self): control.openSettings() control.setSetting('showPersonalize', 'false') control.refresh()
def optimizeLibrary(self): gmatv.reloadCatalogCache() control.setSetting('showUpdateCatalog', 'false') control.refresh()
def removeShowFromLibrary(self, id, name): gmatv.removeFromLibrary(id, name) control.refresh()
def endSetup(self): control.setSetting('addonNewInstall', 'false') control.refresh()
def tvshows(tvshowtitle, imdb, tvdb, season, watched): try: import sys, xbmc if not trakt.getTraktIndicatorsInfo() == False: raise Exception() from metahandler import metahandlers from resources.lib.indexers import episodes metaget = metahandlers.MetaData(preparezip=False) name = control.addonInfo('name') dialog = control.progressDialogBG dialog.create(str(name), str(tvshowtitle)) dialog.update(0, str(name), str(tvshowtitle)) metaget.get_meta('tvshow', name='', imdb_id=imdb) items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0', '0', idx=False) try: items = [ i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season'])) ] except: pass items = [{ 'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode'])) } for i in items] for i in range(len(items)): if xbmc.abortRequested == True: return sys.exit() dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label'])) season, episode = items[i]['season'], items[i]['episode'] metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode) metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched)) try: dialog.close() except: pass except Exception as e: control.log('playcount %s' % e) try: dialog.close() except: pass try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if int(watched) == 7: trakt.markTVShowAsWatched(tvdb) else: trakt.markTVShowAsNotWatched(tvdb) trakt.cachesyncTVShows() except: pass control.refresh()
def enterCredentials(self): tfctv.enterCredentials() control.setSetting('showEnterCredentials', 'false') control.refresh()