Python xbmc.getLocalizedString() Examples

The following are 30 code examples of xbmc.getLocalizedString(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module xbmc , or try the search function .
Example #1
Source File: plugin_content.py    From plugin.audio.spotify with GNU General Public License v3.0 6 votes vote down vote up
def search_artists(self):
        xbmcplugin.setContent(self.addon_handle, "artists")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(133))
        result = self.sp.search(
            q="artist:%s" %
            self.artistid,
            type='artist',
            limit=self.limit,
            offset=self.offset,
            market=self.usercountry)
        artists = self.prepare_artist_listitems(result['artists']['items'])
        self.add_artist_listitems(artists)
        self.add_next_button(result['artists']['total'])
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_artists:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_artists) 
Example #2
Source File: main_service.py    From script.skin.helper.service with GNU General Public License v2.0 6 votes vote down vote up
def check_skin_version(self):
        '''check if skin changed'''
        try:
            skin = xbmc.getSkinDir()
            skin_addon = xbmcaddon.Addon(id=skin)
            skin_label = skin_addon.getAddonInfo('name').decode("utf-8")
            skin_version = skin_addon.getAddonInfo('version').decode("utf-8")
            this_skin = "%s-%s" % (skin_label, skin_version)
            del skin_addon
            if self.last_skin != this_skin:
                # auto correct skin settings if needed
                self.last_skin = this_skin
                self.win.setProperty("SkinHelper.skinTitle", "%s - %s: %s"
                                     % (skin_label, xbmc.getLocalizedString(19114), skin_version))
                self.win.setProperty("SkinHelper.skin_version", "%s: %s"
                                     % (xbmc.getLocalizedString(19114), skin_version))
                self.win.setProperty("SkinHelper.Version", self.addonversion.replace(".", ""))
                SkinSettings().correct_skin_settings()
        except Exception as exc:
            log_exception(__name__, exc) 
Example #3
Source File: plugin_content.py    From plugin.audio.spotify with GNU General Public License v3.0 6 votes vote down vote up
def get_authkey(self):
        '''get authentication key'''
        auth_token = None
        count = 10
        while not auth_token and count: # wait max 5 seconds for the token
            auth_token = self.win.getProperty("spotify-token").decode("utf-8")
            count -= 1
            if not auth_token:
                xbmc.sleep(500)
        if not auth_token:
            if self.win.getProperty("spotify.supportsplayback"):
                if self.win.getProperty("spotify-discovery") == "disabled":
                    msg = self.addon.getLocalizedString(11050)
                else:
                    msg = self.addon.getLocalizedString(11065)
                dialog = xbmcgui.Dialog()
                header = self.addon.getAddonInfo("name")
                dialog.ok(header, msg)
                del dialog
            else:
                # login with browser
                request_token_web(force=True)
                self.win.setProperty("spotify-cmd", "__LOGOUT__")
        return auth_token 
Example #4
Source File: xbmc_context.py    From plugin.video.youtube with GNU General Public License v2.0 6 votes vote down vote up
def localize(self, text_id, default_text=u''):
        if isinstance(text_id, int):
            """
            We want to use all localization strings!
            Addons should only use the range 30000 thru 30999 (see: http://kodi.wiki/view/Language_support) but we
            do it anyway. I want some of the localized strings for the views of a skin.
            """
            if text_id >= 0 and (text_id < 30000 or text_id > 30999):
                result = xbmc.getLocalizedString(text_id)
                if result is not None and result:
                    return utils.to_unicode(result)
                pass
            pass

        result = self._addon.getLocalizedString(int(text_id))
        if result is not None and result:
            return utils.to_unicode(result)

        return utils.to_unicode(default_text) 
