本文整理汇总了Python中xbmcswift2.xbmc.translatePath函数的典型用法代码示例。如果您正苦于以下问题:Python translatePath函数的具体用法?Python translatePath怎么用?Python translatePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了translatePath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: movies_batch_add_to_library
def movies_batch_add_to_library():
""" Batch add movies to library """
movie_batch_file = plugin.get_setting(SETTING_MOVIES_BATCH_ADD_FILE_PATH)
if xbmcvfs.exists(movie_batch_file):
try:
f = open(xbmc.translatePath(movie_batch_file), 'r')
r = f.read()
f.close()
ids = r.split('\n')
except: return plugin.notify(msg='Movies Batch Add File', title='Not found', delay=3000, image=get_icon_path("movies"))
library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER))
import_tmdb()
for id in ids:
if "," in id:
csvs = id.split(',')
for csv in csvs:
if not str(csv).startswith("tt") and csv != "":
movie = tmdb.Movies(csv).info()
id = movie.get('imdb_id')
batch_add_movies_to_library(library_folder, id)
else:
if not str(id).startswith("tt") and id != "":
movie = tmdb.Movies(id).info()
id = movie.get('imdb_id')
batch_add_movies_to_library(library_folder, id)
os.remove(xbmc.translatePath(movie_batch_file))
if xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH)):
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/batch_add_to_library)")
return True
else:
xbmc.sleep(1000)
plugin.notify(msg='Added movie strm-files', title='Starting library scan', delay=3000, image=get_icon_path("movies"))
scan_library(type="video")
return True
elif xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH)): xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/batch_add_to_library)")
示例2: download
def download(path,reponame):
'''
Parameters
----------
path : string
Link download zip repo.
reponame : string
Tên thư mục của repo để kiểm tra đã cài chưa.
Mặc định được gán cho item["label2"].
Truyền "" để bỏ qua Kiểm tra đã cài
'''
if reponame == "":
reponame = "temp"
repo_zip = xbmc.translatePath(os.path.join(tmp,"%s.zip" % reponame))
urllib.urlretrieve(path,repo_zip)
with contextlib.closing(zipfile.ZipFile(repo_zip, "r")) as z:
z.extractall(addons_folder)
else:
repo_path = xbmc.translatePath('special://home/addons/%s' % reponame)
if not os.path.isdir(repo_path):
if reponame == "": reponame = "temp"
repo_zip = xbmc.translatePath(os.path.join(tmp,"%s.zip" % reponame))
urllib.urlretrieve(path,repo_zip)
with contextlib.closing(zipfile.ZipFile(repo_zip, "r")) as z:
z.extractall(addons_folder)
示例3: write_batch_id_files
def write_batch_id_files(tv_ids, movie_ids, misc_ids):
if len(tv_ids) > 0:
shows_import_file_path = "special://profile/addon_data/plugin.video.metalliq/shows_to_add.txt"
if xbmcvfs.exists(shows_import_file_path): os.remove(xbmc.translatePath(shows_import_file_path))
tv_id_list = ""
for id in tv_ids:
tv_id_list = tv_id_list + str(id) + '\n'
if not xbmcvfs.exists(shows_import_file_path):
batch_add_file = xbmcvfs.File(shows_import_file_path, 'w')
batch_add_file.write(tv_id_list)
batch_add_file.close()
dialogs.notify(msg='Converting tvshows, seasons & episodes', title='to id-list for batch-adding', delay=3000, image=get_icon_path("tvshows"))
if len(movie_ids) > 0:
movies_import_file_path = "special://profile/addon_data/plugin.video.metalliq/movies_to_add.txt"
if xbmcvfs.exists(movies_import_file_path): os.remove(xbmc.translatePath(movies_import_file_path))
movie_id_list = ""
for id in movie_ids:
movie_id_list = movie_id_list + str(id) + '\n'
if not xbmcvfs.exists(movies_import_file_path):
batch_add_file = xbmcvfs.File(movies_import_file_path, 'w')
batch_add_file.write(movie_id_list)
batch_add_file.close()
dialogs.notify(msg='Converting movies', title='to id-list for batch-adding', delay=3000, image=get_icon_path("movies"))
if len(misc_ids) > 0:
misc_import_file_path = "special://profile/addon_data/plugin.video.metalliq/misc_to_add.txt"
if xbmcvfs.exists(misc_import_file_path): os.remove(xbmc.translatePath(misc_import_file_path))
misc_id_list = ""
for id in misc_ids:
misc_id_list = misc_id_list + str(id) + '\n'
if not xbmcvfs.exists(misc_import_file_path):
batch_add_file = xbmcvfs.File(misc_import_file_path, 'w')
batch_add_file.write(misc_id_list)
batch_add_file.close()
dialogs.notify(msg='Converting miscellaneous', title='to id-list for batch-adding', delay=3000, image=get_icon_path("tvshows"))
示例4: write_list_id_files
def write_list_id_files(misc_ids, tv_ids, movie_ids, slug, user):
if len(misc_ids) > 0:
misc_list_file_path = "special://profile/addon_data/plugin.video.metalliq/misc_from_" + slug + "_by_" + user + ".txt"
if xbmcvfs.exists(misc_list_file_path): os.remove(xbmc.translatePath(misc_list_file_path))
misc_id_list = ""
for id in misc_ids:
misc_id_list = misc_id_list + str(id) + '\n'
if not xbmcvfs.exists(misc_list_file_path):
batch_add_file = xbmcvfs.File(misc_list_file_path, 'w')
batch_add_file.write(misc_id_list)
batch_add_file.close()
if len(tv_ids) > 0:
shows_list_file_path = "special://profile/addon_data/plugin.video.metalliq/shows_from_" + slug + "_by_" + user + ".txt"
if xbmcvfs.exists(shows_list_file_path): os.remove(xbmc.translatePath(shows_list_file_path))
tv_id_list = ""
for id in tv_ids:
tv_id_list = tv_id_list + str(id) + '\n'
if not xbmcvfs.exists(shows_list_file_path):
batch_add_file = xbmcvfs.File(shows_list_file_path, 'w')
batch_add_file.write(tv_id_list)
batch_add_file.close()
if len(movie_ids) > 0:
movies_list_file_path = "special://profile/addon_data/plugin.video.metalliq/movies_from_" + slug + "_by_" + user + ".txt"
if xbmcvfs.exists(movies_list_file_path): os.remove(xbmc.translatePath(movies_list_file_path))
movie_id_list = ""
for id in movie_ids:
movie_id_list = movie_id_list + str(id) + '\n'
if not xbmcvfs.exists(movies_list_file_path):
batch_add_file = xbmcvfs.File(movies_list_file_path, 'w')
batch_add_file.write(movie_id_list)
batch_add_file.close()
示例5: IIi1IiiiI1Ii
def IIi1IiiiI1Ii():
I11i11Ii("None", "None")
# oO00oOo = ""
# OOOo0 = ( "Busy" , "Bận" , "Band" , "Beschäftigt" , "Bezig" , "忙" , "忙碌" )
# while True :
# Oooo000o = urllib . quote ( xbmc . getInfoLabel ( "System.KernelVersion" ) . strip ( ) )
# if not any ( b in Oooo000o for b in OOOo0 ) : break
# while True :
# IiIi11iIIi1Ii = urllib . quote ( xbmc . getInfoLabel ( "System.FriendlyName" ) . strip ( ) )
# if not any ( b in IiIi11iIIi1Ii for b in OOOo0 ) : break
# try :
# oO00oOo = open ( '/sys/class/net/eth0/address' ) . read ( ) . strip ( )
# except :
# while True :
# oO00oOo = xbmc . getInfoLabel ( "Network.MacAddress" ) . strip ( )
# if re . match ( "[0-9a-f]{2}([-:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$" , oO00oOo . lower ( ) ) : break
# Oo0O = urllib2 . urlopen ( "http://www.viettv24.com/main/checkActivation.php?MacID=%s&app_id=%s&sys=%s&dev=%s" % ( oO00oOo , "10" , Oooo000o , IiIi11iIIi1Ii ) ) . read ( )
if True:
IiI = xbmc.translatePath(xbmcaddon.Addon().getAddonInfo("path")).decode("utf-8")
IiI = xbmc.translatePath(os.path.join(IiI, "temp.jpg"))
# urllib . urlretrieve ( 'https://googledrive.com/host/0B-ygKtjD8Sc-S04wUUxMMWt5dmM/images/phim14.jpg' , IiI )
# ooOo = xbmcgui . ControlImage ( 0 , 0 , 1280 , 720 , IiI )
# Oo = xbmcgui . WindowDialog ( )
# Oo . addControl ( ooOo )
# Oo . doModal ( )
if 67 - 67:
O00ooOO.I1iII1iiII
iI1Ii11111iIi = [
{
"label": "Phim mới",
"path": "%s/latest/%s/%s"
% (ii, urllib.quote_plus("http://m.phim14.net/danh-sach/phim-moi/page-%s.html"), 1),
},
{
"label": "Phim lẻ",
"path": "%s/movies/%s/%s"
% (ii, urllib.quote_plus("http://m.phim14.net/danh-sach/phim-le/page-%s.html"), 1),
},
{
"label": "Phim bộ",
"path": "%s/series/%s/%s"
% (ii, urllib.quote_plus("http://m.phim14.net/danh-sach/phim-bo/page-%s.html"), 1),
},
{"label": "Theo thể loại", "path": "%s/genres" % ii},
{"label": "Theo Quốc gia", "path": "%s/nations" % ii},
{"label": "Tìm kiếm", "path": "%s/search" % ii},
]
return oo000.finish(iI1Ii11111iIi)
else:
i1i1II = xbmcgui.Dialog()
i1i1II.ok("Chú ý", Oo0O)
if 96 - 96:
o0OO0 - Oo0ooO0oo0oO.I1i1iI1i - o00ooo0 / o00 * Oo0oO0ooo
if 56 - 56:
ooO00oOoo - O0OOo
示例6: show_seq_info
def show_seq_info(url):
#dir_contents = dircache.listdir(seq_location)
#dir_contents = fnmatch.filter(dir_contents, '*.lseq')
fullpath = xbmc.translatePath(seq_location + '/' + url)
seqs = [{'label': url, 'path': plugin.url_for('play_sequence', url=fullpath)}]
return seqs
示例7: __init__
def __init__(self, name, addon_id, filepath):
self._name = name
self._filepath = filepath
self._addon_id = addon_id
self._routes = []
self._view_functions = {}
self._addon = xbmcaddon.Addon(id=self._addon_id)
# Keeps track of the added list items
self._current_items = []
# Gets initialized when self.run() is called
self._request = None
# A flag to keep track of a call to xbmcplugin.endOfDirectory()
self._end_of_directory = False
# The plugin's named logger
self._log = setup_log(addon_id)
# The path to the cache directory for the addon
self._cache_path = xbmc.translatePath(
'special://profile/addon_data/%s/.cache/' % self._addon_id)
# If we are runing in CLI, we need to load the strings.xml manually
# TODO: a better way to do this. Perhaps allow a user provided filepath
if xbmcswift2.CLI_MODE:
from xbmcswift2.mockxbmc import utils
utils.load_addon_strings(self._addon,
os.path.join(os.path.dirname(self._filepath), 'resources',
'language', 'English', 'strings.xml'))
示例8: setup_library
def setup_library(library_folder):
if library_folder[-1] != "/":
library_folder += "/"
metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
if not xbmcvfs.exists(metalliq_playlist_folder):
xbmcvfs.mkdir(metalliq_playlist_folder)
playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)
if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)[-1] != "/":
playlist_folder += "/"
# create folders
if not xbmcvfs.exists(playlist_folder):
xbmcvfs.mkdir(playlist_folder)
if not xbmcvfs.exists(library_folder):
# create folder
xbmcvfs.mkdir(library_folder)
# auto configure folder
msg = _(
"Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a movies video source?"
)
if dialogs.yesno(_("Library setup"), msg):
source_thumbnail = get_icon_path("movies")
source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Movies")
source_content = '(\'{0}\',\'movies\',\'metadata.themoviedb.org\',\'\',2147483647,1,\'<settings><setting id="RatingS" value="TMDb" /><setting id="certprefix" value="Rated " /><setting id="fanart" value="true" /><setting id="keeporiginaltitle" value="false" /><setting id="language" value="{1}" /><setting id="tmdbcertcountry" value="us" /><setting id="trailer" value="true" /></settings>\',0,0,NULL,NULL)'.format(
library_folder, LANG
)
add_source(source_name, library_folder, source_content, source_thumbnail)
# return translated path
return xbmc.translatePath(library_folder)
示例9: add_source
def add_source(source_name, source_path, source_content, source_thumbnail):
xml_file = xbmc.translatePath('special://profile/sources.xml')
if not os.path.exists(xml_file):
with open(xml_file, "w") as f:
f.write("""<sources>
<programs>
<default pathversion="1" />
</programs>
<video>
<default pathversion="1" />
</video>
<music>
<default pathversion="1" />
</music>
<pictures>
<default pathversion="1" />
</pictures>
<files>
<default pathversion="1" />
</files>
</sources>""")
existing_source = _get_source_attr(xml_file, source_name, "path")
if existing_source and existing_source != source_path:
_remove_source_content(existing_source)
if _add_source_xml(xml_file, source_name, source_path, source_thumbnail):
_set_source_content(source_content)
示例10: resolve_video_url
def resolve_video_url(url):
from xbmcswift2 import xbmc
cookiepath = xbmc.translatePath( 'special://temp/dabdate_cookie.lwp' )
userid = plugin.get_setting('id', str)
passwd = plugin.get_setting('pass', str)
page_url = dabdate.root_url+url
return dabdate.getStreamUrl( page_url, userid=userid, passwd=passwd, cookiefile=cookiepath )
示例11: get_stream
def get_stream(channel):
playlistFilename = (xbmc.translatePath('special://temp/') +
'twitchplaylist.m3u8')
srlVideoResolver.resolveChannelToPlaylist(channel, playlistFilename)
xbmc.Player().play(playlistFilename)
plugin.set_resolved_url(playlistFilename)
示例12: auto_tv_setup
def auto_tv_setup(library_folder):
if library_folder[-1] != "/":
library_folder += "/"
if not xbmcvfs.exists(library_folder):
xbmcvfs.mkdir(library_folder)
source_thumbnail = xbmc.translatePath('special://home/addons/plugin.video.meta/resources/img/tv.png')
source_name = "Meta TVShows"
source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
add_source(source_name, library_folder, source_content, source_thumbnail)
示例13: __init__
def __init__(self, name=None, addon_id=None, filepath=None, info_type=None):
self._name = name
self._routes = []
self._view_functions = {}
# addon_id is no longer required as it can be parsed from addon.xml
if addon_id:
self._addon = xbmcaddon.Addon(id=addon_id)
else:
self._addon = xbmcaddon.Addon()
self._addon_id = addon_id or self._addon.getAddonInfo('id')
self._name = name or self._addon.getAddonInfo('name')
self._info_type = info_type
if not self._info_type:
types = {
'video': 'video',
'audio': 'music',
'image': 'pictures',
}
self._info_type = types.get(self._addon_id.split('.')[1], 'video')
# Keeps track of the added list items
self._current_items = []
# Gets initialized when self.run() is called
self._request = None
# A flag to keep track of a call to xbmcplugin.endOfDirectory()
self._end_of_directory = False
# Keep track of the update_listing flag passed to
# xbmcplugin.endOfDirectory()
self._update_listing = False
# The plugin's named logger
self._log = setup_log(self._addon_id)
# The path to the storage directory for the addon
self._storage_path = xbmc.translatePath(
'special://profile/addon_data/%s/.storage/' % self._addon_id)
if not os.path.isdir(self._storage_path):
os.makedirs(self._storage_path)
# If we are runing in CLI, we need to load the strings.xml manually
# Since xbmcswift2 currently relies on execution from an addon's root
# directly, we can rely on cwd for now...
if xbmcswift2.CLI_MODE:
from xbmcswift2.mockxbmc import utils
if filepath:
addon_dir = os.path.dirname(filepath)
else:
addon_dir = os.getcwd()
strings_fn = os.path.join(addon_dir, 'resources', 'language',
'English', 'strings.xml')
utils.load_addon_strings(self._addon, strings_fn)
示例14: get_skin_resolution
def get_skin_resolution():
import xml.etree.ElementTree as ElementTree
skin_path = xbmc.translatePath("special://skin/addon.xml")
if not os.path.exists(skin_path):
return Resolution(1280, 720)
else:
tree = ElementTree.parse(skin_path)
res = tree.findall("./extension/res")[0]
return Resolution(int(res.attrib["width"]), int(res.attrib["height"]))
示例15: ensure_path_local
def ensure_path_local(path):
path = xbmc.translatePath(path)
if "://" in path:
if sys.platform.startswith('win') and path.lower().startswith("smb://"):
path = path.replace("smb:", "").replace("/", "\\")
else:
raise LocalizedError(33030, "Downloading to an unmounted network share is not supported",
check_settings=True)
return ensure_unicode(path)