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


Python xbmc.translatePath方法代码示例

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


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

示例1: delete_folder

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def delete_folder(path=None):

    ''' Delete objects from kodi cache
    '''
    LOG.debug("--[ delete folder ]")
    delete_path = path is not None
    path = path or xbmc.translatePath('special://temp/emby').decode('utf-8')
    dirs, files = xbmcvfs.listdir(path)

    delete_recursive(path, dirs)

    for file in files:
        xbmcvfs.delete(os.path.join(path, file.decode('utf-8')))

    if delete_path:
        xbmcvfs.delete(path)
    
    LOG.warn("DELETE %s", path) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:20,代码来源:utils.py

示例2: download_external_subs

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def download_external_subs(cls, src, filename):

        ''' Download external subtitles to temp folder
            to be able to have proper names to streams.
        '''
        temp = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/temp/").decode('utf-8')

        if not xbmcvfs.exists(temp):
            xbmcvfs.mkdir(temp)

        path = os.path.join(temp, filename)

        try:
            response = requests.get(src, stream=True, verify=False)
            response.raise_for_status()
        except Exception as e:
            raise
        else:
            response.encoding = 'utf-8'
            with open(path, 'wb') as f:
                f.write(response.content)
                del response

        return path 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:26,代码来源:playutils.py

示例3: delete_nodes

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def delete_nodes(self):

        ''' Remove node and children files.
        '''
        path = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
        dirs, files = xbmcvfs.listdir(path)

        for file in files:

            if file.startswith('emby'):
                self.delete_node(os.path.join(path, file.decode('utf-8')))

        for directory in dirs:

            if directory.startswith('emby'):
                _, files = xbmcvfs.listdir(os.path.join(path, directory.decode('utf-8')))

                for file in files:
                    self.delete_node(os.path.join(path, directory.decode('utf-8'), file.decode('utf-8')))

                xbmcvfs.rmdir(os.path.join(path, directory.decode('utf-8'))) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:23,代码来源:views.py

示例4: delete_node_by_id

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def delete_node_by_id(self, view_id):

        ''' Remove node and children files based on view_id.
        '''
        path = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
        dirs, files = xbmcvfs.listdir(path)

        for directory in dirs:

            if directory.startswith('emby') and directory.endswith(view_id):
                _, files = xbmcvfs.listdir(os.path.join(path, directory.decode('utf-8')))

                for file in files:
                    self.delete_node(os.path.join(path, directory.decode('utf-8'), file.decode('utf-8')))

                xbmcvfs.rmdir(os.path.join(path, directory.decode('utf-8'))) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:18,代码来源:views.py

示例5: _get_database

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def _get_database(self, path, silent=False):

        path = xbmc.translatePath(path).decode('utf-8')

        if not silent:

            if not xbmcvfs.exists(path):
                raise Exception("Database: %s missing" % path)

            conn = sqlite3.connect(path)
            cursor = conn.cursor()
            cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
            tables = cursor.fetchall()
            conn.close()

            if not len(tables):
                raise Exception("Database: %s malformed?" % path)

        return path 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:21,代码来源:__init__.py

示例6: get_sync

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def get_sync():

    path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/").decode('utf-8')
    
    if not xbmcvfs.exists(path):
        xbmcvfs.mkdirs(path)

    try:
        with open(os.path.join(path, 'sync.json')) as infile:
            sync = json.load(infile)
    except Exception:
        sync = {}

    sync['Libraries'] = sync.get('Libraries', [])
    sync['RestorePoint'] = sync.get('RestorePoint', {})
    sync['Whitelist'] = list(set(sync.get('Whitelist', [])))
    sync['SortedViews'] = sync.get('SortedViews', [])

    return sync 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:21,代码来源:__init__.py

示例7: images

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def images(self):

        ''' Return a dummy image for unwanted images requests over the webservice.
            Required to prevent freezing of widget playback if the file url has no
            local textures cached yet.
        '''
        image = xbmc.translatePath("special://home/addons/plugin.video.emby/icon.png").decode('utf-8')

        self.send_response(200)
        self.send_header('Content-type', 'image/png')
        modified = xbmcvfs.Stat(image).st_mtime()
        self.send_header('Last-Modified', "%s" % modified)
        image = xbmcvfs.File(image)
        size = image.size()
        self.send_header('Content-Length', str(size))
        self.end_headers()

        self.wfile.write(image.readBytes())
        image.close() 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:21,代码来源:webservice.py

