本文整理匯總了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)
示例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
示例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')))
示例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')))
示例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
示例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
示例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()
示例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
示例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")
示例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
示例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()
示例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)
示例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()
示例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
示例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)