Example #5
Source File: resourceaddons.py    From script.skin.helper.service with GNU General Public License v2.0 6 votes vote down vote up
def checkresourceaddons(addonslist):
    '''allow the skinner to perform a basic check if some required resource addons are available'''
    addon = xbmcaddon.Addon(ADDON_ID)
    for item in addonslist:
        setting = item.split(";")[0]
        addontype = item.split(";")[1]
        addontypelabel = item.split(";")[2]
        skinsetting = xbmc.getInfoLabel("Skin.String(%s.path)" % setting).decode("utf-8")
        if not skinsetting or (skinsetting and
                               getCondVisibility("!System.HasAddon(%s)" %
                                                      skinsetting.replace("resource://", "").replace("/", ""))):
            # skin setting is empty or filled with non existing addon...
            if not checkresourceaddon(setting, addontype):
                ret = xbmcgui.Dialog().yesno(
                    heading=addon.getLocalizedString(32007) % addontypelabel,
                    line1=addon.getLocalizedString(32008) % addontypelabel)
                xbmc.executebuiltin("Skin.Reset(%s.path)" % setting)
                if ret:
                    downloadresourceaddons(addontype)
                    checkresourceaddon(setting, addontype)
    del addon 
Example #6
Source File: episodes.py    From script.skin.helper.widgets with GNU General Public License v2.0 6 votes vote down vote up
def listing(self):
        '''main listing with all our episode nodes'''
        all_items = [
            (self.addon.getLocalizedString(32027), "inprogress&mediatype=episodes", "DefaultTvShows.png"),
            (self.addon.getLocalizedString(32002), "next&mediatype=episodes", "DefaultTvShows.png"),
            (self.addon.getLocalizedString(32039), "recent&mediatype=episodes", "DefaultRecentlyAddedEpisodes.png"),
            (self.addon.getLocalizedString(32009), "recommended&mediatype=episodes", "DefaultTvShows.png"),
            (self.addon.getLocalizedString(32010), "inprogressandrecommended&mediatype=episodes", "DefaultTvShows.png"),
            (self.addon.getLocalizedString(32049), "inprogressandrandom&mediatype=episodes", "DefaultTvShows.png"),
            (self.addon.getLocalizedString(32008), "random&mediatype=episodes", "DefaultTvShows.png"),
            (self.addon.getLocalizedString(32042), "unaired&mediatype=episodes", "DefaultTvShows.png"),
            (self.addon.getLocalizedString(32043), "nextaired&mediatype=episodes", "DefaultTvShows.png"),
            (self.addon.getLocalizedString(32068), "airingtoday&mediatype=episodes", "DefaultTvShows.png"),
            (xbmc.getLocalizedString(10134), "favourites&mediatype=episodes", "DefaultMovies.png")
        ]
        return self.metadatautils.process_method_on_list(create_main_entry, all_items) 
Example #7
Source File: plugin_content.py    From plugin.audio.spotify with GNU General Public License v3.0 6 votes vote down vote up
def search_albums(self):
        xbmcplugin.setContent(self.addon_handle, "albums")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(132))
        result = self.sp.search(
            q="album:%s" %
            self.albumid,
            type='album',
            limit=self.limit,
            offset=self.offset,
            market=self.usercountry)
        albumids = []
        for album in result['albums']['items']:
            albumids.append(album["id"])
        albums = self.prepare_album_listitems(albumids)
        self.add_album_listitems(albums, True)
        self.add_next_button(result['albums']['total'])
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_albums:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_albums) 
Example #8
Source File: plugin_content.py    From plugin.audio.spotify with GNU General Public License v3.0 6 votes vote down vote up
def search_playlists(self):
        xbmcplugin.setContent(self.addon_handle, "files")
        result = self.sp.search(
            q=self.playlistid,
            type='playlist',
            limit=self.limit,
            offset=self.offset,
            market=self.usercountry)
        log_msg(result)
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(136))
        playlists = self.prepare_playlist_listitems(result['playlists']['items'])
        self.add_playlist_listitems(playlists)
        self.add_next_button(result['playlists']['total'])
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_playlists:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_playlists) 
Example #9
Source File: plugin_content.py    From plugin.audio.spotify with GNU General Public License v3.0 6 votes vote down vote up
def add_next_button(self, listtotal):
        # adds a next button if needed
        params = self.params
        if listtotal > self.offset + self.limit:
            params["offset"] = self.offset + self.limit
            url = "plugin://plugin.audio.spotify/"
            for key, value in params.iteritems():
                if key == "action":
                    url += "?%s=%s" % (key, value[0])
                elif key == "offset":
                    url += "&%s=%s" % (key, value)
                else:
                    url += "&%s=%s" % (key, value[0])
            li = xbmcgui.ListItem(
                xbmc.getLocalizedString(33078),
                path=url,
                iconImage="DefaultMusicAlbums.png"
            )
            li.setProperty('do_not_analyze', 'true')
            li.setProperty('IsPlayable', 'false')
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=url, listitem=li, isFolder=True) 
Example #10
Source File: traktapi.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, force=False, cache_short=None, cache_long=None, tmdb=None, login=False):
        super(TraktAPI, self).__init__(
            cache_short=cache_short, cache_long=cache_long,
            req_api_url='https://api.trakt.tv/', req_api_name='Trakt')
        self.authorization = ''
        self.sync = {}
        self.last_activities = None
        self.prev_activities = None
        self.refreshcheck = 0
        self.attempedlogin = False
        self.dialog_noapikey_header = u'{0} {1} {2}'.format(self.addon.getLocalizedString(32007), self.req_api_name, self.addon.getLocalizedString(32011))
        self.dialog_noapikey_text = self.addon.getLocalizedString(32012)
        self.client_id = 'e6fde6173adf3c6af8fd1b0694b9b84d7c519cefc24482310e1de06c6abe5467'
        self.client_secret = '15119384341d9a61c751d8d515acbc0dd801001d4ebe85d3eef9885df80ee4d9'
        self.headers = {'trakt-api-version': '2', 'trakt-api-key': self.client_id, 'Content-Type': 'application/json'}
        self.tmdb = tmdb
        self.library = 'video'

        if force:
            self.login()
            return

        self.authorize(login) 
