def Remove_Content(id_array=[]): remove_list = [] # If Super Favourites exist add option to remove a social share sf_path = xbmc.translatePath( 'special://profile/addon_data/plugin.program.super.favourites/Super Favourites/%s' % settings_clean) if len(os.listdir(sf_path)) > 0: remove_list.append(String(30354)) my_text = Text_File(redirect_file, 'r') for item in id_array: if item[0] == 'apk': remove_list.append(String(30304) % item[1]) elif item[0] == 'addon': remove_list.append(String(30305) % item[1]) elif item[0] == '-exec' or item[0] == '-fav': remove_list.append(item[1]) choice = dialog.select(String(30307), remove_list) if choice >= 0: if remove_list[choice] != String(30354): remove_line = '%s~%s~%s\n' % ( id_array[choice][0], id_array[choice][1], id_array[choice][2]) if remove_line in my_text: replace_file = my_text.replace(remove_line, '') Text_File(redirect_file, 'w', replace_file) else: dialog.ok( 'DEFAULT ITEM', 'It\'s only possible to delete items you\'ve added, you cannot delete default items. If you want to create your own custom list set this menu as a custom list via the main +- button' ) # Social share removal else: default.Share_Removal(settings_clean)
def Favourite_Select(installed_content=''): import re import urllib import HTMLParser html_parser = HTMLParser.HTMLParser() final_array = [] dialog_array = [] favourites_path = xbmc.translatePath('special://profile/favourites.xml') if os.path.exists(favourites_path): contents = Text_File(favourites_path, 'r') match = re.compile('<favourite name="(.+?)".+?>(.+?)<\/favourite>', re.DOTALL).findall(contents) for name, command in match: if '-fav~%s~%s\n' % ( String(30326) % html_parser.unescape(name), html_parser.unescape(command)) not in installed_content: final_array.append('-fav~%s~%s\n' % (String(30326) % html_parser.unescape(name), html_parser.unescape(command))) dialog_array.append(html_parser.unescape(name)) choice = dialog.select(String(30323), dialog_array) if choice >= 0: return final_array[choice] else: dialog.ok(String(30324), String(30325)) return ''
def Remove_Content(id_array=[]): remove_list = [] my_text = Text_File(redirect_file, 'r') for item in id_array: if item[0] == 'apk': remove_list.append(String(30304) % item[1]) elif item[0] == 'addon': remove_list.append(String(30305) % item[1]) elif item[0] == '-exec' or item[0] == '-fav': remove_list.append(item[1]) choice = dialog.select(String(30307), remove_list) if choice >= 0: remove_line = '%s~%s~%s\n' % (id_array[choice][0], id_array[choice][1], id_array[choice][2]) if remove_line in my_text: replace_file = my_text.replace(remove_line, '') Text_File(redirect_file, 'w', replace_file) else: dialog.ok( 'DEFAULT ITEM', 'It\'s only possible to delete items you\'ve added, you cannot delete default items. If you want to create your own custom list set this menu as a custom list via the main +- button' )
def Main_Menu(url=main_xml): if debug == 'true': Add_Dir ( '[COLOR=lime]Koding Tutorials[/COLOR]', '', "tutorials", True, '', '', '' ) if url.startswith('http'): contents = Open_URL(url) else: contents = Text_File(url,'r') contents = contents.replace('\n','').replace('\t','') raw_links = Find_In_Text(content=contents, start='<item>', end=r'</item>') xbmc.log(repr(raw_links),2) counter = 1 for item in raw_links: xbmc.log('# Checking link %s'%counter,2) counter += 1 title = Find_In_Text(content=item, start='<title>', end=r'</title>') title = title[0] if (title!=None) else 'Unknown Video' thumb = Find_In_Text(content=item, start='<thumbnail>', end=r'</thumbnail>') thumb = thumb[0] if (thumb!=None) else '' fanart = Find_In_Text(content=item, start='<thumbnail>', end=r'</thumbnail>') fanart = fanart[0] if (fanart!=None) else '' if not '<sublink>' in item: links = Find_In_Text(content=item, start='<link>', end=r'</link>') else: links = Find_In_Text(content=item, start='<sublink>', end=r'</sublink>') if links[0].endswith('.xml') or links[0]=='none' or links[0] == '' or links[0].startswith('msg~'): links = links[0] if links == 'none' or links == '': Add_Dir( name=title, url='', mode='', folder=False, icon=thumb, fanart=fanart ) elif Data_Type(links)=='str': if links.startswith('msg~'): links = links.replace('msg~','') Add_Dir( name=title, url="{%s}"%links, mode='simple_dialog', folder=False, icon=thumb, fanart=fanart ) else: Add_Dir( name=title, url=links, mode='main_menu', folder=True, icon=thumb, fanart=fanart ) else: Add_Dir( name=title, url="{'url':%s}"%links, mode='play_link', folder=False, icon=thumb, fanart=fanart )
def Main_Menu(url=main_xml): # If debug mode is enabled show the koding tutorials if debug == 'true': Add_Dir('[COLOR=lime]Koding Tutorials[/COLOR]', '', "tutorials", True, '', '', '') ############################################################# # COMMENT OUT THE FOLLOWING 2 LINES WHEN READY FOR RELEASE!!! else: Add_Dir( '[COLOR=lime]Enable debug mode for some cool dev tools![/COLOR]', '', "koding_settings", False, '', '', '') ############################################################# # An optional example title/message, however in our example we're going to do one via our online xml so we've commented this out # my_message= "{'title' : 'Support & Suggestions', 'msg' : \"If you come across any online content you'd like to get added please use the support thread at noobsandnerds.com and I'll be happy to look into it for you.\"}" # Add_Dir( # name="Support/Suggestions", url=my_message, mode="simple_dialog", folder=False, # icon="https://cdn2.iconfinder.com/data/icons/picons-basic-2/57/basic2-087_info-512.png") # Read the contents of our file into memory if url.startswith('http'): contents = Open_URL(url) else: contents = Text_File(url, 'r') # This isn't essential but we'll replace all linebreaks (\n) and tabs (\t) with an empty string. # This removes them and just makes it a smaller file to work with and easier to debug. contents = contents.replace('\n', '').replace('\t', '') # Split the contents up into sections - we're finding every instance of <item> and </item> and everything inbetween raw_links = Find_In_Text(content=contents, start='<item>', end=r'</item>') xbmc.log(repr(raw_links), 2) counter = 1 # Now loop through each of those matches and pull out the relevant data for item in raw_links: xbmc.log('# Checking link %s' % counter, 2) counter += 1 title = Find_In_Text(content=item, start='<title>', end=r'</title>') title = title[0] if (title != None) else 'Unknown Video' thumb = Find_In_Text(content=item, start='<thumbnail>', end=r'</thumbnail>') thumb = thumb[0] if (thumb != None) else '' fanart = Find_In_Text(content=item, start='<thumbnail>', end=r'</thumbnail>') fanart = fanart[0] if (fanart != None) else '' # If this contains sublinks grab all of them if not '<sublink>' in item: links = Find_In_Text(content=item, start='<link>', end=r'</link>') # Otherwise just grab the link tag else: links = Find_In_Text(content=item, start='<sublink>', end=r'</sublink>') # If it's an xml file then we set the link to the xml path rather than a list of links if links[0].endswith('.xml') or links[0] == 'none' or links[ 0] == '' or links[0].startswith('msg~'): links = links[0] # If link is none we presume it's a folder if links == 'none' or links == '': Add_Dir(name=title, url='', mode='', folder=False, icon=thumb, fanart=fanart) # If link is a string it's either another menu or a message elif Data_Type(links) == 'str': # If it's a message clean up the string and load up the simple_dialog function if links.startswith('msg~'): links = links.replace('msg~', '') Add_Dir(name=title, url="{%s}" % links, mode='simple_dialog', folder=False, icon=thumb, fanart=fanart) # Otherwise we presume it's a menu else: Add_Dir(name=title, url=links, mode='main_menu', folder=True, icon=thumb, fanart=fanart) # Otherwise send through our list of links to the Play_Link function else: Add_Dir(name=title, url="{'url':%s}" % links, mode='play_link', folder=False, icon=thumb, fanart=fanart)
def Extract_Skins(): koding.Extract(skin_zip, skin_path) skinsize = os.path.getsize(skin_zip) Text_File(update_skin, 'w', skinsize)
def Add_Content(id_array): dolog('id_array: %s' % id_array) choice = dialog.select( String(30314), [String(30170), String(30323), String(30313), String(30354)]) if choice >= 0: my_text = Text_File(redirect_file, 'r') if choice == 0: if dialog.yesno(String(30507), String(30508), yeslabel=String(30510), nolabel=String(30509)): addon_id = Keyboard(String(30511)) dolog('SEARCHING ONLINE FOR: %s' % addon_id) Sleep_If_Function_Active(function=Install_Addons, args=[encryptme('e', addon_id)], show_busy=False, kill_time=120) # xbmc.executebuiltin('UpdateLocalAddons') Toggle_Addons(addon=addon_id) if xbmc.getCondVisibility('System.HasAddon(%s)' % addon_id): dialog.ok(String(30334), String(30512) % addon_id) else: include_list = Addon_Browser(browser_type='list', header=String(30306), skiparray=id_array) dolog('include_list: %s' % include_list) for item in include_list: if not my_text.endswith('\n'): my_text += '\n' my_text += 'addon~%s~%s\n' % (item[0], item[1]) elif choice == 1: my_text += Favourite_Select(my_text) elif choice == 2: # List of QP modes full_array = [ String(30318), String(30315), String(30319), String(30316), String(30320), String(30321), String(30317), String(30322) ] qp_dict = { String(30318): 'RunScript(script.qlickplay,info=list,type=movie)', String(30315): 'RunScript(script.qlickplay,info=list,type=movie,query=qqqqq)', String(30319): 'RunScript(script.qlickplay,info=list,type=tv)', String(30316): 'RunScript(script.qlickplay,info=list,type=tv,query=qqqqq)', String(30320): 'RunScript(script.qlickplay,info=list,type=video)', String(30321): 'RunScript(script.qlickplay,info=list,type=video,query=qqqqq)', String(30317): 'RunScript(script.qlickplay,info=list,type=channel)', String(30322): 'RunScript(script.qlickplay,info=list,type=channel,query=qqqqq)' } my_array = [] # Populate the list of QP items but don't show ones already installed for item in full_array: dolog('full_array: ' + repr(item)) if not item in my_text: my_array.append(item) choice = dialog.select(String(30314), my_array) if choice >= 0: my_text += '-exec~%s~%s\n' % (my_array[choice], qp_dict[my_array[choice]]) elif choice == 3: dolog('%s - running share_install' % settings_clean) Share_Install(settings_clean) Text_File(redirect_file, 'w', my_text)
redirect_setting = sys.argv[1] # If it's a submenu and not a main home menu we use the args else: redirect_setting = sys.argv[1] dolog('REDIRECT SETTING: %s' % redirect_setting) # Set the main redirect file redirect_file = os.path.join(redirects, redirect_setting) if not os.path.exists(redirects): os.makedirs(redirects) # Check the contents of the redirect file legacy_path = os.path.join(redirects, settings_clean) if os.path.exists(redirect_file): runcode = Text_File(redirect_file, 'r').replace('\r', '') elif os.path.exists(legacy_path): runcode = Text_File(legacy_path, 'r').replace('\r', '') cleanname = sys.argv[1].replace("HOME_", '').replace('SUBMENU_', '').replace( '_DIALOG_USER', '').replace('_DIALOG_PLUS_USER', '').replace('_EXEC_USER', '') cleanname = cleanname.replace('DIALOG', '').replace('_TVG', '') cleanname = cleanname.lower() mymenu = cleanname.replace('_', '').replace(' ', '') if mymenu == 'xxx': mymenu = 'adult' if mymenu == 'technology': mymenu = 'tech' if mymenu == 'cooking': mymenu = 'food'
def showlist(usenan=False): from operator import itemgetter myapps = koding.My_Apps() runcode_array = runcode.splitlines() delete_array = [] final_array = [] genre_array = [] id_array = [] cust_array = [] if os.path.exists(redirect_file + '_CUST'): temp_array = Text_File(redirect_file + '_CUST', 'r').splitlines() for line in temp_array: cust_array.append(line + '~custom') sf_path = Physical_Path( 'special://profile/addon_data/plugin.program.super.favourites/Super Favourites/%s' % settings_clean) if os.path.exists(sf_path): for item in os.listdir(sf_path): fullpath = os.path.join(sf_path, item) if os.path.isdir(fullpath): genre_array.append('share~' + item.replace('_', ' ') + '~' + item) if usenan: try: addon_list = Addon_Genre(genre=mymenu, custom_url=BASE + 'addons/addon_list_new.txt') except: try: addon_list = Addon_Genre(genre=mymenu) except: addon_list = {} if addon_list: my_addons = Get_Contents(path=ADDONS, exclude_list=['packages', 'temp'], full_path=False) addons_matching_genre = List_From_Dict(addon_list) for item in my_addons: try: addon_id = Get_Addon_ID(item) if addon_id in addons_matching_genre: name = koding.Cleanup_String(addon_list[addon_id]) genre_array.append('addon~' + name + '~' + addon_id) except: pass # Add genre list to our custom list runcode_array += genre_array runcode_array += cust_array xbmc.log(repr(runcode_array), 2) if 'HOME_LIVE_TV_TVG_DIALOG_PLUS' in redirect_setting: final_array.append([ '-exec', String(code=30993, source='script.trtv'), "xbmc.executebuiltin('RunScript(special://home/addons/script.trtv/addon.py)')" ]) for line in runcode_array: if '~' in line: raw_split = line.split('~') app_type = raw_split[0] clean_name = raw_split[1] # Make an exception for paths which contain tilda raw_split.pop(0) raw_split.pop(0) app_id = '' for item in raw_split: if item != 'custom': app_id += item if app_type == '-exec': final_array.append([app_type, clean_name, app_id]) if '~custom' in line: delete_array.append([app_type, clean_name, app_id]) if app_type == 'share': final_array.append([app_type, clean_name, app_id]) if app_type == '-fav': final_array.append([app_type, clean_name, app_id]) if '~custom' in line: delete_array.append([app_type, clean_name, app_id]) # Check the addon is installed, if it is add to the list if app_type == 'addon': try: myaddon = xbmcaddon.Addon(app_id) name = myaddon.getAddonInfo('name') if realname == 'true': clean_name = name final_array.append([app_type, clean_name, app_id]) if '~custom' in line: delete_array.append([app_type, clean_name, app_id]) id_array.append(app_id) except: pass if app_type == 'apk' and app_id in myapps: final_array.append([app_type, clean_name, app_id]) app_array = [] if len(final_array) > 0: final_array = sorted(final_array, key=itemgetter(0, 1)) for item in final_array: if item[0] == 'apk': app_array.append(String(30304) % item[1]) elif item[0] == 'share': app_array.append(String(30565) % item[1]) elif item[0] == 'addon': app_array.append(String(30305) % item[1]) elif item[0] == '-exec' or item[0] == '-fav': app_array.append(item[1]) app_array.append('------------------------------') final_array.append(['blank', '------------------------------', '']) app_array.append(String(30301)) final_array.append( ['add', String(30301), 'Add_Content(id_array=%s)' % id_array]) app_array.append(String(30302)) final_array.append([ 'remove', String(30302), 'Remove_Content(id_array=%s)' % delete_array ]) choice = dialog.select(Skin_String(cleanname.replace('_', '')), app_array) xbmc.log('delete array: %s' % delete_array, 2) if choice < 0: return else: run_app = final_array[choice] if run_app[0] == 'apk': xbmc.executebuiltin('StartAndroidActivity(%s)' % run_app[2]) elif run_app[0] == 'addon': xbmc.executebuiltin('RunAddon(%s)' % run_app[2]) elif run_app[0] == 'share': xbmc.executebuiltin( 'ActivateWindow(10001,"plugin://plugin.program.super.favourites/?folder=%s/%s",return)' % (settings_clean, urllib.quote_plus(run_app[2]))) SF_Single_Entry() else: try: exec(run_app[2]) except: xbmc.executebuiltin(run_app[2])