示例8: add_item_to_library

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def add_item_to_library(self, item_path, item_url):
        error = False
        new = False
        if item_path:
            item_path = xbmc.translatePath(item_path)
            dir = os.path.dirname(item_path)
            if not xbmcvfs.exists(dir):
                try:
                    xbmcvfs.mkdirs(dir)
                except Exception, e:
                    error = True
                    util.error('Failed to create directory 1: ' + dir)

            if not xbmcvfs.exists(item_path):
                try:
                    file_desc = xbmcvfs.File(item_path, 'w')
                    file_desc.write(item_url)
                    file_desc.close()
                    new = True
                except Exception, e:
                    util.error('Failed to create .strm file: ' +
                               item_path + " | " + str(e))
                    error = True 
开发者ID:kodi-czsk,项目名称:plugin.video.sosac.ph,代码行数:25,代码来源:sutils.py

示例9: __init__

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def __init__( self ):
		sources = xbmc.translatePath('special://profile/sources.xml')
		file = open(sources, 'r')
		source_data = file.read()
		file.close()
		source_tree = BeautifulSoup(source_data, 'html.parser')
		tv_path = source_tree.find('path', text = TV_SHOWS_PATH)
		movie_path = source_tree.find('path', text = MOVIE_PATH)
		msg = ""
		if tv_path is None:
			msg = "No source for " + TV_SHOWS_PATH + "\n"
		if movie_path is None:
			msg = "No source for " + MOVIE_PATH + "\n"
		if msg != "":
			dialog = xbmcgui.Dialog()
			dialog.ok(addon.getLocalizedString(39042), msg)
		else:
			dialog = xbmcgui.Dialog()
			dialog.ok(addon.getLocalizedString(39042), "Sources OK") 
开发者ID:moneymaker365,项目名称:plugin.video.ustvvod,代码行数:21,代码来源:xbmclibrary.py

示例10: deleteDB

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def deleteDB():
    try:
        xbmc.log("[script.tvguide.fullscreen] Deleting database...", xbmc.LOGDEBUG)
        dbPath = xbmc.translatePath(xbmcaddon.Addon(id = 'script.tvguide.fullscreen').getAddonInfo('profile'))
        dbPath = os.path.join(dbPath, 'source.db')

        delete_file(dbPath)

        passed = not os.path.exists(dbPath)

        if passed:
            xbmc.log("[script.tvguide.fullscreen] Deleting database...PASSED", xbmc.LOGDEBUG)
        else:
            xbmc.log("[script.tvguide.fullscreen] Deleting database...FAILED", xbmc.LOGDEBUG)

        return passed

    except Exception, e:
        xbmc.log('[script.tvguide.fullscreen] Deleting database...EXCEPTION', xbmc.LOGDEBUG)
        return False 
开发者ID:primaeval,项目名称:script.tvguide.fullscreen,代码行数:22,代码来源:ResetDatabase.py

示例11: __init__

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def __init__(self,force=False):
        self.conn = None
        self.eventQueue = list()
        self.event = threading.Event()
        self.eventResults = dict()

        self.loadOptional(force)
        self.source = instantiateSource(force)

        self.updateInProgress = False
        self.updateFailed = False
        self.settingsChanged = None
        self.alreadyTriedUnlinking = False
        self.channelList = list()
        self.category = "Any"

        profilePath = xbmc.translatePath(ADDON.getAddonInfo('profile'))
        if not os.path.exists(profilePath):
            os.makedirs(profilePath)
        self.databasePath = os.path.join(profilePath, Database.SOURCE_DB)

        threading.Thread(name='Database Event Loop', target=self.eventLoop).start() 
开发者ID:primaeval,项目名称:script.tvguide.fullscreen,代码行数:24,代码来源:source.py

示例12: autocrop_image

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def autocrop_image(infile,outfile):
    infile = xbmc.translatePath(infile)
    image = Image.open(infile)
    border = 0
    size = image.size
    bb_image = image
    bbox = bb_image.getbbox()
    if (size[0] == bbox[2]) and (size[1] == bbox[3]):
        bb_image=bb_image.convert("RGB")
        bb_image = ImageOps.invert(bb_image)
        bbox = bb_image.getbbox()
    image = image.crop(bbox)
    (width, height) = image.size
    width += border * 2
    height += border * 2
    ratio = float(width)/height
    cropped_image = Image.new("RGBA", (width, height), (0,0,0,0))
    cropped_image.paste(image, (border, border))
    #TODO find epg height
    logo_height = 450 / int(ADDON.getSetting('channels.per.page'))
    logo_height = logo_height - 2
    cropped_image = cropped_image.resize((int(logo_height*ratio), logo_height),Image.ANTIALIAS)
    outfile = xbmc.translatePath(outfile)
    cropped_image.save(outfile) 