Example #11
Source File: traktapi.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 6 votes vote down vote up
def get_collection(self, tmdbtype, page=1, limit=20):
        items = []
        if not self.tmdb or not self.authorize():
            return items
        collection = self.sync_collection(utils.type_convert(tmdbtype, 'trakt'))
        collection = sorted(collection, key=lambda i: i[utils.type_convert(tmdbtype, 'trakt')]['title'], reverse=False)
        start_at = limit * (page - 1)
        end_at = start_at + limit
        for i in collection[start_at:end_at]:
            i = i.get(utils.type_convert(tmdbtype, 'trakt'))
            i_tmdb = i.get('ids', {}).get('tmdb', '')
            item = ListItem(library=self.library, **self.tmdb.get_detailed_item(tmdbtype, i_tmdb))
            if item and item.label != 'N/A':
                items.append(item)
        if items and collection[end_at:]:  # If there's more items add the next page item
            items.append(ListItem(library=self.library, label=xbmc.getLocalizedString(33078), nextpage=page + 1))
        return items 
Example #12
Source File: context.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 6 votes vote down vote up
def refresh_item():
    dbtype = sys.listitem.getVideoInfoTag().getMediaType()
    if dbtype == 'episode':
        d_args = (
            'tv', sys.listitem.getProperty('tvshow.tmdb_id'),
            sys.listitem.getVideoInfoTag().getSeason(),
            sys.listitem.getVideoInfoTag().getEpisode())
    elif dbtype == 'tvshow':
        d_args = ('tv', sys.listitem.getProperty('tmdb_id'))
    elif dbtype == 'movie':
        d_args = ('movie', sys.listitem.getProperty('tmdb_id'))
    else:
        return
    details = _plugin.tmdb.get_detailed_item(*d_args, cache_refresh=True)
    if details:
        xbmcgui.Dialog().ok(_addon.getLocalizedString(32144), _addon.getLocalizedString(32143).format(details.get('label')))
    xbmc.executebuiltin('Container.Refresh') 
Example #13
Source File: container.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 6 votes vote down vote up
def set_userdiscover_selectlist_properties(self, data_list=None, header=None, multiselect=True):
        if not data_list:
            return
        header = header or self.addon.getLocalizedString(32111)
        func = xbmcgui.Dialog().multiselect if multiselect else xbmcgui.Dialog().select
        dialog_list = [i.get('name') for i in data_list]
        select_list = func(header, dialog_list)
        if not select_list:
            return
        if not multiselect:
            select_list = [select_list]
        for i in select_list:
            label = data_list[i].get('name')
            value = data_list[i].get('id')
            if not value:
                continue
            self.new_property_label = '{0} / {1}'.format(self.new_property_label, label) if self.new_property_label else label
            self.new_property_value = '{0} / {1}'.format(self.new_property_value, value) if self.new_property_value else '{}'.format(value) 
