def index(): #Build default menu items #0) Downloads folder if kodiutils.get_setting_as_bool("download") and kodiutils.get_setting_as_bool("folder") and kodiutils.get_setting("downloadPath") and xbmcvfs.exists(kodiutils.get_setting("downloadPath")): liz = ListItem("["+kodiutils.get_string(32012)+"]") liz.setInfo( type="Video", infoLabels={"plot":kodiutils.get_string(32012)}) liz.setArt({"thumb":downloads_thumb, "fanart": fanart_bg}) addDirectoryItem(plugin.handle, plugin.url_for(downloads), liz, True) #1) Most Recent liz = ListItem("["+kodiutils.get_string(32013)+"]") liz.setInfo( type="Video", infoLabels={"plot":kodiutils.get_string(32013)}) liz.setArt({"thumb":recent_thumb, "fanart": fanart_bg}) addDirectoryItem(plugin.handle, plugin.url_for(show_episodes, urllib.quote('%sgetEpisodes%s&grouping=latest' % (BASE, KEY), safe=''), 0, urllib.quote(fanart_bg, safe='')), liz, True) #2) Featured liz = ListItem("["+kodiutils.get_string(32023)+"]") liz.setInfo( type="Video", infoLabels={"plot":kodiutils.get_string(32023)}) liz.setArt({"thumb":featured_thumb, "fanart": fanart_bg}) addDirectoryItem(plugin.handle, plugin.url_for(show_episodes, urllib.quote('%sgetEpisodes%s&grouping=featured' % (BASE, KEY), safe=''), 0, urllib.quote(fanart_bg, safe='')), liz, True) #3) Archive shows liz = ListItem("["+kodiutils.get_string(32014)+"]") liz.setInfo( type="Video", infoLabels={"plot":kodiutils.get_string(32014)}) liz.setArt({"thumb":archived_thumb, "fanart": fanart_bg}) addDirectoryItem(plugin.handle, plugin.url_for(list_shows, urllib.quote("%sgetShows%s&grouping=archived" % (BASE,KEY), safe='')), liz, True) #List shows list_shows(urllib.quote("%sgetShows%s" % (BASE,KEY), safe=''))
def index(): refresh = arg_as_bool('refresh') clear_cache = arg_as_bool('clear-cache') if clear_cache: include_premium = adobe_activate_api.is_authenticated() channel_list = events.get_channel_list(include_premium) util.clear_cache(events.get_live_events_url(channel_list)) current_time = time.strftime("%I:%M %p", time.localtime(time.time())) addDirectoryItem(plugin.handle, plugin.url_for(index, refresh=True), ListItem(get_string(30850) % current_time), True) include_premium = adobe_activate_api.is_authenticated() channel_list = events.get_channel_list(include_premium) espn_url = events.get_live_events_url(channel_list) legacy.index_legacy_live_events(espn_url) if get_setting_as_bool('ShowAndroidTVMenu'): url = base64.b64decode( 'aHR0cHM6Ly93YXRjaC5wcm9kdWN0LmFwaS5lc3BuLmNvbS9hcGkvcHJvZHVjdC92MS9hbmRyb2lkL3R2L2hvbWU=' ) addDirectoryItem(plugin.handle, plugin.url_for(page_api_url, url=url), ListItem(get_string(30780)), True) if get_setting_as_bool('ShowAppleTVMenu'): addDirectoryItem(plugin.handle, plugin.url_for(appletv.appletv_root_menu), ListItem(get_string(30730)), True) if get_setting_as_bool('ShowLegacyMenu'): addDirectoryItem(plugin.handle, plugin.url_for(legacy_root_menu), ListItem(get_string(30740)), True) if get_setting_as_bool('ShowRokuMenu'): addDirectoryItem(plugin.handle, plugin.url_for(roku.roku_root_menu), ListItem(get_string(30760)), True) if get_setting_as_bool('ShowTVOSMenu'): addDirectoryItem(plugin.handle, plugin.url_for(tvos.tvos_root_menu), ListItem(get_string(30750)), True) endOfDirectory(plugin.handle, updateListing=refresh, cacheToDisc=False)
def include_item(network_id): for setting in CHANNEL_SETTINGS: channel = CHANNEL_SETTINGS[setting] if channel == network_id: return get_setting_as_bool(setting) if network_id in SOURCE_NAME_TO_CHANNEL_SETTING: return get_setting_as_bool(SOURCE_NAME_TO_CHANNEL_SETTING[network_id]) return True
def index(): """Main menu""" if ku.get_setting_as_bool("show_genres"): add_menu_item(themes, 32005, args={ "href": "en/categories/stories", "title": ku.localize(32005) }, art=ku.icon("genres.png")) if ku.get_setting_as_bool("show_motions"): add_menu_item(themes, 32002, args={ "href": "en/categories/motions", "title": ku.localize(32002) }, art=ku.icon("techniques.png")) if ku.get_setting_as_bool("show_characters"): add_menu_item(themes, 32003, args={ "href": "en/categories/characters", "title": ku.localize(32003) }, art=ku.icon("characters.png")) if ku.get_setting_as_bool("show_authors"): add_menu_item(authors, 32004, art=ku.icon("authors.png")) if ku.get_setting_as_bool("show_experts"): add_menu_item(experts, 32023, art=ku.icon("experts.png")) if ku.get_setting_as_bool("show_techniques"): add_menu_item(themes, 32006, args={"href": "en/categories/techniques", "title": ku.localize(32006)}, art=ku.icon("techniques.png")) if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, args={"menu": True}, art=ku.icon("search.png")) if ku.get_setting_as_bool("show_recent"): add_menu_item(recent, 32026, art=ku.icon("saved.png")) if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) xbmcplugin.setPluginCategory(plugin.handle, ADDON_NAME) xbmcplugin.endOfDirectory(plugin.handle)
def index(): """Main menu""" if ku.get_setting_as_bool("show_home"): add_menu_item(show_category, 32009, { "href": "free", "title": ku.get_string(32009)}, ku.icon("home.png")) if ku.get_setting_as_bool("show_new"): add_menu_item(show_category, 32004, { "href": "free/new", "title": ku.get_string(32004)}, ku.icon("new.png")) if ku.get_setting_as_bool("show_popular"): add_menu_item(show_category, 32005, { "href": "free/popular", "title": ku.get_string(32005)}, ku.icon("popular.png")) if ku.get_setting_as_bool("show_collections"): add_menu_item(show_category, 32006, { "key": "collection", "href": "free/collections", "title": ku.get_string(32006), "isdir": True }, ku.icon("collection.png")) if ku.get_setting_as_bool("show_the_cut"): add_menu_item(show_category, "The Cut", { "key": "the-cut", "href": "the-cut", "title": "The Cut", }, ku.icon("the-cut.png")) if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, {"menu": True}, ku.icon("search.png")) if ku.get_setting_as_bool("show_recent"): add_menu_item(recent, 32021) if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) xp.setPluginCategory(plugin.handle, ADDON_NAME) xp.endOfDirectory(plugin.handle)
def index(): """Main menu""" if ku.get_setting_as_bool("show_genres"): add_menu_item(themes, 32005, { "href": "en/categories/stories", "title": ku.get_string(32005) }, ku.icon("genres.png")) if ku.get_setting_as_bool("show_motions"): add_menu_item(themes, 32002, { "href": "en/categories/motions", "title": ku.get_string(32002) }, ku.icon("techniques.png")) if ku.get_setting_as_bool("show_characters"): add_menu_item(themes, 32003, { "href": "en/categories/characters", "title": ku.get_string(32003) }, ku.icon("characters.png")) if ku.get_setting_as_bool("show_authors"): add_menu_item(authors, 32004, art=ku.icon("authors.png")) if ku.get_setting_as_bool("show_experts"): add_menu_item(experts, 32023, art=ku.icon("experts.png")) if ku.get_setting_as_bool("show_techniques"): add_menu_item(themes, 32006, { "href": "en/categories/techniques", "title": ku.get_string(32006) }, ku.icon("techniques.png")) if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, {"menu": True}, ku.icon("search.png")) if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) xp.setPluginCategory(plugin.handle, ADDON_NAME) xp.endOfDirectory(plugin.handle)
def index(): # type: () -> None """Main menu""" if ku.get_setting_as_bool("show_collections"): add_menu_item(collections, 32004, art=ku.icon("collection.png")) # Collections if ku.get_setting_as_bool("show_years"): add_menu_item(year, 32006, art=ku.icon("year.png")) # Years if ku.get_setting_as_bool("show_recent"): add_menu_item(recent, 32005, art=ku.icon("recent.png")) # Recent if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, {"menu": True}, ku.icon("search.png")) # Search if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) # Settings xbmcplugin.setPluginCategory(plugin.handle, ADDON_NAME) xbmcplugin.endOfDirectory(plugin.handle)
def onClick(self, controlID): if controlID == 9100: self.ClearAllListviews() sHost = kodiutils.get_setting('host') iPort = kodiutils.get_setting_as_int('port') bUseSSL = kodiutils.get_setting_as_bool('usessl') #Show error if we don't have any port or host if len(sHost) == 0: kodiutils.dialogok(__language__(30008), __language__(30009), __language__(30010), "") kodiutils.show_settings() return self.getControl(9002).setLabel( kodiutils.get_setting('host')) #print the host we connect to log("Connecting to: " + sHost) self.WS.ConnectTo(sHost, iPort, bUseSSL, "directory") if controlID == 9102: self.ClearAllListviews() self.WS.terminate() if controlID == 6000: self.CleanUp() self.close() if controlID == 9500: self.SetSorting("NAME", True) if controlID == 9501: self.SetSorting("MODIFY", True) if controlID == 9502: self.SetSorting("SIZE", True) if controlID == 9503: self.SetCleanFilename( self.getControl(9503).isSelected() == 1, True) if controlID == 100: self.onClickDirectory() if controlID == 500: self.onClickFilelist() if controlID == 9101: kodiutils.show_settings() self.getControl(9002).setLabel(kodiutils.get_setting('host')) if controlID == 600: self.onClickQueue() if controlID == 601: if kodiutils.dialogyesno(__language__(30011), __language__(30012)) == True: self.WS.SendMOTRCommand( "QUEUEMANAGEMENT", "-1;clear-finished" ) #QueueID = -1 when default commands are used if controlID == 602: if kodiutils.dialogyesno(__language__(30011), __language__(30013)) == True: self.WS.SendMOTRCommand( "QUEUEMANAGEMENT", "-1;stop-all-running" ) #QueueID = -1 when default commands are used if controlID == 603: if kodiutils.dialogyesno(__language__(30011), __language__(30014)) == True: self.WS.SendMOTRCommand( "QUEUEMANAGEMENT", "-1;remove-all" ) #QueueID = -1 when default commands are used
def next_song(headers): next_url = 'https://api.shiriapp.org.il/api/session/next-song' song = requests.post( next_url, headers=headers, verify=kodiutils.get_setting_as_bool('verify_https')).json() file = song['file_url'] title = song['title'] if title: title = title.encode('utf8') try: artist = song['artist']['pretty_name'].encode('utf8') except TypeError: artist = '' try: album = song['album']['pretty_name'].encode('utf8') except TypeError: album = '' duration = song['file_duration'] listitem = xbmcgui.ListItem(title) listitem.setInfo( 'music', { 'title': title, 'artist': artist, 'album': album, 'mediatype': 'song', 'duration': duration }) listitem.setPath(file) return listitem
def parental_control_is_active(): now = datetime.datetime.now() hour_start = get_setting_as_int('parental.control.start') hour_now = now.hour hour_end = get_setting_as_int('parental.control.end') return get_setting_as_bool( 'parental.control.enabled') and hour_start <= hour_now <= hour_end
def get_item_listing_text(event_name, starttime, duration, status, network, blackout, auth_types, requires_package=False, sport=None, sport2=None): if sport != sport2 and len(sport2) > 0: sport += ' (' + sport2 + ')' length = duration if len(network) > 0: ename = '[B]%s[/B]' % event_name else: ename = event_name if starttime is not None: now = time.time() etime = time.strftime("%I:%M %p", starttime) if status == 'replay': etime_local = starttime if etime_local.tm_hour == 0 and etime_local.tm_min == 0: etime = time.strftime("%m/%d/%Y", starttime) else: etime = time.strftime("%m/%d %I:%M %p", starttime) ename = etime + ' - ' + ename elif status == 'live': starttime_time = time.mktime(starttime) length -= (time.time() - starttime_time) ename = ename + ' - ' + etime else: now_time = time.localtime(now) if now_time.tm_year == starttime.tm_year and \ now_time.tm_mon == starttime.tm_mon and \ now_time.tm_mday == starttime.tm_mday: etime = time.strftime("%I:%M %p", starttime) else: etime = time.strftime("%m/%d %I:%M %p", starttime) ename = etime + ' - ' + ename blackout_text = '' if blackout: blackout_text = get_string(30580) if len(blackout_text) > 0: ename = blackout_text + ' ' + ename if len(network) > 0: if get_setting_as_bool('NoColors'): ename = network + ' ' + ename else: # ename = '[B]%s[/B] %s' % (network, ename) ename = '%s %s' % (network, ename) requires_auth = check_auth_types(auth_types) if requires_auth and not adobe_activate_api.is_authenticated(): ename = get_string(40300) + ' - ' + ename if requires_package: ename = get_string(40310) + ' - ' + ename return ename, length
def run(): xbmc.log("plugin.video.tvhkAPI involved", 1) xbmc.log("sys.argv = " + str(sys.argv), 1) if not kodiutils.get_setting_as_bool("enter_all_videos"): plugin.run() else: plugin.redirect("/videos")
def index(): """Main menu""" if ku.get_setting_as_bool("show_themes"): add_menu_item(theme, 32004, {"token": 0}, ku.icon("themes.png")) if ku.get_setting_as_bool("show_years"): add_menu_item(year, 32005, {"token": 0}, ku.icon("year.png")) if ku.get_setting_as_bool("show_series"): add_menu_item(series, 32006, {"token": 0}, ku.icon("collection.png")) if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, {"menu": True}, ku.icon("search.png")) if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) xp.setPluginCategory(plugin.handle, ADDON_NAME) xp.endOfDirectory(plugin.handle)
def DownloadLink(self, sDirectory): sHost = kodiutils.get_setting('host') sPort = kodiutils.get_setting('port') bUseSSL = kodiutils.get_setting_as_bool('usessl') sWebConnect = 'http://' if bUseSSL == True: sWebConnect = 'https://' return sWebConnect + sHost + ":" + sPort + "/" + sDirectory + "/"
def index(): # type: () -> None """Main menu""" if ku.get_setting_as_bool("show_featured"): add_menu_item(featured, 32008, art=ku.icon("featured.png")) if ku.get_setting_as_bool("show_collection"): add_menu_item(section, 32002, art=ku.icon("collection.png")) if ku.get_setting_as_bool("show_shows"): add_menu_item(shows, 32003, art=ku.icon("shows.png")) if ku.get_setting_as_bool("show_new"): add_menu_item(new, 32006, art=ku.icon("new.png")) if ku.get_setting_as_bool("show_recent"): add_menu_item(recent, 32005, art=ku.icon("recent.png")) if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, args={"menu": True}, art=ku.icon("search.png")) if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) xbmcplugin.setPluginCategory(plugin.handle, ADDON_NAME) xbmcplugin.endOfDirectory(plugin.handle)
def _get_kids_mode(): if get_setting_as_bool('kids_zone_forced'): return True # kids will contain a string of 'True' or 'False' kids = plugin.args.get('kids') if kids: return True if kids[0] == 'True' else False return False
def index(): # type: () -> None """Main menu""" add_menu_item(section, "Collections", art=ku.icon("collection.png")) if ku.get_setting_as_bool("show_recent"): add_menu_item(recent, 32005, art=ku.icon("recent.png")) if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, args={"menu": True}, art=ku.icon("search.png")) if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) xbmcplugin.setPluginCategory(plugin.handle, ADDON_NAME) xbmcplugin.endOfDirectory(plugin.handle)
def run(self): debug( 'START SERVICE....................................................................' ) last_changelog = get_setting('system.changelog') update_addon() if last_changelog != ADDON.getAddonInfo('version'): debug('SYSTEM.CHANGELOG: {}'.format( ADDON.getAddonInfo('changelog'))) set_setting('system.changelog', '{}'.format(ADDON.getAddonInfo('version'))) dtextviewer('', ADDON.getAddonInfo('changelog')) if get_setting_as_bool('system.autoexec'): try: exec_build_in( 'ActivateWindow(videos,plugin://{})'.format(ADDON_ID)) except: pass if get_setting('kraska.user'): kra = Kraska() kra.check_user() if get_setting_as_bool('system.ws.remote.enable'): ws = websocket.WS() ws.reconnect() self.next_ep = NextEp() clean_textures() from threading import Thread w = Thread(target=player.run) w.start() while not monitor.abortRequested(): try: self.periodical_check() except: debug('error: {}'.format(traceback.format_exc())) pass sleep(1000 * 5)
def audio_score(self, lang1, pos, score, stream_info, weight=3): if get_setting_as_bool('stream.adv') and 'streams' in stream_info: force_lang = preferred_lang_list.get(self.data.get('id')) ascore = {apos: 0 for apos, _ in enumerate(stream_info['streams'])} for apos, _ in enumerate(stream_info['streams']): acodec, channels, lang = _ lang = lang.lower() if force_lang is not None and force_lang.lower() == lang: ascore[apos] += 1000 debug('FORCE lang: {}'.format(force_lang.lower())) debug(' - lang {}/{}'.format(lang, lang1)) if acodec in get_setting('stream.adv.whitelist.codec'): debug(' - audio whitelist acodec {}'.format(acodec)) ascore[apos] += 1 if acodec in get_setting('stream.adv.blacklist.codec'): debug(' - audio blacklist acodec {}'.format(acodec)) ascore[apos] -= 10 if lang == lang1: if get_setting_as_bool('stream.adv.audio.channels'): weight = weight + ( channels - 3) if 3 > channels > weight else weight debug(' - audio adv prefered lang {} => {}'.format( lang1, weight)) ascore[apos] += weight ascore = { k: v for k, v in sorted( ascore.items(), key=lambda item: item[1], reverse=True) } sel = list(ascore.keys())[0] score[pos] += ascore[sel] debug('audio score: {} -> {} / {}'.format(ascore, sel, score[pos])) else: score[pos] += weight debug('audio basic prefered lang {} => {} / {}'.format( lang1, weight, score[pos])) return score
def make_list_item(label, icon=None, info_labels=None): if get_setting_as_bool('NoColors'): label = re.sub(r'\[COLOR=\w{8}\]', '', label) label = re.sub(r'\[/COLOR\]', '', label) listitem = ListItem(label, iconImage=icon) listitem.setInfo('video', infoLabels=info_labels) listitem.setProperty('IsPlayable', 'true') listitem.setArt({ 'icon': icon }) return listitem
def index(): """Main menu""" if ku.get_setting_as_bool("show_highlights"): add_menu_item(highlights, ku.get_string(32006), art=ku.icon("highlights.png")) if ku.get_setting_as_bool("show_genres"): add_menu_item(browse, ku.get_string(32005), {"id": "genre_items", "title": ku.get_string(32005)}, ku.icon("genres.png")) if ku.get_setting_as_bool("show_subjects"): add_menu_item(browse, ku.get_string(32003), {"id": "subject_items", "title": ku.get_string(32003)}, ku.icon("subjects.png")) if ku.get_setting_as_bool("show_people"): add_menu_item(browse, ku.get_string(32004), {"id": "people_items", "title": ku.get_string(32004)}, ku.icon("people.png")) if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, {"menu": True}, ku.icon("search.png")) if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) xp.setPluginCategory(plugin.handle, ADDON_NAME) xp.endOfDirectory(plugin.handle)
def system_after(self): data = self.response.get(SC.ITEM_SYSTEM, {}) if 'setContent' in data: # and settings.get_setting_bool('gui.views.enabled'): xbmcplugin.setContent(params.handle, data['setContent']) # view_mode = data["setContent"].lower() # view_code = settings.get_setting_int('gui.views.{0}'.format(view_mode)) # if view_code > 0: # xbmc.executebuiltin("Container.SetViewMode(%d)" % view_code) if 'SetSortMethod' in data: #method = SORT_METHODS[int(data.get('SetSortMethod'))] #xbmc.executebuiltin('Container.SetSortMethod(%d)' % method) pass if SC.ITEM_FOCUS in data: try: control = cur_win.getControl(cur_win.getFocusId()) control.selectItem(int(data[SC.ITEM_FOCUS])) except: pass check_last_key = '{}.last_series'.format(ADDON_ID) if 'checkLast' in data and get_setting_as_bool( 'stream.autoplay.episode'): check_last = data['checkLast'] stop = home_win.getProperty('{}.stop'.format(ADDON_ID)) debug('Mame check last data: {} / {}'.format(stop, check_last)) item_id = int(check_last.get('id', 0)) ki = SCKODIItem(int(item_id)) last_ep = ki.get_last_ep() if item_id > 0 and last_ep: win_last_series = home_win.getProperty(check_last_key) home_win.setProperty(check_last_key, str(item_id)) debug('last {} cur {}'.format(win_last_series, item_id)) if win_last_series == '' or win_last_series != str(item_id): debug('last ep: {}'.format(last_ep)) try: data = Sc.up_next(item_id, last_ep[0], last_ep[1]) d = SCUpNext(data) debug('NEXT EP: {}'.format(d.get().get('play_info'))) cmd = 'PlayMedia({})'.format( create_plugin_url(d.get().get('play_info'))) if stop is None or stop == '': debug('play: {}'.format(cmd)) exec_build_in(cmd) except: debug('chyba: {}'.format(traceback.format_exc())) pass else: home_win.clearProperty(check_last_key) # upraceme po sebe home_win.clearProperty('{}.stop'.format(ADDON_ID))
def search(): # type: () -> Union[bool, None] query = get_arg("q") offset = int(get_arg("offset", 1)) period = get_arg("period", "") sound = "Sound" if ku.get_setting_as_bool("search_sound") else "" colour = "Colour" if ku.get_setting_as_bool("search_colour") else "" # remove saved search item if bool(get_arg("delete", False)): iwm.remove(query) xbmc.executebuiltin("Container.Refresh()") return True # View saved search menu if bool(get_arg("menu", False)): add_menu_item(search, "[{}]".format(ku.localize(32016)), {"new": True}) # [New Search] for item in iwm.retrieve(): text = item.encode("utf-8") add_menu_item(search, text, {"q": text}) xbmcplugin.setPluginCategory(plugin.handle, ku.localize(32007)) # Search xbmcplugin.endOfDirectory(plugin.handle) return True # look-up if bool(get_arg("new", False)): query = ku.user_input() iwm.append(query) if not query: return False payload = iwm.IWM_SEARCH_PAYLOAD.copy() payload["keyword"] = query payload["page"] = offset payload["filter"] = 'Content_Date_Period,"{}",colourSorter,"{}",soundSorter,"{}",mediaType,"Video"'.format(period, colour, sound) title = period if period else query data = iwm.post_json(payload) xbmcplugin.setPluginCategory(plugin.handle, "{} '{}'".format(ku.localize(32007), title)) # Search 'query' parse_search_results(query, offset, data)
def loop(): monitor = xbmc.Monitor() while not monitor.abortRequested(): # Sleep/wait for abort for 10 seconds if kodiutils.get_setting_as_bool("debug"): kodiutils.notification(kodiutils.get_string(30032), "Debug :: Timer set to %d" % kodiutils.get_setting_as_int("timer"), time=5000, icon=ADDON.getAddonInfo('icon'), sound=True) if monitor.waitForAbort(kodiutils.get_setting_as_int("timer")): # Abort was requested while waiting. We should exit break logger.debug("Edem.tv.parser is launched parse function at %s" % time.time()) parse()
def emit(self, record): levels = { logging.CRITICAL: xbmc.LOGFATAL, logging.ERROR: xbmc.LOGERROR, logging.WARNING: xbmc.LOGWARNING, logging.INFO: xbmc.LOGINFO, logging.DEBUG: xbmc.LOGDEBUG, logging.NOTSET: xbmc.LOGNONE, } if get_setting_as_bool('debug'): try: xbmc.log(self.format(record), levels[record.levelno]) except UnicodeEncodeError: xbmc.log(self.format(record).encode( 'utf-8', 'ignore'), levels[record.levelno])
def onInit(self): log("Window onInit method called from Kodi") self.getControl(11).setVisible(False) #If we are connected, then this is probably a second time init, called after playback is finished if self.WS.isSocketConnected() == True: return self.GUIOnConnection(False) xbmcgui.Window(xbmcgui.getCurrentWindowId()).setFocusId( 9100) #Connect selected if kodiutils.get_setting_as_bool('autoconnect') == True: self.onClick(9100)
def default_params(query): params = { 'ver': API_VERSION, 'uid': get_uuid(), 'skin': get_skin_name(), 'lang': SYSTEM_LANG_CODE, } # plugin_url = 'plugin://{}/{}'.format(ADDON_ID, query.params.orig_args if query.params.orig_args else '') # try: # kv = KodiViewModeDb() # sort = kv.get_sort(plugin_url) # except: # sort = (0, 1) # try: # if sort is not None: # params.update({'sm': '{},{}'.format(sort[0], sort[1])}) # except: # debug('ERR API SORT: {}'.format(traceback.format_exc())) # pass parental_control = Sc.parental_control_is_active() if get_setting_as_bool('stream.dubed') or ( parental_control and get_setting_as_bool('parental.control.dubed')): params.update({'dub': 1}) if not parental_control and get_setting_as_bool('stream.dubed.titles'): params.update({'dub': 1, "tit": 1}) if parental_control: params.update({ "m": Sc.RATING_MAP.get(get_setting('parental.control.rating')) }) if get_setting_as_bool('plugin.show.genre'): params.update({'gen': 1}) if 'HDR' not in query: params.update( {'HDR': 0 if get_setting_as_bool('stream.exclude.hdr') else 1}) if 'DV' not in query: params.update({ 'DV': 0 if get_setting_as_bool('stream.exclude.dolbyvision') else 1 }) if get_setting_as_bool('plugin.show.old.menu'): params.update({'old': 1}) return params
def downloads(): if kodiutils.get_setting_as_bool("folder") and kodiutils.get_setting("downloadPath") and xbmcvfs.exists(kodiutils.get_setting("downloadPath")): dirs, files = xbmcvfs.listdir(kodiutils.get_setting("downloadPath")) if files: items = [] for file_ in files: cm = [] liz = ListItem(file_.split(".")[0]) liz.setPath(os.path.join(kodiutils.get_setting("downloadPath"),file_)) liz.setProperty('IsPlayable', 'true') cm.append((kodiutils.get_string(32055), 'XBMC.RunPlugin(plugin://%s/delete_file/%s)' % (ADDON.getAddonInfo("id"),urllib.quote(os.path.join(kodiutils.get_setting("downloadPath"),file_), safe='')) )) liz.addContextMenuItems(cm, replaceItems=False) items.append((liz.getPath(), liz, False)) if items: addDirectoryItems(plugin.handle, items, totalItems=len(items)) endOfDirectory(plugin.handle)
def index(): """Main menu""" if ku.get_setting_as_bool("show_home"): add_menu_item(show_category, 32009, { "href": "free", "title": ku.get_string(32009) }, ku.icon("home.png")) if ku.get_setting_as_bool("show_new"): add_menu_item(show_category, 32004, { "href": "free/new", "title": ku.get_string(32004) }, ku.icon("new.png")) if ku.get_setting_as_bool("show_popular"): add_menu_item(show_category, 32005, { "href": "free/popular", "title": ku.get_string(32005) }, ku.icon("popular.png")) if ku.get_setting_as_bool("show_collections"): add_menu_item( show_category, 32006, { "key": "collection", "href": "free/collections", "title": ku.get_string(32006), "isdir": True }, ku.icon("collection.png")) if ku.get_setting_as_bool("show_the_cut"): add_menu_item(show_category, "The Cut", { "key": "the-cut", "href": "the-cut", "title": "The Cut", }, ku.icon("the-cut.png")) if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, {"menu": True}, ku.icon("search.png")) if ku.get_setting_as_bool("show_recent"): add_menu_item(recent, 32021) if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) xp.setPluginCategory(plugin.handle, ADDON_NAME) xp.endOfDirectory(plugin.handle)
def add_directories(id, page = "1", recursive=False, prefix=""): dir = get_url(ids.collections_request_url.format(id=id, page=page), critical=True) dir_json = json.loads(dir) for item in dir_json["results"]: setContent(plugin.handle, 'tvshows') images = json.loads(item["images_json"]) if item["type"] == "Category": name = item["name"] if "top_level_category" in item: if item["top_level_category"]["name"].lower() == item["name"].lower(): name = item["promotion_name"] listitem = ListItem(name) listitem.setArt({'icon': images["image_base"],'thumb': images["image_base"], 'poster': images["image_base"]}) if "image_show_big" in images: listitem.setArt({"fanart" : images["image_show_big"]}) plot = "" if 'description' in item and item['description'] != None: try: startDATES = datetime(*(time.strptime(item['description'].split(', ')[1], '%d.%m.%y')[0:6])) # Do, 04.07.19 locale.setlocale(locale.LC_ALL, '') lastTIMES = startDATES.strftime('%A - %d.%m.%Y') plot = kodiutils.get_string(32006).format(str(lastTIMES)) except: pass listitem.setInfo(type='Video', infoLabels={'Title': name, 'Plot': plot}) addDirectoryItem(plugin.handle, url=plugin.url_for(get_by_category, item["id"]), listitem=listitem, isFolder=True) elif item["type"] == "Collection": if item["ui_tag"] == "": add_directories(item["id"], prefix=item["title"]+" ") elif recursive: add_directories(item["id"]) else: icon = "" if "image_base" in images: icon = images["image_base"] addDirectoryItem(plugin.handle, url=plugin.url_for(get_by_collection, item["id"], "1"), listitem=ListItem(prefix+item["title"], iconImage=icon, thumbnailImage=icon), isFolder=True) if int(dir_json["pagination"]["page"]) * int(dir_json["pagination"]["items_per_page"]) < int(dir_json["pagination"]["total_items"]): if kodiutils.get_setting_as_bool("limitlist"): addDirectoryItem(plugin.handle, url=plugin.url_for(get_by_collection, id, str(int(page)+1)), listitem=ListItem(kodiutils.get_string(32007).format(str(int(page)+1))), isFolder=True) else: get_by_collection(id, str(int(page)+1))
def __init__(self, force=False): debug("TRAKT Initializing.") Trakt.configuration.defaults.client(id=self.__client_id, secret=self.__client_secret) Trakt.on('oauth.token_refreshed', self.on_token_refreshed) Trakt.configuration.defaults.oauth(refresh=True) Trakt.configuration.defaults.http(retry=True, timeout=90) from resources.lib.services.Monitor import monitor self.monitor = monitor if not get_setting_as_bool('trakt.enabled'): debug('Trak nieje zapnuty') return self.initialize(force=force)
def index(): # type: () -> None """Main menu""" if ku.get_setting_as_bool("show_featured"): add_menu_item( section, 32002, { "token": "featuredFilmCollection_facet", "category": ku.localize(32002) }, ku.icon("featured.png")) if ku.get_setting_as_bool("show_place"): add_menu_item(section, 32009, { "token": "place_facet", "category": ku.localize(32009) }, ku.icon("place.png")) if ku.get_setting_as_bool("show_series"): add_menu_item(section, 32021, { "token": "series_facet", "category": ku.localize(32021) }, ku.icon("series.png")) if ku.get_setting_as_bool("show_genre"): add_menu_item(section, 32004, { "token": "genre_facet", "category": ku.localize(32004) }, ku.icon("genre.png")) if ku.get_setting_as_bool("show_years"): add_menu_item(section, 32006, { "token": "decade_facet", "category": ku.localize(32006) }, ku.icon("year.png")) if ku.get_setting_as_bool("show_recent"): add_menu_item(recent, 32005, art=ku.icon("recent.png")) if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, {"menu": True}, ku.icon("search.png")) if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) xbmcplugin.setPluginCategory(plugin.handle, ADDON_NAME) xbmcplugin.endOfDirectory(plugin.handle)
def run(): uuid = get_uuid() headers = {'Content-Type': 'application/json', 'X-UUID': uuid} # Set artists payload = {'ids': [10, 11, 12, 13, 14]} artists_url = 'https://api.shiriapp.org.il/api/session/current-artist/set-all' requests.post(artists_url, headers=headers, data=json.dumps(payload), verify=kodiutils.get_setting_as_bool('verify_https')) playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC) playlist.clear() for i in range(10): listitem = next_song(headers) playlist.add(listitem.getPath(), listitem, i + 1) xbmc.Player().play(playlist)
def index(): # type: () -> None """Main menu""" if ku.get_setting_as_bool("show_contributor"): add_menu_item(section, 32002, { "idx": "index/contributor/", "category": ku.localize(32002) }, ku.icon("contributor.png")) if ku.get_setting_as_bool("show_location"): add_menu_item(section, 32009, { "idx": "index/location/", "category": ku.localize(32009) }, ku.icon("location.png")) if ku.get_setting_as_bool("show_partof"): add_menu_item(section, 32021, { "idx": "index/partof/", "category": ku.localize(32021) }, ku.icon("series.png")) if ku.get_setting_as_bool("show_subject"): add_menu_item(section, 32004, { "idx": "index/subject/", "category": ku.localize(32004) }, ku.icon("genre.png")) if ku.get_setting_as_bool("show_years"): add_menu_item(year, 32006, art=ku.icon("year.png")) if ku.get_setting_as_bool("show_recent"): add_menu_item(recent, 32005, art=ku.icon("recent.png")) if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, {"menu": True}, ku.icon("search.png")) if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) xbmcplugin.setPluginCategory(plugin.handle, ADDON_NAME) xbmcplugin.endOfDirectory(plugin.handle)
def index(): # type: () -> None """Main menu""" if ku.get_setting_as_bool("show_live"): add_menu_item(live, 32006, art=ku.icon("livetv.png")) if ku.get_setting_as_bool("show_programmes"): add_menu_item(programme, 32009, art=ku.icon("programme.png")) if ku.get_setting_as_bool("show_topics"): add_menu_item(topic, 32008, art=ku.icon("topic.png")) if ku.get_setting_as_bool("show_past24h"): add_menu_item(past24h, 32004, art=ku.icon("past24h.png")) if ku.get_setting_as_bool("show_recent"): add_menu_item(recent, 32005, art=ku.icon("recent.png")) if ku.get_setting_as_bool("show_search"): add_menu_item(search, 32007, {"menu": True}, ku.icon("search.png")) if ku.get_setting_as_bool("show_settings"): add_menu_item(settings, 32010, art=ku.icon("settings.png"), directory=False) xbmcplugin.setPluginCategory(plugin.handle, ADDON_NAME) xbmcplugin.endOfDirectory(plugin.handle)
def run(): if not kodiutils.get_setting_as_bool("enter_all_videos"): plugin.run() else: plugin.redirect("/videos")