开发者ID:primaeval,项目名称:script.tvguide.fullscreen,代码行数:26,代码来源:ResizeLogos.py

示例13: shutdown_hooks

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def shutdown_hooks():
	opcao= xbmcgui.Dialog().yesno(translate(40000), translate(70027),translate(70028) + str(xbmc.getSkinDir()) )
	if opcao:
		mensagemok(translate(40000),translate(70029),translate(70030))
		mensagemok(translate(40000),translate(70031))
		opcao= xbmcgui.Dialog().yesno(translate(40000), translate(70032) )
		if opcao:
			import xml.etree.ElementTree as ET
			skin_path = xbmc.translatePath("special://skin/")
			tree = ET.parse(os.path.join(skin_path, "addon.xml"))
			try: res = tree.findall("./res")[0]
			except: res = tree.findall("./extension/res")[0]
			xml_specific_folder = str(res.attrib["folder"])
			xml_video_osd = os.path.join(xbmc.translatePath("special://skin/"),xml_specific_folder,"VideoOSD.xml")
			xml_content = readfile(xml_video_osd).replace('PlayerControl(Stop)','RunPlugin(plugin://plugin.video.p2p-streams/?mode=7)')
			try:
				save(xml_video_osd,xml_content)
				xbmc.executebuiltin("Notification(%s,%s,%i,%s)" % (translate(40000), translate(600026), 1,addonpath+"/icon.png"))
			except: mensagemok(translate(40000),'No permissions.')
			opcao= xbmcgui.Dialog().yesno(translate(40000), translate(70033) )
			if opcao:
				from peertopeerutils.keymapeditor import *
				run() 
开发者ID:tvaddonsco,项目名称:program.plexus,代码行数:25,代码来源:advancedfunctions.py

示例14: get_upnext_info

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def get_upnext_info(videoid, videoid_next_episode, info_data, metadata, is_played_from_addon):
    """Get the data to send to Up Next add-on"""
    upnext_info = {
        'current_episode': _upnext_info(videoid, *info_data[videoid.value]),
        'next_episode': _upnext_info(videoid_next_episode, *info_data[videoid_next_episode.value])
    }

    if is_played_from_addon:
        url = common.build_url(videoid=videoid_next_episode,
                               mode=g.MODE_PLAY,
                               params={'profile_guid': g.LOCAL_DB.get_active_profile_guid()})
    else:
        # Played from Kodi library get the strm file path
        file_path = g.SHARED_DB.get_episode_filepath(
            videoid_next_episode.tvshowid,
            videoid_next_episode.seasonid,
            videoid_next_episode.episodeid)
        url = g.py2_decode(xbmc.translatePath(file_path))
    upnext_info['play_info'] = {'play_path': url}

    if 'creditsOffset' in metadata[0]:
        upnext_info['notification_offset'] = metadata[0]['creditsOffset']
    return upnext_info 
开发者ID:CastagnaIT,项目名称:plugin.video.netflix,代码行数:25,代码来源:am_upnext_notifier.py

示例15: purge

# 需要导入模块: import xbmc [as 别名]
# 或者: from xbmc import translatePath [as 别名]
def purge():
    """Purge all items exported to Kodi library and delete internal library database"""
    common.info('Purging internal database and kodi library')
    for videoid_value in g.SHARED_DB.get_movies_id_list():
        videoid = common.VideoId.from_path([common.VideoId.MOVIE, videoid_value])
        execute_library_tasks(videoid, [remove_item],
                              common.get_local_string(30030))
    for videoid_value in g.SHARED_DB.get_tvshows_id_list():
        videoid = common.VideoId.from_path([common.VideoId.SHOW, videoid_value])
        execute_library_tasks(videoid, [remove_item],
                              common.get_local_string(30030))
    # If for some reason such as improper use of the add-on, unexpected error or other
    # has caused inconsistencies with the contents of the database or stored files,
    # make sure that everything is removed
    g.SHARED_DB.purge_library()
    for folder_name in [FOLDER_MOVIES, FOLDER_TV]:
        section_dir = xbmc.translatePath(
            makeLegalFilename('/'.join([library_path(), folder_name])))
        common.delete_folder_contents(section_dir, delete_subfolders=True) 
开发者ID:CastagnaIT,项目名称:plugin.video.netflix,代码行数:21,代码来源:library.py


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