Example #14
Source File: player.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 6 votes vote down vote up
def build_selectbox(self, clearsetting=False, assertplayers=True):
        self.itemlist, self.actions = [], []
        if clearsetting:
            self.itemlist.append(xbmcgui.ListItem(xbmc.getLocalizedString(13403)))  # Clear Default
        if self.is_local:
            self.append_playeraction(u'{0} {1}'.format(self.addon.getLocalizedString(32061), 'Kodi'), self.is_local, identifier='play_kodi')
        for i in sorted(self.play_movie, key=lambda x: x[1]):
            self.build_playeraction(i[0], 'play_movie', assertplayers=assertplayers)
        for i in sorted(self.search_movie, key=lambda x: x[1]):
            self.build_playeraction(i[0], 'search_movie', assertplayers=assertplayers)
        for i in sorted(self.play_episode, key=lambda x: x[1]):
            self.build_playeraction(i[0], 'play_episode', assertplayers=assertplayers)
        for i in sorted(self.search_episode, key=lambda x: x[1]):
            self.build_playeraction(i[0], 'search_episode', assertplayers=assertplayers)
        utils.kodi_log(u'Player -- Built {} Players!\n{}'.format(
            len(self.itemlist), self.identifierlist), 2) 
Example #15
Source File: downloader.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 6 votes vote down vote up
def open_url(self, url, stream=False, check=False, cred=None, count=0):
        if not url:
            return False

        valid = self.check_url(url, cred)

        if not valid:
            return False
        if check:
            return True
        if valid == 'auth' and not cred:
            cred = (xbmcgui.Dialog().input(heading=xbmc.getLocalizedString(1014)) or '', xbmcgui.Dialog().input(heading=xbmc.getLocalizedString(733), option=xbmcgui.ALPHANUM_HIDE_INPUT) or '')

        response = requests.get(url, timeout=10.000, stream=stream, auth=cred)
        if response.status_code == 401:
            if count > 2 or not xbmcgui.Dialog().yesno(self.addon.getAddonInfo('name'), self.addon.getLocalizedString(32056), yeslabel=self.addon.getLocalizedString(32057), nolabel=xbmc.getLocalizedString(222)):
                xbmcgui.Dialog().ok(self.addon.getAddonInfo('name'), self.addon.getLocalizedString(32055))
                return False
            count += 1
            cred = (xbmcgui.Dialog().input(heading=xbmc.getLocalizedString(1014)) or '', xbmcgui.Dialog().input(heading=xbmc.getLocalizedString(733), option=xbmcgui.ALPHANUM_HIDE_INPUT) or '')
            response = self.open_url(url, stream, check, cred, count)
        return response 
Example #16
Source File: artists.py    From script.skin.helper.widgets with GNU General Public License v2.0 5 votes vote down vote up
def listing(self):
        '''main listing with all our artist nodes'''
        all_items = [
            (self.addon.getLocalizedString(32063), "recent&mediatype=artists", "DefaultMusicArtists.png"),
            (self.addon.getLocalizedString(32065), "recommended&mediatype=artists", "DefaultMusicArtists.png"),
            (self.addon.getLocalizedString(32064), "random&mediatype=artists", "DefaultMusicArtists.png"),
            (xbmc.getLocalizedString(10134), "favourites&mediatype=artists", "DefaultMusicArtists.png")
        ]
        return self.metadatautils.process_method_on_list(create_main_entry, all_items) 
Example #17
Source File: pvr.py    From script.skin.helper.widgets with GNU General Public License v2.0 5 votes vote down vote up
def process_channel(self, channeldata):
        '''transform the json received from kodi into something we can use'''
        item = {}
        channelname = channeldata["label"]
        channellogo = self.metadatautils.get_clean_image(channeldata['thumbnail'])
        if channeldata.get('broadcastnow'):
            # channel with epg data
            item = channeldata['broadcastnow']
            item["runtime"] = item["runtime"] * 60
            item["genre"] = u" / ".join(item["genre"])
            # del firstaired as it's value doesn't make any sense at all
            del item["firstaired"]
            # append artwork
            if self.enable_artwork:
                self.metadatautils.extend_dict(
                    item, self.metadatautils.get_pvr_artwork(
                        item["title"], channelname, item["genre"]))
        else:
            # channel without epg
            item = channeldata
            item["title"] = xbmc.getLocalizedString(161)
        item["file"] = u"plugin://script.skin.helper.service?action=playchannel&channelid=%s"\
            % (channeldata["channelid"])
        item["channel"] = channelname
        item["type"] = "channel"
        item["label"] = channelname
        item["channelid"] = channeldata["channelid"]
        if not channellogo:
            channellogo = self.metadatautils.get_channellogo(channelname)
        if channellogo:
            item["art"] = {"thumb": channellogo}
        item["channellogo"] = channellogo
        item["isFolder"] = False
        return item 
