def my_gist_hash (): return '3312e9f0ee2e9268d849057364c7fa9f' def my_addon_version (): return '1.18.1' def my_version (): return my_addon_version() + '-gist-r11' # priv: revision 70 # If the version number mismatches, overwrite gist_hash in settings.xml if (my_addon_version() != xbmcaddon.Addon().getAddonInfo('version')): addon.setSetting('gist_hash', version_gist_hash[xbmcaddon.Addon().getAddonInfo('version')]) sites = [ { 'title': '酷播 99KUBO', 'action': 'list_items', 'callback': 'kubo_id()', 'isFolder': True, 'siteVisible': 'siteVisible = True' }, { 'title': '劇迷 gimy.tv', 'action': 'list_items', 'callback': 'gimytv_id()', 'isFolder': True, 'siteVisible': 'siteVisible = True' }, { 'title': '劇迷 gimy.cc', 'action': 'list_items', 'callback': 'gimycc_id()', 'isFolder': True, 'siteVisible': 'siteVisible = True' }, ] def read_program (python_program): python_program_text = '' if os.path.isfile(python_program): with open(python_program, 'r') as f: python_program_text = f.read() return (python_program_text) def read_site_order (): python_file = 'site_order.py' return read_program(os.path.join(get_tempdir(), python_file)) def read_youtube_channels (): python_file = 'YouTube_Channels.py' # 1st: try /tmp python_program_text = read_program(os.path.join(get_tempdir(), python_file)) if (0 >= len(python_program_text)): # 2nd: try /userdata python_program_text = read_program(os.path.join(xbmc.translatePath('special://masterprofile'), 'addon_data/plugin.video.hdp_ims', python_file)) return (python_program_text) def list_sites (params): name = 'list_sites()' site_order = [] youtube_channels = [] xbmc.log('[%s] %s' % (name, '0. site_order={' + ', '.join(map(str, site_order)) + '}'), xbmc.LOGNOTICE) xbmc.log('[%s] %s' % (name, '0. youtube_channels={' + ', '.join(map(str, youtube_channels)) + '}'), xbmc.LOGNOTICE) # read user-defined site order exec read_site_order() # check if site_order is valid if (len(site_order) != len(sites)): site_order = range(len(sites)) xbmc.log('[%s] %s' % (name, '1. site_order={' + ', '.join(map(str, site_order)) + '}'), xbmc.LOGNOTICE) # read user-defined youtube channels exec read_youtube_channels() xbmc.log('[%s] %s' % (name, '2. youtube_channels={' + ', '.join(youtube_channels) + '}'), xbmc.LOGNOTICE) for site_index in site_order: site = sites[site_index] exec site['siteVisible'] if (siteVisible): li = xbmcgui.ListItem(site['title']) params['action'] = site['action'] params['callback'] = site['callback'] params['data'] = base64.b64encode(json.dumps(site).encode('utf-8')) url = build_url_dict(params) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=site['isFolder']) if params['show_hidden_sites']: # Separator xbmcplugin.addDirectoryItem(handle=addon_handle, url='', listitem=xbmcgui.ListItem('----------'), isFolder=False) for site in hidden_sites: li = xbmcgui.ListItem(site['title']) params['action'] = site['action'] params['callback'] = site['callback'] params['data'] = base64.b64encode(json.dumps(site).encode('utf-8')) url = build_url_dict(params) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=site['isFolder']) # Separator xbmcplugin.addDirectoryItem(handle=addon_handle, url='', listitem=xbmcgui.ListItem('=========='), isFolder=False) # Version if ((not params['show_hidden_sites']) and ('1' == addon.getSetting('hs_show'))): params['action'] = 'input_password_to_show_hidden_sites' url = build_url_dict(params) isFolder = True else: url = '' isFolder = False xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=xbmcgui.ListItem('[版本資訊] hdp_ims: ' + my_version()), isFolder=isFolder) # Separator xbmcplugin.addDirectoryItem(handle=addon_handle, url='', listitem=xbmcgui.ListItem('=========='), isFolder=False) xbmcplugin.endOfDirectory(addon_handle) # -- kubo -- kubo_episode_str3 = 'http' def kubo_videos (params): data = json.loads(base64.b64decode(params['data']), 'utf-8') try: page = int(data['page']) except: page = 1 order = str_between(params['link'], '-order-', ' ').strip() html = get_link_contents(params['link'].replace('.html', '-p-' + str(page) + '.html' )) if ('' == html): return [] pageInfo = str_between(html, '當前:', '頁') if ('' == pageInfo): pageInfo = '1/1' pages = pageInfo.split('/') htmlToExplode = str_between(html, '