def getWordsListing(show_all=False): listing = list() categories = get_categories() severities = get_severities() catId = 0 for name, tuples in categories.iteritems(): wordId = 0 for word, severity in tuples: if show_all or filter.is_blocked(severity, name, severities): params = {'mode': 'word-details', 'wordId': wordId, 'categoryId': catId} listing.append([word, sys.argv[0] + '?' + urllib.urlencode(params)]) wordId += 1 catId += 1 return listing
def getWordsListing(show_all=False): listing = list() categories = get_categories() severities = get_severities() catId = 0 for name, tuples in categories.iteritems(): wordId = 0 for word, severity in tuples: if show_all or filter.is_blocked(severity, name, severities): params = { 'mode': 'word-details', 'wordId': wordId, 'categoryId': catId } listing.append( [word, sys.argv[0] + '?' + urllib.urlencode(params)]) wordId += 1 catId += 1 return listing
def handle(params): try: mode = urllib.unquote_plus(params["mode"]) except: mode = None dialog = xbmcgui.Dialog() if mode == 'mute-movie': movieid = urllib.unquote_plus(params["id"]) xbmc.log("movieid: %s" % str(movieid)) details = data.getMovieDetails(movieid) xbmc.log('details: %s' % details) ret = dialog.yesno(details['label'], Addon.getLocalizedString(30302)) if not ret: sys.exit() fileLoc = details['file'] finder = subf.SubFinder(Addon) srtLoc = finder.getSRT(fileLoc) if srtLoc: xbmc.log("Using srt file: %s" % srtLoc) if createEDL(srtLoc, fileLoc): dialog.ok(details['label'], Addon.getLocalizedString(30303)) else: dialog.ok(details['label'], Addon.getLocalizedString(30307)) elif mode == 'mute-episode': episodeId = urllib.unquote_plus(params["id"]) xbmc.log("episodeId: %s" % str(episodeId)) details = data.getEpisodeDetails(episodeId) xbmc.log('details: %s' % details) ret = dialog.yesno(details['showtitle'], Addon.getLocalizedString(30308)) if not ret: sys.exit() fileLoc = details['file'] finder = subf.SubFinder(Addon) srtLoc = finder.getSRT(fileLoc) if srtLoc: xbmc.log("Using srt file: %s" % srtLoc) if createEDL(srtLoc): dialog.ok(details['showtitle'], Addon.getLocalizedString(30309)) else: dialog.ok(details['showtitle'], Addon.getLocalizedString(30307)) elif mode == 'movies': movieDict = data.GetAllMovies() xbmc.log("movieDict: %s" % movieDict) listing = [] for movie in movieDict: url = sys.argv[0] + "?mode=mute-movie&id=" + str(movie['movieid']) listing.append([movie['label'], movie['thumbnail'], url]) showThumbnailListing(listing) elif mode == 'tv': shows = data.GetAllTVShows() xbmc.log('tv shows: %s' % shows) listing = [] for show in shows: url = sys.argv[0] + "?mode=tvshow-details&id=" + str(show['tvshowid']) listing.append([show['label'], show['thumbnail'], url]) showThumbnailListing(listing, True) elif mode == 'tvshow-details': showId = urllib.unquote_plus(params["id"]) episodes = data.GetTVShowEpisodes(showId) xbmc.log('episodes: %s' % episodes) listing = [] for episode in episodes: url = sys.argv[0] + "?mode=mute-episode&id=" + str(episode['episodeid']) listing.append([episode['label'], episode['thumbnail'], url]) showThumbnailListing(listing, True) elif mode == 'view-active': show = dialog.yesno("WARNING", "This will show offensive words on screen.\nAre you sure you want to view it now?") if show: showSimpleListing(getWordsListing()) elif mode == 'show-all': show = dialog.yesno("WARNING", "This will show offensive words on screen.\nAre you sure you want to view it now?") if show: dialog.ok('XBMC', "To edit this list, modify 'filter.txt' in the script's directory" ) showSimpleListing(getWordsListing(True)) elif mode == 'word-details': categoryId = int(urllib.unquote_plus(params["categoryId"])) wordId = int(urllib.unquote_plus(params["wordId"])) categories = get_categories() prefs = get_severities() category = categories.keys()[categoryId] word, severity = categories[category][wordId] isFiltered = filter.is_blocked(severity, category, prefs) blockNum = None if category in prefs: blockNum = prefs[category] title = 'Blocking This Word' if isFiltered else 'Not Actively Blocking' line0 = 'Category: %s' % category line1 = "Severity (1 is lowest, 10 is most offensive): %d" % severity if blockNum: line2 = 'Current category setting blocks words with severity >= %d' % blockNum else: line2 = 'No setting for this category, cannot block it' dialog.ok(title, line0, line1, line2) else: xbmc.log("Running %s v%s. Using default listing." % (__scriptid__, __version__)) xbmc.log(" %s " % str(sys.argv[:])) showSimpleListing(getInitialListing())
def handle(params): try: mode = urllib.unquote_plus(params["mode"]) except: mode = None dialog = xbmcgui.Dialog() if mode == 'mute-movie': movieid = urllib.unquote_plus(params["id"]) xbmc.log("movieid: %s" % str(movieid)) details = data.getMovieDetails(movieid) xbmc.log('details: %s' % details) ret = dialog.yesno(details['label'], Addon.getLocalizedString(30302)) if not ret: sys.exit() fileLoc = details['file'] finder = subf.SubFinder(Addon) srtLoc = finder.getSRT(fileLoc) if srtLoc: xbmc.log("Using srt file: %s" % srtLoc) if createEDL(srtLoc, fileLoc): dialog.ok(details['label'], Addon.getLocalizedString(30303)) else: dialog.ok(details['label'], Addon.getLocalizedString(30307)) elif mode == 'mute-episode': episodeId = urllib.unquote_plus(params["id"]) xbmc.log("episodeId: %s" % str(episodeId)) details = data.getEpisodeDetails(episodeId) xbmc.log('details: %s' % details) ret = dialog.yesno(details['showtitle'], Addon.getLocalizedString(30308)) if not ret: sys.exit() fileLoc = details['file'] finder = subf.SubFinder(Addon) srtLoc = finder.getSRT(fileLoc) if srtLoc: xbmc.log("Using srt file: %s" % srtLoc) if createEDL(srtLoc, fileLoc): dialog.ok(details['showtitle'], Addon.getLocalizedString(30309)) else: dialog.ok(details['showtitle'], Addon.getLocalizedString(30307)) elif mode == 'movies': movieDict = data.GetAllMovies() xbmc.log("movieDict: %s" % movieDict) listing = [] for movie in movieDict: url = sys.argv[0] + "?mode=mute-movie&id=" + str(movie['movieid']) listing.append([movie['label'], movie['thumbnail'], url]) showThumbnailListing(listing) elif mode == 'tv': shows = data.GetAllTVShows() xbmc.log('tv shows: %s' % shows) listing = [] for show in shows: url = sys.argv[0] + "?mode=tvshow-details&id=" + str( show['tvshowid']) listing.append([show['label'], show['thumbnail'], url]) showThumbnailListing(listing, True) elif mode == 'tvshow-details': showId = urllib.unquote_plus(params["id"]) episodes = data.GetTVShowEpisodes(showId) xbmc.log('episodes: %s' % episodes) listing = [] for episode in episodes: url = sys.argv[0] + "?mode=mute-episode&id=" + str( episode['episodeid']) listing.append([episode['label'], episode['thumbnail'], url]) showThumbnailListing(listing, True) elif mode == 'view-active': show = dialog.yesno( "WARNING", "This will show offensive words on screen.\nAre you sure you want to view it now?" ) if show: showSimpleListing(getWordsListing()) elif mode == 'show-all': show = dialog.yesno( "WARNING", "This will show offensive words on screen.\nAre you sure you want to view it now?" ) if show: dialog.ok( 'XBMC', "To edit this list, modify 'filter.txt' in the script's directory" ) showSimpleListing(getWordsListing(True)) elif mode == 'word-details': categoryId = int(urllib.unquote_plus(params["categoryId"])) wordId = int(urllib.unquote_plus(params["wordId"])) categories = get_categories() prefs = get_severities() category = categories.keys()[categoryId] word, severity = categories[category][wordId] isFiltered = filter.is_blocked(severity, category, prefs) blockNum = None if category in prefs: blockNum = prefs[category] title = 'Blocking This Word' if isFiltered else 'Not Actively Blocking' line0 = 'Category: %s' % category line1 = "Severity (1 is lowest, 10 is most offensive): %d" % severity if blockNum: line2 = 'Current category setting blocks words with severity >= %d' % blockNum else: line2 = 'No setting for this category, cannot block it' dialog.ok(title, line0, line1, line2) else: xbmc.log("Running %s v%s. Using default listing." % (__scriptid__, __version__)) xbmc.log(" %s " % str(sys.argv[:])) showSimpleListing(getInitialListing())