Example #18
Source File: pvr.py    From script.skin.helper.widgets with GNU General Public License v2.0 5 votes vote down vote up
def listing(self):
        '''main listing with all our channel nodes'''

        # add generic pvr entries
        all_items = [
            (self.addon.getLocalizedString(32069),
             "lastchannels&mediatype=pvr&reload=$INFO[Window(Home).Property(widgetreload2)]",
             "DefaultAddonPVRClient.png"),
            (self.addon.getLocalizedString(32018),
             "recordings&mediatype=pvr&reload=$INFO[Window(Home).Property(widgetreload2)]",
             "DefaultAddonPVRClient.png"),
            (self.addon.getLocalizedString(32019),
             "nextrecordings&mediatype=pvr&reload=$INFO[Window(Home).Property(widgetreload2)]",
             "DefaultAddonPVRClient.png"),
            (self.addon.getLocalizedString(32031),
             "nextrecordings&mediatype=pvr&reversed=true&reload=$INFO[Window(Home).Property(widgetreload2)]",
             "DefaultAddonPVRClient.png"),
            (self.addon.getLocalizedString(32021),
             "timers&mediatype=pvr&reload=$INFO[Window(Home).Property(widgetreload2)]",
             "DefaultAddonPVRClient.png")]

        # get all channel groups and create a tv channels entry for each groups
        for item in self.metadatautils.kodidb.channelgroups():
            label = "%s: %s" % (self.addon.getLocalizedString(32020), item["label"])
            widgetpath = "channels&mediatype=pvr&reload=$INFO[Window(Home).Property(widgetreload2)]"
            widgetpath += "&channelgroup=%s" % (item["channelgroupid"])
            all_items.append((label, widgetpath, "DefaultAddonPVRClient.png"))

        return self.metadatautils.process_method_on_list(create_main_entry, all_items) 
Example #19
Source File: pykodi.py    From script.artwork.beef with MIT License 5 votes vote down vote up
def localize(messageid):
    if isinstance(messageid, basestring):
        result = messageid
    elif messageid >= 32000 and messageid < 33000:
        result = get_main_addon().getLocalizedString(messageid)
    else:
        result = xbmc.getLocalizedString(messageid)
    return result.encode('utf-8') if isinstance(result, unicode) else result 
Example #20
Source File: main_module.py    From script.skin.helper.service with GNU General Public License v2.0 5 votes vote down vote up
def overlaytexture(self):
        '''legacy: helper to let the user choose a background overlay from a skin defined folder'''
        skinstring = self.params.get("skinstring", "BackgroundOverlayTexture")
        self.params["skinstring"] = skinstring
        self.params["resourceaddon"] = "resource.images.backgroundoverlays"
        self.params["customfolder"] = "special://skin/extras/bgoverlays/"
        self.params["allowmulti"] = "false"
        self.params["header"] = self.addon.getLocalizedString(32002)
        self.selectimage() 
Example #21
Source File: container.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 5 votes vote down vote up
def list_search(self):
        self.updatelisting = True if self.params.pop('updatelisting', False) else False
        org_query = self.params.get('query')
        if not self.params.get('query'):
            self.params['query'] = self.set_searchhistory(
                query=utils.try_decode_string(xbmcgui.Dialog().input(self.addon.getLocalizedString(32044), type=xbmcgui.INPUT_ALPHANUM)),
                itemtype=self.params.get('type'))
        elif self.params.get('history', '').lower() == 'true':  # Param to force history save
            self.set_searchhistory(query=self.params.get('query'), itemtype=self.params.get('type'))
        if self.params.get('query'):
            self.list_tmdb(query=self.params.get('query'), year=self.params.get('year'))
            if not org_query:
                self.params['updatelisting'] = 'True'
                container_url = u'plugin://plugin.video.themoviedb.helper/?{}'.format(utils.urlencode_params(self.params))
                xbmc.executebuiltin('Container.Update({})'.format(container_url)) 
