当前位置: 首页>>代码示例>>Python>>正文


Python ADDON.getLocalizedString方法代码示例

本文整理汇总了Python中pulsar.addon.ADDON.getLocalizedString方法的典型用法代码示例。如果您正苦于以下问题:Python ADDON.getLocalizedString方法的具体用法?Python ADDON.getLocalizedString怎么用?Python ADDON.getLocalizedString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pulsar.addon.ADDON的用法示例。


在下文中一共展示了ADDON.getLocalizedString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GetLocalizedStrings

# 需要导入模块: from pulsar.addon import ADDON [as 别名]
# 或者: from pulsar.addon.ADDON import getLocalizedString [as 别名]
def GetLocalizedStrings(label):
    ids = re.compile('LOCALIZE\[(\d+)\]').findall(label)
    
    if ids:
        if label == 'LOCALIZE[%s]' % ids[0]:
            return ADDON.getLocalizedString(int(ids[0])).encode('utf-8')
        
        for id in ids:
            LocalizedString = ADDON.getLocalizedString(int(id)).encode('utf-8')
            label = label.replace('LOCALIZE[%s]' % id, LocalizedString)
            
    return label
开发者ID:assli100,项目名称:kodi-openelec,代码行数:14,代码来源:util.py

示例2: register

# 需要导入模块: from pulsar.addon import ADDON [as 别名]
# 或者: from pulsar.addon.ADDON import getLocalizedString [as 别名]
def register(search, search_movie, search_episode):
    import base64
    import json
    import sys

    try:
        payload = json.loads(base64.b64decode(sys.argv[1]))
    except:
        notify(ADDON.getLocalizedString(30102).encode('utf-8'), time=1000)
        return

    results = ()
    method = {
        "search": search,
        "search_movie": search_movie,
        "search_episode": search_episode,
    }.get(payload["method"]) or (lambda *a, **kw: [])
    try:
        results = ()
        objects = method(payload["search_object"])
        if objects is not None:
            results = tuple(objects)
    finally:
        urllib2.urlopen(
            payload["callback_url"],
            data=json.dumps(results)
        )
开发者ID:override187,项目名称:plugin.video.pulsar,代码行数:29,代码来源:provider.py

示例3: pulsard_thread

