def toggle_subtitles(mode, current): if mode == "all": subtitles = get_subtitles_enabled() if subtitles == "1": subtitles = "0" else: subtitles = "1" common.file_put_contents("/data/etc/.subtitles_enabled", subtitles) os.system("sh /data/hack/subtitles.sh") common.set_string("subtitles-plugin", subtitles) if mode == "language": if get_subtitles_language_filter() == "0" and current != "1": common.set_string("subtitles-plugin-language","1") else: config = ConfigParser.SafeConfigParser({"lang": "All", "plugins" : "BierDopje,OpenSubtitles", "tvplugins" : "BierDopje,OpenSubtitles", "movieplugins" : "OpenSubtitles" }) if os.path.exists("/data/etc/.subtitles"): config.read("/data/etc/.subtitles") config.set("DEFAULT", "lang", "All") if os.path.exists("/data/etc/.subtitles"): configfile = open("/data/etc/.subtitles", "w") config.write(configfile) configfile.close() common.set_string("subtitles-plugin-language","0")
def register_defaults(): subtitle_provider("get", "default") subtitle_provider("get", "tv") subtitle_provider("get", "movie") common.set_string("subtitles-plugin-language", get_subtitles_language_filter() ) common.set_string("subtitles-plugin", get_subtitles_enabled() ) common.set_string("featured-feed", get_featured_feed() ) common.set_string("featured-name", get_featured_name() ) common.set_string("browser-homepage", "".join(get_browser_homepage().split("http://")) ) if not os.path.exists("/data/etc/.subtitles"): common.file_put_contents("/data/etc/.subtitles", """[DEFAULT] lang = All movieplugins = OpenSubtitles,Undertexter tvplugins = BierDopje,OpenSubtitles,Addic7ed,Subtitulos,SubsWiki,Undertexter plugins = BierDopje,OpenSubtitles,Subtitulos,SubsWiki,Addic7ed,Undertexter [BierDopje] key = C2FAFCBE34610608 """) set_home_enabled_strings() version_local = get_local_version() if version_local != "": common.set_string("boxeeplus-version", version_local )
def toggle_subtitles(mode, current): if mode == "all": subtitles = get_subtitles_enabled() if subtitles == "1": subtitles = "0" else: subtitles = "1" common.file_put_contents("/data/etc/.subtitles_enabled", subtitles) os.system("sh /data/hack/subtitles.sh") xbmc.executebuiltin("Skin.SetString(subtitles-plugin,%s)" % subtitles) if mode == "language": if get_subtitles_language_filter() == "0" and current != "1": xbmc.executebuiltin("Skin.SetString(subtitles-plugin-language,1)") else: config = ConfigParser.SafeConfigParser({"lang": "All", "plugins" : "BierDopje,OpenSubtitles", "tvplugins" : "BierDopje,OpenSubtitles", "movieplugins" : "OpenSubtitles" }) if os.path.exists("/data/hack/boxee/scripts/OpenSubtitles/resources/lib/config.ini"): config.read("/data/hack/boxee/scripts/OpenSubtitles/resources/lib/config.ini") config.set("DEFAULT", "lang", "All") if os.path.exists("/data/hack/boxee/scripts/OpenSubtitles/resources/lib/config.ini"): configfile = open("/data/hack/boxee/scripts/OpenSubtitles/resources/lib/config.ini", "w") config.write(configfile) configfile.close() xbmc.executebuiltin("Skin.SetString(subtitles-plugin-language,0)")
def store_fanart_list(): global shows file = "" for show in fanart: file = file + show + "=" + fanart[show] + "\n" common.file_put_contents("/data/etc/.fanart", file)
def toggle_boot_to_xbmc(): bootenabled = get_boot_to_xbmc_enabled() if bootenabled == "1": bootenabled = "0" else: bootenabled = "1" common.file_put_contents("/data/etc/.boot_to_xbmc_enabled", bootenabled) common.set_string("boot-to-xbmc", bootenabled)
def theme_previous(): get_themes() #Load varaiables with theme names based on the directory structure theme_selected_tracker = get_theme_selected_from_file() #Get the numerical value of the theme currently showing on the boxee+ settings page num = int(theme_selected_tracker) - 1 #convert string read from file to int so a comparison can be completed and add 1 if num < 0: num = theme_count -1 # if the number has been set back to 0 then go back to the top. theme_selected_tracker = "%s" % num# convert it back to string to be written to the tracker file. common.file_put_contents("/data/etc/.replace_theme_enabled", theme_selected_tracker) #write the currently shown theme number back to file xbmc.executebuiltin("Skin.SetString(theme-name,%s)" % get_theme_name() ) #change the text shown on the setting screen.
def toggle_jump_to_last_unwatched(): jumpenabled = get_jump_to_last_unwatched_value() if jumpenabled == "1": jumpenabled = "0" else: jumpenabled = "1" common.file_put_contents("/data/etc/.jump_to_unwatched_enabled", jumpenabled) xbmc.executebuiltin("Skin.SetString(jump-to-unwatched,%s)" % jumpenabled)
def featured_previous(): replace = get_featured_feed_value() num = int(replace) - 1 if num < 0: num = 4 replace = "%s" % num common.file_put_contents("/data/etc/.replace_featured_enabled", replace) common.set_string("featured-feed", get_featured_feed() ) common.set_string("featured-name", get_featured_name() )
def toggle_homeenabled(section): homeenabled = get_homeenabled_value().split(",") if section in homeenabled: homeenabled.remove(section) else: homeenabled.append(section) common.file_put_contents("/data/etc/.home_enabled", ",".join(homeenabled)) set_home_enabled_strings()
def showmusic_function(): showmusic = common.file_get_contents("/data/etc/.showmusic_enabled") if showmusic == "1": showmusic = "0" else: showmusic = "1" xbmc.executebuiltin("Skin.SetString(showmusic,%s)" % showmusic) common.file_put_contents("/data/etc/.showmusic_enabled", showmusic)
def featured_previous(): replace = get_featured_feed_value() num = int(replace) - 1 if num < 0: num = 4 replace = "%s" % num common.file_put_contents("/data/etc/.replace_featured_enabled", replace) xbmc.executebuiltin("Skin.SetString(featured-feed,%s)" % get_featured_feed() ) xbmc.executebuiltin("Skin.SetString(featured-name,%s)" % get_featured_name() )
def toggle_jump_to_last_unwatched(): jumpenabled = get_jump_to_last_unwatched_value() if jumpenabled == "1": jumpenabled = "0" else: jumpenabled = "1" common.file_put_contents("/data/etc/.jump_to_unwatched_enabled", jumpenabled) common.set_string("jump-to-unwatched", jumpenabled)
def store_fanart_list(): global shows, fanart_changed file = "" for show in fanart: art = fanart[show] file = file + "%s=" % show file = file + "%s\n" % art common.file_put_contents("/data/etc/.fanart", file.encode("utf-8")) fanart_changed = 0
def featured_previous(): replace = get_featured_feed_value() num = int(replace) - 1 if num < 0: num = 3 replace = "%s" % num common.file_put_contents("/data/etc/.replace_featured_enabled", replace) xbmc.executebuiltin("Skin.SetString(featured-feed,%s)" % get_featured_feed()) xbmc.executebuiltin("Skin.SetString(featured-name,%s)" % get_featured_name())
def toggle_homeenabled(section, action): homeenabled = get_homeenabled_value().split(",") if section in ["friends", "shows", "movies", "music"]: if section == "friends": types = [ "Built-in", "Netflix", "Vudu", "Navi-X", "Spotify", "Grooveshark", "Pandora", "BBC iPlayer", "Revision3", "Crunchyroll", "Off" ] if section == "shows": types = [ "Built-in", "BBC iPlayer", "Revision3", "Crunchyroll", "Off" ] if section == "movies": types = ["Built-in", "Netflix", "Vudu", "Navi-X", "Off"] if section == "music": types = ["Built-in", "Spotify", "Grooveshark", "Pandora", "Off"] replacement = get_homereplacement(section) for item in homeenabled: itemname = item.split("|")[0] if itemname == section: homeenabled.remove(item) pos = types.index(replacement) if action == "next": pos = pos + 1 if action == "previous": pos = pos - 1 if pos >= len(types): pos = 0 if pos < 0: pos = len(types) - 1 if types[pos] != "Off": homeenabled.append("%s|%s" % (section, types[pos])) else: found = 0 for item in homeenabled: itemname = item.split("|")[0] if itemname == section: homeenabled.remove(item) found = 1 if found == 0: homeenabled.append(section) common.file_put_contents("/data/etc/.home_enabled", ",".join(homeenabled)) set_home_enabled_strings()
def store_fanart_list(): global shows, fanart_changed file = "" for show in fanart: art = fanart[show] file = file + "%s=" % show file = file + "%s\n" % art common.file_put_contents(xbmc.translatePath('special://profile/.fanart'), file.encode("utf-8")) fanart_changed = 0
def set_telnet_password(): passwd = common.file_get_contents("/data/etc/passwd") kb = xbmc.Keyboard('default', 'heading', True) kb.setDefault(passwd) # optional kb.setHeading('Enter telnet password') # optional kb.setHiddenInput(True) # optional kb.doModal() if kb.isConfirmed(): passwd = kb.getText() if passwd == "": dialog = xbmcgui.Dialog() ok = dialog.ok('Telnet', 'The telnet password must not be empty.') else: common.file_put_contents("/data/etc/passwd", passwd)
def set_youtube_sub(): youtube = common.file_get_contents("/data/etc/youtube") yt = xbmc.Keyboard('default', 'heading', True) yt.setDefault(youtube) # optional yt.setHeading('Enter YouTube username') # optional yt.setHiddenInput(False) # optional yt.doModal() if yt.isConfirmed(): you = yt.getText() if you == "": dialog = xbmcgui.Dialog() ok = dialog.ok('YouTube', 'You most enter a username.') else: common.file_put_contents("/data/etc/youtube", you) xbmc.executebuiltin("Skin.SetString(youtube,%s)" % you )
def set_youtube_sub(): youtube = common.file_get_contents("/data/etc/youtube") yt = xbmc.Keyboard('default', 'heading', True) yt.setDefault(youtube) # optional yt.setHeading('Enter YouTube username') # optional yt.setHiddenInput(False) # optional yt.doModal() if yt.isConfirmed(): you = yt.getText() if you == "": dialog = xbmcgui.Dialog() ok = dialog.ok('YouTube', 'You most enter a username.') else: common.file_put_contents("/data/etc/youtube", you) xbmc.executebuiltin("Skin.SetString(youtube,%s)" % you)
def toggle_homeenabled(section, action): homeenabled = get_homeenabled_value().split(",") if section in ["friends","shows","movies","music"]: if section == "friends": types = ["Built-in", "Netflix", "Vudu", "Navi-X", "Spotify", "Grooveshark", "Pandora", "BBC iPlayer", "Revision3", "Crunchyroll", "Off"] if section == "shows": types = ["Built-in", "BBC iPlayer", "Revision3", "Crunchyroll", "Off"] if section == "movies": types = ["Built-in", "Netflix", "Vudu", "Navi-X", "Off"] if section == "music": types = ["Built-in", "Spotify", "Grooveshark", "Pandora", "Off"] replacement = get_homereplacement(section) for item in homeenabled: itemname = item.split("|")[0] if itemname == section: homeenabled.remove(item) pos = types.index(replacement) if action == "next": pos = pos + 1 if action == "previous": pos = pos - 1 if pos >= len(types): pos = 0 if pos < 0: pos = len(types) - 1 if types[pos] != "Off": homeenabled.append("%s|%s" % (section, types[pos])) else: found = 0 for item in homeenabled: itemname = item.split("|")[0] if itemname == section: homeenabled.remove(item) found = 1 if found == 0: homeenabled.append(section) common.file_put_contents("/data/etc/.home_enabled", ",".join(homeenabled)) set_home_enabled_strings()
def toggle_subtitles(mode, current): if mode == "all": subtitles = get_subtitles_enabled() if subtitles == "1": subtitles = "0" else: subtitles = "1" common.file_put_contents("/data/etc/.subtitles_enabled", subtitles) os.system("sh /data/hack/subtitles.sh") xbmc.executebuiltin("Skin.SetString(subtitles-plugin,%s)" % subtitles) if mode == "language": if get_subtitles_language_filter() == "0" and current != "1": xbmc.executebuiltin("Skin.SetString(subtitles-plugin-language,1)") else: config = ConfigParser.SafeConfigParser({ "lang": "All", "plugins": "BierDopje,OpenSubtitles", "tvplugins": "BierDopje,OpenSubtitles", "movieplugins": "OpenSubtitles" }) if os.path.exists( "/data/hack/boxee/scripts/OpenSubtitles/resources/lib/config.ini" ): config.read( "/data/hack/boxee/scripts/OpenSubtitles/resources/lib/config.ini" ) config.set("DEFAULT", "lang", "All") if os.path.exists( "/data/hack/boxee/scripts/OpenSubtitles/resources/lib/config.ini" ): configfile = open( "/data/hack/boxee/scripts/OpenSubtitles/resources/lib/config.ini", "w") config.write(configfile) configfile.close() xbmc.executebuiltin("Skin.SetString(subtitles-plugin-language,0)")
def set_browser_homepage(): homepage = get_browser_homepage() kb = xbmc.Keyboard('default', 'heading', True) kb.setDefault(homepage) kb.setHeading('Enter homepage URL') # optional kb.setHiddenInput(False) # optional kb.doModal() if kb.isConfirmed(): homepage = kb.getText() common.file_put_contents("/data/etc/.browser_homepage", homepage) template = common.file_get_contents("/data/hack/apps/browser2/template.xml") template = homepage.join(template.split("$URL$")) common.file_put_contents("/data/hack/apps/browser2/descriptor.xml", template) os.system("sh /data/hack/apps.sh") common.set_string("browser-homepage", "".join(get_browser_homepage().split("http://")) )
def set_squeezecontroller(): squeezecontroller = get_squeezecontroller() kb = xbmc.Keyboard('default', 'heading', True) kb.setDefault(squeezecontroller) kb.setHeading('Enter squeezecontroller hostname or IP') # optional kb.setHiddenInput(False) # optional kb.doModal() if kb.isConfirmed(): squeezecontroller = kb.getText() squeezecontroller = squeezecontroller.strip() if running_squeezeslave() == 1: mc.ShowDialogNotification("Killing squeezeslave") try: os.system("killall squeezeslave") time.sleep(2) except: pass else: mc.ShowDialogNotification("Squeezeslave is not running") if squeezecontroller == "": dialog = xbmcgui.Dialog() if dialog.yesno('Squeezeslave', 'Unsetting squeezecontroller disables squeezeslave! Do you want to disable squeezeslave?'): os.system("rm /data/etc/squeezecontroller") else: mc.ShowDialogNotification("Updating squeezeslave settings") common.file_put_contents("/data/etc/squeezecontroller", squeezecontroller) mc.ShowDialogNotification("Starting squeezeslave") os.system("sh /data/hack/squeezeslave.sh") # wait 2 seconds, usually squeezeslave crashes when settings are wrong time.sleep(2) if running_squeezeslave() == 1: mc.ShowDialogNotification("Squeezeslave started successfully") else: mc.ShowDialogNotification("Squeezeslave start failed, check settings!") common.set_string("squeezecontroller", get_squeezecontroller() )
def apply_theme(): get_themes() #Load varaiables with theme names based on the directory structure theme_location = get_theme_path() #Load variable theme_location with the theme path theme_name = get_theme_name() #Load variable theme_name with the theme name should_restart = 'false' #Created variable to monitor if the selected theme needs a full restart if theme_name == 'boxee': # Ask for confirmation of a full restart if the selected theme is boxee if mc.ShowDialogConfirm("Restart Required", "To apply the original boxee theme a full restart is required", "Cancel", "Restart"): should_restart = 'true' else: return if os.path.isfile(theme_location + '/skin.sh'):#checks the presence of skin.sh before applying the theme if os.path.isfile(theme_location + '/media/Textures.xbt'):#checks the presence of Textures.xbt before applything theme. commandStr = "cp -f " + theme_location + "/*.sh /data/hack/"#build the copy comand to copy skin.sh and or splash.sh to the hack directory commandStr = "%s" % commandStr#converts to a string os.system(commandStr)#exectures the copy command os.system("dos2unix /data/hack/*.sh")#if the .sh file has been edited in windows then its not possible to execute it. this converts the files to unixx files os.system("chmod 777 /data/hack/*.sh")#ensures all *.sh files are executable os.system("sh /data/hack/skin.sh")#runs skin.sh to map the texture folder to the curenntly chosen theme common.file_put_contents("/data/etc/.currently_enabled_theme", theme_name)#write the currently enabled theme to text file elif theme_name == 'boxee':#boxee is the only theme that doesnt require a Textures.xby so make an exception if its not present commandStr = "cp -f " + theme_location + "/*.sh /data/hack/" commandStr = "%s" % commandStr os.system(commandStr) os.system("dos2unix /data/hack/*.sh") os.system("chmod 777 /data/hack/*.sh") os.system("sh /data/hack/skin.sh") common.file_put_contents("/data/etc/.currently_enabled_theme", theme_name)#write the currently enabled theme to text file else: mc.ShowDialogOk("Error", "It appears that this theme has not been contructed correctly.\n\n Please contact the author of the theme for further assistance")#error message for missing Textures.xbt return else: mc.ShowDialogOk("Error", "It appears that this theme has not been contructed correctly.\n\n Please contact the author of the theme for further assistance")#error message for missing skin.sh return if should_restart == 'true':#if the restart variable was set to true restart os.system("reboot") else: os.system("sh /data/hack/reset.sh") #if the variable was set to false do a soft reset
def set_watched(command): list = mc.GetWindow(10483).GetList(52) item = list.GetItem(1) series = mc.GetInfoString("Container(52).ListItem.TVShowTitle") db_path = xbmc.translatePath('special://profile/Database/') itemList = list.GetItems() seasons = [] episodes_count = 0 for item in itemList: season = item.GetSeason() if (season != -1): seasons.append(season) episodes_count = episodes_count + 1 seasons = dict.fromkeys(seasons) seasons = seasons.keys() use_season = -1 display_name = series season_string = "" if (len(seasons) == 1): display_name = "Season %s" % (seasons[0]) season_string = " %s" % display_name use_season = seasons[0] dialog = xbmcgui.Dialog() if dialog.yesno( "Watched", "Do you want to mark all episodes of %s%s as %s?" % (series, season_string, command)): progress = xbmcgui.DialogProgress() progress.create( 'Updating episodes', 'Setting %s%s as %s' % (series, season_string, command)) current_count = 0 info_count = 0 sql = ".timeout 100000;\n" for item in itemList: episode = item.GetEpisode() boxeeid = mc.GetInfoString("Container(52).ListItem(" + str(info_count) + ").Property(boxeeid)") info_count = info_count + 1 print boxeeid if (episode != -1): current_count = current_count + 1 percent = int((episodes_count / current_count) * 100) message = "Episode " + str(current_count) + " out of " + str( episodes_count) progress.update(percent, "", message, "") path = item.GetPath() # First make sure we don't get double values in the DB, so remove any old ones sql = sql + "DELETE FROM watched WHERE strPath = \"" + path + "\" or (strBoxeeId != \"\" AND strBoxeeId = \"" + boxeeid + "\");\n" if command == "watched": sql = sql + "INSERT INTO watched VALUES(null, \"" + path + "\", \"" + boxeeid + "\", 1, 0, -1.0);\n" common.file_put_contents("/tmp/sqlinject", sql) os.system('cat /tmp/sqlinject | /data/hack/bin/sqlite3 ' + db_path + 'boxee_user_catalog.db') xbmc.executebuiltin("Container.Update") xbmc.executebuiltin("Container.Refresh") xbmc.executebuiltin("Window.Refresh") progress.close() xbmc.executebuiltin("XBMC.ReplaceWindow(10483)") # progress = xbmcgui.DialogProgress() # progress.create('Updating episodes', 'Setting %s%s as %s' % (series, season_string, command)) # # for x in range(0, 10): # time.sleep(1); # xbmc.executebuiltin("Container.Update") # xbmc.executebuiltin("Container.Refresh") # xbmc.executebuiltin("Window.Refresh") # # progress.close() # # xbmc.executebuiltin("XBMC.ReplaceWindow(10483)") xbmc.executebuiltin("Notification(,%s marked as %s...,2000)" % (display_name, command))
def set_watched(command): list = mc.GetWindow(10483).GetList(52) item = list.GetItem(1) series = mc.GetInfoString("Container(52).ListItem.TVShowTitle") db_path = xbmc.translatePath('special://profile/Database/') itemList = list.GetItems() seasons = [] episodes_count = 0 for item in itemList: season = item.GetSeason() if(season != -1): seasons.append(season) episodes_count = episodes_count + 1 seasons = dict.fromkeys(seasons) seasons = seasons.keys() use_season = -1 display_name = series season_string = "" if(len(seasons) == 1): display_name = "Season %s" % (seasons[0]) season_string = " %s" % display_name use_season = seasons[0] dialog = xbmcgui.Dialog() if dialog.yesno("Watched", "Do you want to mark all episodes of %s%s as %s?" % (series, season_string, command)): progress = xbmcgui.DialogProgress() progress.create('Updating episodes', 'Setting %s%s as %s' % (series, season_string, command)) current_count = 0 info_count = 0 sql = ".timeout 100000;\n" for item in itemList: episode = item.GetEpisode() boxeeid = mc.GetInfoString("Container(52).ListItem("+str(info_count)+").Property(boxeeid)") info_count = info_count + 1 print boxeeid if(episode != -1): current_count = current_count+1 percent = int( ( episodes_count / current_count ) * 100) message = "Episode " + str(current_count) + " out of " + str(episodes_count) progress.update( percent, "", message, "" ) path = item.GetPath() # First make sure we don't get double values in the DB, so remove any old ones sql = sql + "DELETE FROM watched WHERE strPath = \""+path+"\" or (strBoxeeId != \"\" AND strBoxeeId = \""+boxeeid+"\");\n" if command == "watched": sql = sql + "INSERT INTO watched VALUES(null, \""+path+"\", \""+boxeeid+"\", 1, 0, -1.0);\n" common.file_put_contents("/tmp/sqlinject", sql) os.system('cat /tmp/sqlinject | /data/hack/bin/sqlite3 ' + db_path + 'boxee_user_catalog.db') xbmc.executebuiltin("Container.Update") xbmc.executebuiltin("Container.Refresh") xbmc.executebuiltin("Window.Refresh") progress.close() xbmc.executebuiltin("XBMC.ReplaceWindow(10483)") # progress = xbmcgui.DialogProgress() # progress.create('Updating episodes', 'Setting %s%s as %s' % (series, season_string, command)) # # for x in range(0, 10): # time.sleep(1); # xbmc.executebuiltin("Container.Update") # xbmc.executebuiltin("Container.Refresh") # xbmc.executebuiltin("Window.Refresh") # # progress.close() # # xbmc.executebuiltin("XBMC.ReplaceWindow(10483)") xbmc.executebuiltin("Notification(,%s marked as %s...,2000)" % (display_name, command))