Example #22
Source File: container.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 5 votes vote down vote up
def list_traktmanagement(self):
        if not self.params.get('trakt') in constants.TRAKT_MANAGEMENT:
            return
        with utils.busy_dialog():
            traktapi = TraktAPI()
            slug_type = 'show' if self.params.get('type') == 'episode' else utils.type_convert(self.params.get('type'), 'trakt')
            trakt_type = utils.type_convert(self.params.get('type'), 'trakt')
            slug = traktapi.get_traktslug(slug_type, 'tmdb', self.params.get('tmdb_id'))
            item = traktapi.get_details(slug_type, slug, season=self.params.get('season', None), episode=self.params.get('episode', None))
            items = {trakt_type + 's': [item]}
            if self.params.get('trakt') == 'watchlist_add':
                traktapi.sync_watchlist(slug_type, mode='add', items=items)
            if self.params.get('trakt') == 'history_add':
                traktapi.sync_history(slug_type, mode='add', items=items)
            if self.params.get('trakt') == 'collection_add':
                traktapi.sync_collection(slug_type, mode='add', items=items)
            if self.params.get('trakt') == 'watchlist_remove':
                traktapi.sync_watchlist(slug_type, mode='remove', items=items)
            if self.params.get('trakt') == 'history_remove':
                traktapi.sync_history(slug_type, mode='remove', items=items)
            if self.params.get('trakt') == 'collection_remove':
                traktapi.sync_collection(slug_type, mode='remove', items=items)
            # TODO: Check status response and add dialog
        dialog_action = self.params.get('trakt').replace('_add', '').replace('_remove', '')
        dialog_header = 'Trakt {0}'.format(dialog_action.capitalize())
        dialog_text = self.addon.getLocalizedString(32062) if '_add' in self.params.get('trakt') else self.addon.getLocalizedString(32063)
        dialog_text = dialog_text.format(self.params.get('tmdb_id'), dialog_action.capitalize())
        xbmcgui.Dialog().ok(dialog_header, dialog_text)
        self.updatelisting = True 
Example #23
Source File: container.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 5 votes vote down vote up
def set_userdiscover_genre_property(self):
        data_list = self.tmdb.get_request_lc('genre', self.params.get('type'), 'list')
        if not data_list:
            return
        data_list = data_list.get('genres', [])
        self.set_userdiscover_selectlist_properties(data_list, header=self.addon.getLocalizedString(32112)) 
Example #24
Source File: skinshortcuts.py    From script.skin.helper.service with GNU General Public License v2.0 5 votes vote down vote up
def playlists_widgets():
    '''skin provided playlists'''
    widgets = []
    import xml.etree.ElementTree as xmltree
    for playlist_path in ["special://skin/playlists/",
                          "special://skin/extras/widgetplaylists/", "special://skin/extras/playlists/"]:
        if xbmcvfs.exists(playlist_path):
            log_msg("skinshortcuts widgets processing: %s" % playlist_path)
            media_array = kodi_json('Files.GetDirectory', {"directory": playlist_path, "media": "files"})
            for item in media_array:
                if item["file"].endswith(".xsp"):
                    playlist = item["file"]
                    contents = xbmcvfs.File(item["file"], 'r')
                    contents_data = contents.read().decode('utf-8')
                    contents.close()
                    xmldata = xmltree.fromstring(contents_data.encode('utf-8'))
                    media_type = ""
                    label = item["label"]
                    for line in xmldata.getiterator():
                        if line.tag == "smartplaylist":
                            media_type = line.attrib['type']
                        if line.tag == "name":
                            label = line.text
                    try:
                        languageid = int(label)
                        label = xbmc.getLocalizedString(languageid)
                    except Exception:
                        pass
                    if not media_type:
                        mutils = MetadataUtils()
                        media_type = mutils.detect_plugin_content(playlist)
                        del mutils
                    widgets.append([label, playlist, media_type])
    return widgets 