# 需要导入模块: from pulsar.addon import ADDON [as 别名]
# 或者: from pulsar.addon.ADDON import getLocalizedString [as 别名]
def pulsard_thread(monitor):
    try:
        import xbmc
        while not xbmc.abortRequested:
            log.info("pulsard: starting pulsard")
            proc = start_pulsard(stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
            threading.Thread(target=wait_for_abortRequested, args=[proc, monitor]).start()

            if PLATFORM["os"] == "windows":
                while proc.poll() is None:
                    log.info(proc.stdout.readline())
            else:
                # Kodi hangs on some Android (sigh...) systems when doing a blocking
                # read. We count on the fact that Pulsar daemon flushes its log
                # output on \n, creating a pretty clean output
                import fcntl
                fd = proc.stdout.fileno()
                fl = fcntl.fcntl(fd, fcntl.F_GETFL)
                fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
                while proc.poll() is None:
                    try:
                        log.info(proc.stdout.readline())
                        continue
                    except IOError:
                        time.sleep(1)  # nothing to read, sleep

            if proc.returncode == 0 or xbmc.abortRequested:
                break
            notify(ADDON.getLocalizedString(30100).encode('utf-8'), time=1000)
            time.sleep(3)
    except Exception:
        import xbmc
        import traceback
        map(xbmc.log, traceback.format_exc().split("\n"))
        raise
开发者ID:override187,项目名称:plugin.video.pulsar,代码行数:37,代码来源:daemon.py

示例4: run

# 需要导入模块: from pulsar.addon import ADDON [as 别名]
# 或者: from pulsar.addon.ADDON import getLocalizedString [as 别名]
def run(url_suffix=""):
    if not os.path.exists(os.path.join(xbmc.translatePath(ADDON.getAddonInfo("path")), ".firstrun")):
        notify(ADDON.getLocalizedString(30101).encode('utf-8'))
        return

    socket.setdefaulttimeout(300)
    urllib2.install_opener(urllib2.build_opener(NoRedirectHandler()))

    url = sys.argv[0].replace("plugin://%s" % ADDON_ID, PULSARD_HOST + url_suffix) + sys.argv[2]
    xbmc.log(url)

    try:
        data = _json(url)
    except:
        return

    if not data:
        return

    if data["content_type"]:
        xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
        xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_DATE)
        xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_GENRE)
        xbmcplugin.setContent(HANDLE, data["content_type"])

    listitems = range(len(data["items"]))
    for i, item in enumerate(data["items"]):
        # Translate labels
        if item["label"][0:8] == "LOCALIZE":
            item["label"] = GetLocalizedString(item["label"])
        if item["label2"][0:8] == "LOCALIZE":
            item["label2"] = GetLocalizedString(item["label2"])

        listItem = xbmcgui.ListItem(label=item["label"], label2=item["label2"], iconImage=item["icon"], thumbnailImage=item["thumbnail"])
        if item.get("info"):
            listItem.setInfo("video", item["info"])
        if item.get("stream_info"):
            for type_, values in item["stream_info"].items():
                listItem.addStreamInfo(type_, values)
        if item.get("art"):
            listItem.setArt(item["art"])
        if item.get("context_menu"):
            # Translate context menus
            print "Before: %s" % item["context_menu"]
            for m, menu in enumerate(item["context_menu"]):
                if menu[0][0:8] == "LOCALIZE":
                    menu[0] = GetLocalizedString(menu[0])
            print "After: %s" % item["context_menu"]
            listItem.addContextMenuItems(item["context_menu"])
        listItem.setProperty("isPlayable", item["is_playable"] and "true" or "false")
        if item.get("properties"):
            for k, v in item["properties"].items():
                listItem.setProperty(k, v)
        listitems[i] = (item["path"], listItem, not item["is_playable"])

    xbmcplugin.addDirectoryItems(HANDLE, listitems, totalItems=len(listitems))
    xbmcplugin.endOfDirectory(HANDLE, succeeded=True, updateListing=False, cacheToDisc=True)
开发者ID:Stevie-Bs,项目名称:repository.xvbmc,代码行数:60,代码来源:navigation.py

示例5: run

# 需要导入模块: from pulsar.addon import ADDON [as 别名]
# 或者: from pulsar.addon.ADDON import getLocalizedString [as 别名]
def run(url_suffix=""):
    if not os.path.exists(os.path.join(xbmc.translatePath(ADDON.getAddonInfo("path")), ".firstrun")):
        notify(ADDON.getLocalizedString(30101).encode('utf-8'))
        return

    socket.setdefaulttimeout(300)
    urllib2.install_opener(urllib2.build_opener(NoRedirectHandler()))

    url = sys.argv[0].replace("plugin://%s" % ADDON_ID, PULSARD_HOST + url_suffix) + sys.argv[2]
    xbmc.log(url)
    try: 
        data = _json(url)
    except urllib2.HTTPError, e:
        return
开发者ID:assli100,项目名称:kodi-openelec,代码行数:16,代码来源:navigation.py

示例6: GetLocalizedString

# 需要导入模块: from pulsar.addon import ADDON [as 别名]
# 或者: from pulsar.addon.ADDON import getLocalizedString [as 别名]
 def GetLocalizedString(self, *args, **kwargs):
     return ADDON.getLocalizedString(*args, **kwargs).encode('utf-8')
开发者ID:assli100,项目名称:kodi-openelec,代码行数:4,代码来源:rpc.py


注:本文中的pulsar.addon.ADDON.getLocalizedString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。