Example #25
Source File: container.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 5 votes vote down vote up
def set_userdiscover_separator_property(self):
        choice = xbmcgui.Dialog().yesno(
            self.addon.getLocalizedString(32107),
            self.addon.getLocalizedString(32108),
            yeslabel=self.addon.getLocalizedString(32109), nolabel=self.addon.getLocalizedString(32110))
        self.new_property_value = 'OR' if choice else 'AND'
        self.new_property_label = 'ANY' if choice else 'ALL' 
Example #26
Source File: container.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 5 votes vote down vote up
def add_userdiscover_method_property(self, header, tmdbtype, usedetails, old_label=None, old_value=None):
        if old_label and old_value:
            if xbmcgui.Dialog().yesno(
                    u'{} {}'.format(tmdbtype.capitalize(), self.addon.getLocalizedString(32098)),
                    self.addon.getLocalizedString(32099) + ':', old_label,
                    self.addon.getLocalizedString(32100),
                    yeslabel=self.addon.getLocalizedString(32101), nolabel=self.addon.getLocalizedString(32102)):
                return
            self.new_property_label = old_label
            self.new_property_value = old_value

        new_label = utils.try_decode_string(xbmcgui.Dialog().input(header))
        if not new_label:
            return

        new_value = self.tmdb.get_tmdb_id(
            tmdbtype, query=new_label, selectdialog=True, longcache=True, usedetails=usedetails, returntuple=True)
        if not new_value:
            if xbmcgui.Dialog().yesno(self.addon.getLocalizedString(32103), self.addon.getLocalizedString(32104).format(new_label)):
                self.add_userdiscover_method_property(header, tmdbtype, usedetails)
            return

        new_value = (utils.try_encode_string(new_value[0]), new_value[1])
        self.new_property_label = '{0} / {1}'.format(self.new_property_label, new_value[0]) if self.new_property_label else new_value[0]
        self.new_property_value = '{0} / {1}'.format(self.new_property_value, new_value[1]) if self.new_property_value else '{}'.format(new_value[1])
        if xbmcgui.Dialog().yesno(u'{} {}'.format(self.addon.getLocalizedString(32106), new_value[0]), u'{}\n{}'.format(self.new_property_label, self.addon.getLocalizedString(32105))):
            self.add_userdiscover_method_property(header, tmdbtype, usedetails) 
Example #27
Source File: downloader.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 5 votes vote down vote up
def get_gzip_text(self):
        if not self.download_url:
            return

        with utils.busy_dialog():
            response = self.open_url(self.download_url)
        if not response:
            xbmcgui.Dialog().ok(self.addon.getAddonInfo('name'), self.addon.getLocalizedString(32058))
            return

        with gzip.GzipFile(fileobj=BytesIO(response.content)) as downloaded_gzip:
            content = downloaded_gzip.read()
        return content 
Example #28
Source File: skinshortcuts.py    From script.skin.helper.service with GNU General Public License v2.0 5 votes vote down vote up
def static_widgets():
    '''static widget nodes which are hardcoded in a skin'''
    widgets = []
    addon = xbmcaddon.Addon(ADDON_ID)
    widgets.append([xbmc.getLocalizedString(8), "$INCLUDE[WeatherWidget]", "static"])
    widgets.append([xbmc.getLocalizedString(130), "$INCLUDE[SystemInfoWidget]", "static"])
    widgets.append([addon.getLocalizedString(32025), "$INCLUDE[skinshortcuts-submenu]", "static"])
    if getCondVisibility("System.Hasaddon(script.games.rom.collection.browser)"):
        widgets.append([addon.getLocalizedString(32026), "$INCLUDE[RCBWidget]", "static"])
    del addon
    return widgets 
Example #29
Source File: downloader.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, download_url=None, extract_to=None):
        self.addon = xbmcaddon.Addon()
        self.download_url = download_url
        self.extract_to = xbmc.translatePath(extract_to)
        self.msg_cleardir = self.addon.getLocalizedString(32054) 
Example #30
Source File: ChineseKeyboard.py    From xbmc-addons-chinese with GNU General Public License v2.0 5 votes vote down vote up
def OnIPAddress(self):
        dialog = xbmcgui.Dialog()
        ip = dialog.numeric( 3, xbmc.getLocalizedString(14068), '' )
        self.strEdit += ip
        self.UpdateLabel()