本文整理汇总了Python中xbmc.validatePath函数的典型用法代码示例。如果您正苦于以下问题:Python validatePath函数的具体用法?Python validatePath怎么用?Python validatePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validatePath函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setup
def setup(self):
#create authorization helper and load default settings
gauth = GoogleAuth(xbmc.validatePath(xbmc.translatePath(utils.addon_dir() + '/resources/lib/pydrive/settings.yaml')))
gauth.LoadClientConfigSettings()
#check if this user is already authorized
if(not xbmcvfs.exists(xbmc.translatePath(utils.data_dir() + "google_drive.dat"))):
settings = {"client_id":self.CLIENT_ID,'client_secret':self.CLIENT_SECRET}
drive_url = gauth.GetAuthUrl(settings)
utils.log("Google Drive Authorize URL: " + drive_url)
code = xbmcgui.Dialog().input('Google Drive Validation Code','Input the Validation code after authorizing this app')
gauth.Auth(code)
gauth.SaveCredentialsFile(xbmc.validatePath(xbmc.translatePath(utils.data_dir() + 'google_drive.dat')))
else:
gauth.LoadCredentialsFile(xbmc.validatePath(xbmc.translatePath(utils.data_dir() + 'google_drive.dat')))
#create the drive object
self.drive = GoogleDrive(gauth)
#make sure we have the folder we need
xbmc_folder = self._getGoogleFile(self.root_path)
print xbmc_folder
if(xbmc_folder == None):
self.mkdir(self.root_path)
开发者ID:elephunk84,项目名称:Kodi-Addons,代码行数:28,代码来源:vfs.py
示例2: init
def init(self, magnet_uri):
self.magnet_uri = magnet_uri
self.magnet_args = urlparse.parse_qs(self.magnet_uri.replace("magnet:?", "")) # I know about urlparse.urlsplit but this is faster
self.magnet_display_name = ""
if self.magnet_args["dn"]:
self.magnet_display_name = self.magnet_args["dn"][0]
self.torrent2http_options = {
"magnet": magnet_uri,
"dlpath": xbmc.validatePath(xbmc.translatePath(plugin.get_setting("dlpath"))) or ".",
"dlrate": plugin.get_setting("max_download_rate") or "0",
"ulrate": plugin.get_setting("max_upload_rate") or "0",
"encryption": plugin.get_setting("encryption"),
}
# Check for Android and FAT32 SD card issues
if PLATFORM["os"] == "android" and "sdcard" in self.torrent2http_options["dlpath"].lower():
plugin.notify("Downloading to SD card is not supported (FAT32). Resetting.", delay=15000)
plugin.set_setting("dlpath", "")
self.torrent2http_options["dlpath"] = xbmc.validatePath(xbmc.translatePath(plugin.get_setting("dlpath"))) or "."
# Translate smb:// url to UNC path on windows, very hacky
if PLATFORM["os"] == "windows" and "smb://" in self.torrent2http_options["dlpath"].lower():
self.torrent2http_options["dlpath"] = self.torrent2http_options["dlpath"].replace("smb:", "").replace("/", "\\")
if plugin.get_setting("keep_files", bool):
plugin.log.info("Will keep file after playback.")
self.torrent2http_options["keep"] = None
self.on_playback_started = []
self.on_playback_resumed = []
self.on_playback_paused = []
self.on_playback_stopped = []
return self
开发者ID:samheg,项目名称:xbmctorrent,代码行数:29,代码来源:player.py
示例3: getClient
def getClient(self):
#create authorization helper and load default settings
gauth = GoogleAuth(xbmc.validatePath(xbmc.translatePath(utils.addon_dir() + '/resources/lib/pydrive/settings.yaml')))
gauth.LoadClientConfigSettings()
gauth.LoadCredentialsFile(xbmc.validatePath(xbmc.translatePath(utils.data_dir() + 'google_drive.dat')))
result = GoogleDrive(gauth)
return result
开发者ID:robweber,项目名称:xbmcbackup,代码行数:10,代码来源:authorizers.py
示例4: _get_folder_images
def _get_folder_images(self, path):
self.log("_get_folder_images started with path: %s" % repr(path))
dirs, files = xbmcvfs.listdir(path)
images = [xbmc.validatePath(path + f) for f in files if f.lower()[-3:] in ("jpg", "png")]
if addon.getSetting("recursive") == "true":
for directory in dirs:
if directory.startswith("."):
continue
images.extend(self._get_folder_images(xbmc.validatePath("/".join((path, directory, "")))))
self.log("_get_folder_images ends")
return images
开发者ID:jspullar,项目名称:script.screensaver.multi_slideshow,代码行数:11,代码来源:screensaver.py
示例5: MenuAccounts
def MenuAccounts():
if (tfalse(addst("anon-enable","false"))==True):
anonPath=xbmc.validatePath(xbmc.translatePath(addst("anon-path","special://logpath"))) #.replace(pFindWhat,"|tag|").replace("|tag|",pReplaceWith)
if (len(anonPath) > 0):
addon.add_directory({'mode':'System.ExecWait','url':'ftp://'+LiP+':'+addst('port','2121')+'/'},{'title':cFL('00.)','darkorange')+' User: '+cFL('[ [I]Anonymous[/I] ]','darkorange')+'[CR]'+anonPath},is_folder=True,fanart=_artFanart,img=artp("Anonymous"))
for tn in ['01','02','03','04','05','06','07','08','09','10']:
if (tfalse(addst(tn+"-enable","false"))==True):
tt={}; tt['path']=xbmc.validatePath(xbmc.translatePath(addst(tn+"-path","special://logpath")))
tt['user']=addst(tn+"-user",""); tt['pass']=addst(tn+"-pass","xbmchub"); tt['perm']=addst(tn+"-perm","elradfmwM")
if (len(tt['user']) > 0) and (len(tt['path']) > 0):
addon.add_directory({'mode':'GoToFTP','url':tn},{'title':cFL(tn+'.)','darkorange')+' User: '+cFL(tt['user'],'darkorange')+'[CR]'+tt['path']},is_folder=True,fanart=_artFanart,img=artp("User"+tn))
开发者ID:HIGHWAY99,项目名称:repository.thehighway.br,代码行数:11,代码来源:default.py
示例6: _fetch_movies
def _fetch_movies(self, request):
if request == 'RecommendedMovie':
# Unfinished movies
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["title", "playcount", "year", "genre", "studio", "tagline", "plot", "runtime", "fanart", "thumbnail", "file", "plotoutline", "lastplayed", "trailer", "rating", "resume"], "sort": {"order": "descending", "method": "lastplayed"}, "limits": {"end": %d}, "filter": {"field": "inprogress", "operator": "true", "value": ""}}, "id": 1}' %self.LIMIT)
elif request == 'RecentMovie' and self.RECENTITEMS_UNPLAYED:
# Recent added and unplayed
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["title", "playcount", "year", "genre", "studio", "tagline", "plot", "runtime", "fanart", "thumbnail", "file", "plotoutline", "lastplayed", "trailer", "rating", "resume"], "sort": {"order": "descending", "method": "dateadded"}, "limits": {"end": %d}, "filter": {"field": "playcount", "operator": "is", "value": "0"} }, "id": 1}' %self.LIMIT)
elif request == 'RecentMovie':
# Recent added
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["title", "playcount", "year", "genre", "studio", "tagline", "plot", "runtime", "fanart", "thumbnail", "file", "plotoutline", "lastplayed", "trailer", "rating", "resume"], "sort": {"order": "descending", "method": "dateadded"}, "limits": {"end": %d} }, "id": 1}' %self.LIMIT)
elif request == "RandomMovie" and self.RANDOMITEMS_UNPLAYED:
# Reandom and unplayed
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["title", "playcount", "year", "genre", "studio", "tagline", "plot", "runtime", "fanart", "thumbnail", "file", "plotoutline", "lastplayed", "trailer", "rating", "resume"], "sort": {"method": "random" }, "limits": {"end": %d} , "filter": {"field": "playcount", "operator": "lessthan", "value": "1"} }, "id": 1}' %self.LIMIT)
else:
# Random episode
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["title", "playcount", "year", "genre", "studio", "tagline", "plot", "runtime", "fanart", "thumbnail", "file", "plotoutline", "lastplayed", "trailer", "rating", "resume"], "sort": {"method": "random" }, "limits": {"end": %d} }, "id": 1}' %self.LIMIT)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
if json_response['result'].has_key('movies'):
self._clear_properties(request)
count = 0
for item in json_response['result']['movies']:
count += 1
if item['resume']['position'] > 0:
resume = "true"
played = '%s%%'%int((float(item['resume']['position']) / float(item['resume']['total'])) * 100)
else:
resume = "false"
played = '0%'
path = media_path(item['file'])
self.WINDOW.setProperty("%s.%d.Title" % (request, count), item['title'])
self.WINDOW.setProperty("%s.%d.Year" % (request, count), str(item['year']))
self.WINDOW.setProperty("%s.%d.Genre" % (request, count), " / ".join(item['genre']))
self.WINDOW.setProperty("%s.%d.Studio" % (request, count), item['studio'][0])
self.WINDOW.setProperty("%s.%d.Plot" % (request, count), item['plot'])
self.WINDOW.setProperty("%s.%d.PlotOutline" % (request, count), item['plotoutline'])
self.WINDOW.setProperty("%s.%d.Tagline" % (request, count), item['tagline'])
self.WINDOW.setProperty("%s.%d.Runtime" % (request, count), item['runtime'])
self.WINDOW.setProperty("%s.%d.Rating" % (request, count), str(round(float(item['rating']),1)))
self.WINDOW.setProperty("%s.%d.Trailer" % (request, count), item['trailer'])
self.WINDOW.setProperty("%s.%d.Fanart" % (request, count), item['fanart'])
self.WINDOW.setProperty("%s.%d.Thumb" % (request, count), item['thumbnail'])
self.WINDOW.setProperty("%s.%d.Logo" % (request, count), xbmc.validatePath(os.path.join(path, 'logo.png')))
self.WINDOW.setProperty("%s.%d.Landscape" % (request, count), xbmc.validatePath(os.path.join(path, 'landscape.png')))
self.WINDOW.setProperty("%s.%d.Banner" % (request, count), xbmc.validatePath(os.path.join(path, 'banner.png')))
self.WINDOW.setProperty("%s.%d.Disc" % (request, count), xbmc.validatePath(os.path.join(path, 'disc.png')))
self.WINDOW.setProperty("%s.%d.Resume" % (request, count), resume)
self.WINDOW.setProperty("%s.%d.Played" % (request, count), played)
self.WINDOW.setProperty("%s.%d.File" % (request, count), item['file'])
self.WINDOW.setProperty("%s.%d.Path" % (request, count), path)
开发者ID:BigNoid,项目名称:service.skin.widgets,代码行数:50,代码来源:default.py
示例7: _get_legal_filepath
def _get_legal_filepath(self, title, url, id_=0):
# set our default filename and extension
file_, ext = os.path.splitext(os.path.basename(url))
# does user want to use title as filename
file_ = [file_, title][self.m_addon.getSetting("trailer.use.title")]
# set identifier
trailer_id = ""
if (id_ > 0):
trailer_id = " ({id})".format(id="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[id_])
# set our default trailer text
trailer = ["", "-trailer"][self.m_addon.getSetting("trailer.add.trailer")]
# set our default file path (if play_mode is temp, download to cache folder)
if (self.m_addon.getSetting("trailer.play.mode") == 1):
filepath = "special://temp/"
else:
filepath = self.m_addon.getSetting("trailer.save.folder") or "special://temp/"
# do we want to save with movie
if (self.m_addon.getSetting("trailer.save.movie")):
filepath, file_, trailer = self._get_movie_path(
title,
filepath,
file_,
trailer
)
# set final filename
file_ = "{name}{id}{trailer}{ext}".format(
name=os.path.splitext(file_)[0],
id=trailer_id,
trailer=trailer,
ext=ext
)
# FIXME: may need changing for temorary download
# if file already exists add an ID and try again
if (filepath != "special://temp/" and
xbmcvfs.exists(xbmc.makeLegalFilename(xbmc.validatePath(
os.path.join(
xbmc.translatePath(filepath),
file_
)
)).decode("UTF-8"))):
return self._get_legal_filepath(title, url, id_ + 1)
# return final path
return xbmc.makeLegalFilename(xbmc.validatePath(
os.path.join(
xbmc.translatePath(filepath),
file_
)
)).decode("UTF-8")
开发者ID:nuka1195,项目名称:plugin.video.movie_trailers,代码行数:49,代码来源:player.py
示例8: viewTallImage
def viewTallImage(image_url, width, height):
log( 'viewTallImage %s: %sx%s' %(image_url, width, height))
#image_url=unescape(image_url) #special case for handling reddituploads urls
#log( 'viewTallImage %s: %sx%s' %(image_url, width, height))
#useWindow=xbmcgui.WindowDialog()
useWindow=xbmcgui.WindowXMLDialog('slideshow05.xml', addon_path)
#useWindow.setCoordinateResolution(1)
#screen_w=useWindow.getHeight() #1280
#screen_h=useWindow.getWidth() #720
screen_w=1920
screen_h=1080
log('screen %dx%d'%(screen_w,screen_h))
try:
w=int(float(width))
h=int(float(height))
ar=float(w/h)
resize_percent=float(screen_w)/w
if w > screen_w:
new_h=int(h*resize_percent)
else:
if abs( h - screen_h) < ( screen_h / 10 ): #if the image height is about 10 percent of the screen height, zoom it a bit
new_h=screen_h*2
elif h < screen_h:
new_h=screen_h
else:
new_h=h
log( ' image=%dx%d resize_percent %f new_h=%d ' %(w,h, resize_percent, new_h))
loading_img = xbmc.validatePath('/'.join((addon_path, 'resources', 'skins', 'Default', 'media', 'srr_busy.gif' )))
slide_h=new_h-screen_h
log( ' slide_h=' + repr(slide_h))
#sy=0
#note: y-axis not accurate. 0 does not always indicate top of screen
img_control = xbmcgui.ControlImage(0, 0, screen_w, new_h, '', aspectRatio=2) #(values 0 = stretch (default), 1 = scale up (crops), 2 = scale down (black bars)
#img_control = useWindow.getControl( 101 )
img_loading = xbmcgui.ControlImage(screen_w-100, 0, 100, 100, loading_img, aspectRatio=2)
#the cached image is of lower resolution. we force nocache by using setImage() instead of defining the image in ControlImage()
img_control.setImage(image_url, False)
useWindow.addControls( [ img_loading, img_control])
#useWindow.addControl( img_control )
img_control.setPosition(0,0)
scroll_time=(int(h)/int(w))*20000
img_control.setAnimations( [
('conditional', "condition=true delay=6000 time=%d effect=slide start=0,-%d end=0,0 tween=sine easing=inout pulse=true" %( scroll_time, slide_h) ),
('conditional', "condition=true delay=0 time=4000 effect=fade start=0 end=100 " ) ,
] )
useWindow.doModal()
useWindow.removeControls( [img_control,img_loading] )
del useWindow
except Exception as e:
log(" EXCEPTION viewTallImage:="+ str( sys.exc_info()[0]) + " " + str(e) )
开发者ID:gedisony,项目名称:plugin.video.reddit_viewer,代码行数:60,代码来源:actions.py
示例9: walkTree
def walkTree(self,directory):
if(directory[-1:] == '/'):
directory = directory[:-1]
if(self.vfs.exists(directory + "/")):
dirs,files = self.vfs.listdir(directory)
#create all the subdirs first
for aDir in dirs:
dirPath = xbmc.validatePath(xbmc.translatePath(directory + "/" + aDir))
file_ext = aDir.split('.')[-1]
if(not dirPath in self.exclude_dir):
self.addFile("-" + dirPath)
#catch for "non directory" type files
shouldWalk = True
for s in file_ext:
if(s in self.not_dir):
shouldWalk = False
if(shouldWalk):
self.walkTree(dirPath)
#copy all the files
for aFile in files:
filePath = xbmc.translatePath(directory + "/" + aFile)
self.addFile(filePath)
开发者ID:robweber,项目名称:xbmcbackup,代码行数:31,代码来源:backup.py
示例10: hide_loading_indicator
def hide_loading_indicator(self):
bg_img = xbmc.validatePath("/".join((ADDON_PATH, "resources", "media", self.BACKGROUND_IMAGE)))
self.loading_control.setAnimations([("conditional", "effect=fade start=100 end=0 time=500 condition=true")])
self.background_control.setAnimations(
[("conditional", "effect=fade start=0 end=100 time=500 delay=500 condition=true")]
)
self.background_control.setImage(bg_img)
开发者ID:jspullar,项目名称:script.screensaver.multi_slideshow,代码行数:7,代码来源:screensaver.py
示例11: create_name
def create_name(self,zip_entry,sub_filename,subtitle_lang):
if self.temp:
name = "temp_sub"
else:
name = os.path.splitext( sub_filename )[0]
if (__addon__.getSetting( "lang_to_end" ) == "true"):
file_name = u"%s.%s%s" % ( name,
subtitle_lang,
os.path.splitext( zip_entry )[1] )
else:
file_name = u"%s%s" % ( name, os.path.splitext( zip_entry )[1] )
log( __name__ ,"Sub in Zip [%s], File Name [%s]" % (zip_entry,
file_name,))
ret_zip_entry = xbmc.validatePath(os.path.join(self.tmp_sub_dir,zip_entry)).decode("utf-8")
ret_file_name = xbmc.validatePath(os.path.join(self.sub_folder,file_name)).decode("utf-8")
return ret_zip_entry,ret_file_name
开发者ID:yurybubnov,项目名称:script.fansubs.subtitles,代码行数:16,代码来源:gui.py
示例12: get_sources
def get_sources():
results = []
result = eval(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Files.GetSources", "params": {"media": "video"}, "id": 1}'))
if 'sources' not in result['result']:
return results
sources = result['result']['sources']
sources = [ xbmc.validatePath(s['file']) for s in sources ]
for s in sources:
log("FOUND SOURCE: %s" % s, xbmc.LOGINFO)
if s.startswith('addons://'):
s = clean_path(s)
log("%s is an addon source, ignoring..." % s, xbmc.LOGINFO)
elif s.startswith('multipath://'):
log("%s is a multipath source, splitting and adding individuals..." % s, xbmc.LOGINFO)
s = s.replace('multipath://', '')
parts = s.split('/')
parts = [ f for f in parts ]
for b in parts:
if b:
b = clean_path(b)
log("%s is a straight forward source, adding.." % b, xbmc.LOGINFO)
results.append(b)
else:
s = clean_path(s)
log("%s is a straight forward source, adding..." % s, xbmc.LOGINFO)
results.append(s)
return results
开发者ID:verybadsoldier,项目名称:missing-movie-viewer,代码行数:31,代码来源:default.py
示例13: _fetch_tvshows_recommended
def _fetch_tvshows_recommended(self, request):
# First unplayed episode of recent played tvshows
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": {"properties": ["title", "studio", "thumbnail", "file"], "sort": {"order": "descending", "method": "lastplayed"}, "filter": {"field": "inprogress", "operator": "true", "value": ""}, "limits": {"end": %d}}, "id": 1}' %self.LIMIT)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
if json_response['result'].has_key('tvshows'):
self._clear_properties(request)
count = 0
for item in json_response['result']['tvshows']:
count += 1
json_query2 = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, "properties": ["title", "playcount", "plot", "season", "episode", "showtitle", "thumbnail", "fanart", "file", "lastplayed", "rating", "resume"], "sort": {"method": "episode"}, "filter": {"field": "playcount", "operator": "is", "value": "0"}, "limits": {"end": 1}}, "id": 1}' %item['tvshowid'])
json_query2 = unicode(json_query2, 'utf-8', errors='ignore')
json_response2 = simplejson.loads(json_query2)
if json_response2.has_key('result') and json_response2['result'] != None and json_response2['result'].has_key('episodes'):
for item2 in json_response2['result']['episodes']:
episode = ("%.2d" % float(item2['episode']))
season = "%.2d" % float(item2['season'])
rating = str(round(float(item2['rating']),1))
episodeno = "s%se%s" %(season,episode)
seasonthumb = ''
if item2['resume']['position'] > 0:
resume = "true"
played = '%s%%'%int((float(item2['resume']['position']) / float(item2['resume']['total'])) * 100)
else:
resume = "false"
played = '0%'
path = media_path(item['file'])
self.WINDOW.setProperty("%s.%d.Title" % (request, count), item2['title'])
self.WINDOW.setProperty("%s.%d.Episode" % (request, count), episode)
self.WINDOW.setProperty("%s.%d.EpisodeNo" % (request, count), episodeno)
self.WINDOW.setProperty("%s.%d.Season" % (request, count), season)
self.WINDOW.setProperty("%s.%d.Plot" % (request, count), item2['plot'])
self.WINDOW.setProperty("%s.%d.TVshowTitle" % (request, count), item2['showtitle'])
self.WINDOW.setProperty("%s.%d.Rating" % (request, count), rating)
self.WINDOW.setProperty("%s.%d.Thumb" % (request, count), item2['thumbnail'])
self.WINDOW.setProperty("%s.%d.Fanart" % (request, count), item2['fanart'])
self.WINDOW.setProperty("%s.%d.Poster" % (request, count), xbmc.validatePath(os.path.join(path, 'poster.jpg')))
self.WINDOW.setProperty("%s.%d.Banner" % (request, count), xbmc.validatePath(os.path.join(path, 'banner.jpg')))
self.WINDOW.setProperty("%s.%d.Logo" % (request, count), xbmc.validatePath(os.path.join(path, 'logo.png')))
self.WINDOW.setProperty("%s.%d.Clearart" % (request, count), xbmc.validatePath(os.path.join(path, 'clearart.png')))
self.WINDOW.setProperty("%s.%d.Studio" % (request, count), item['studio'][0])
self.WINDOW.setProperty("%s.%d.TvshowThumb" % (request, count), item['thumbnail'])
self.WINDOW.setProperty("%s.%d.SeasonThumb" % (request, count), seasonthumb)
self.WINDOW.setProperty("%s.%d.Resume" % (request, count), resume)
self.WINDOW.setProperty("%s.%d.Played" % (request, count), played)
self.WINDOW.setProperty("%s.%d.File" % (request, count), item2['file'])
self.WINDOW.setProperty("%s.%d.Path" % (request, count), path)
开发者ID:BigNoid,项目名称:service.skin.widgets,代码行数:47,代码来源:default.py
示例14: translatePath
def translatePath( filepath ):
# translate any special:// paths
filepath = xbmc.translatePath( xbmc.validatePath( filepath ) )
# if windows and samba convert to a proper format for shutil and os modules
if ( os.environ.get( "OS", "win32" ) == "win32" and filepath.startswith( "smb://" ) ):
filepath = filepath.replace( "/", "\\" ).replace( "smb:", "" )
# return result
return filepath
开发者ID:nuka1195,项目名称:weather.weather.com_plus,代码行数:8,代码来源:utils.py
示例15: _get_root_dir
def _get_root_dir( self, path ):
# get current working directory, we need to reset sys.argv[ 0 ] to a plugin for weather plugins as they aren't run as plugins, but they are categorized as plugins
cwd = os.path.dirname( xbmc.validatePath( path.replace( "Q:\\plugins\\weather\\", "plugin://weather/" ) ) )
# check if we're at root folder of addon
if ( not os.path.isfile( os.path.join( xbmc.translatePath( cwd ), "addon.xml" ) ) ):
# we're not at root, assume resources/lib/
cwd = os.path.dirname( os.path.dirname( cwd ) )
# return result
return cwd
开发者ID:Rocky5,项目名称:XBMC4Kids,代码行数:9,代码来源:xbmcaddon.py
示例16: init_global_controls
def init_global_controls(self):
self.log("init_global_controls start")
loading_img = xbmc.validatePath("/".join((ADDON_PATH, "resources", "media", "loading.gif")))
self.loading_control = ControlImage(576, 296, 128, 128, loading_img)
self.preload_control = ControlImage(-1, -1, 1, 1, "")
self.background_control = ControlImage(0, 0, 1280, 720, "")
self.global_controls = [self.preload_control, self.background_control, self.loading_control]
self.xbmc_window.addControls(self.global_controls)
self.log("init_global_controls end")
开发者ID:jspullar,项目名称:script.screensaver.multi_slideshow,代码行数:9,代码来源:screensaver.py
示例17: _get_folder_images
def _get_folder_images(self, path):
self.log('_get_folder_images started with path: %s' % repr(path))
dirs, files = xbmcvfs.listdir(path)
images = [
xbmc.validatePath(path + f) for f in files
if f.lower()[-3:] in ('jpg', 'png')
]
if addon.getSetting('recursive') == 'true':
for directory in dirs:
if directory.startswith('.'):
continue
images.extend(
self._get_folder_images(
xbmc.validatePath('/'.join((path, directory, '')))
)
)
self.log('_get_folder_images ends')
return images
开发者ID:raven42,项目名称:script.screensaver.multi_slideshow,代码行数:18,代码来源:screensaver.py
示例18: findTrack
def findTrack(self, artistname, trackname):
# Find the song
chars0 = trackname[0].lower() + trackname[1].lower()
chars1 = trackname[0].upper() + trackname[1].lower()
chars2 = trackname[0].lower() + trackname[1].upper()
chars3 = trackname[0].upper() + trackname[1].upper()
req = {
"jsonrpc": "2.0",
"method": "AudioLibrary.GetSongs",
"id": "libSongs",
"params": {
"properties": ["artist", "duration", "album", "title", "file", "thumbnail", "fanart", "track"],
"limits": {"start": 0, "end": 1000},
"sort": {"order": "ascending", "method": "track", "ignorearticle": True},
"filter": {"and": [
{"field": "artist", "operator": "is", "value": artistname.encode('utf-8')},
{"or": [
#{"field": "title", "operator": "is", "value": trackname.lower().encode('utf-8')}
{"field": "title", "operator": "startswith", "value": chars0.encode('utf-8')},
{"field": "title", "operator": "startswith", "value": chars1.encode('utf-8')},
{"field": "title", "operator": "startswith", "value": chars2.encode('utf-8')},
{"field": "title", "operator": "startswith", "value": chars3.encode('utf-8')},
]}
]}
}
}
rpcresp = xbmc.executeJSONRPC(json.dumps(req))
# xbmc.log(str(rpcresp))
rpcresp = json.loads(rpcresp)
found = 0 < int(rpcresp['result']['limits']['end'])
ret = None
#strInd = ' '
if found:
# xbmc.log(str(rpcresp))
trackname_stripped = strip_accents(trackname.strip().lower())
for s in rpcresp['result']['songs']:
if trackname_stripped == strip_accents(s['title'].strip().lower()):
path = xbmc.translatePath(s['file'])
path = xbmc.validatePath(path)
if os.path.exists(path):
ret = s
break
log("Found in library, but file doesn't exist: %s" % path)
xbmc.executebuiltin('Notification(%s,%s, 1000)' % ("File doesn't exist", os.path.basename(path)))
#if artistname.lower() <> ret['artist'][0].lower() or trackname.lower() <> ret['title'].lower():
#if ret is not None:
# strInd = '+++ '
# xbmc.log(strInd + str(artistname.encode('utf-8')) + " -- " + str(trackname.encode('utf-8')))
# xbmc.log(' ' + str(ret['artist'][0].encode('utf-8')) + " -- " + str(ret['title'].encode('utf-8')))
#else:
#xbmc.log('NOT found track ' + str(artistname.encode('utf-8')) + " -- " + str(trackname.encode('utf-8')))
#xbmc.log(strInd + str(artistname.encode('utf-8')) + " -- " + str(trackname.encode('utf-8')))
return ret
开发者ID:wkia,项目名称:kodi-addon-repo,代码行数:57,代码来源:player.py
示例19: _get_folder_images
def _get_folder_images(self, path):
self.log('_get_folder_images started with path: %s' % repr(path))
_, files = xbmcvfs.listdir(path)
images = [
xbmc.validatePath(path + f) for f in files
if f.lower()[-3:] in ('jpg', 'png')
]
self.log('_get_folder_images ends')
return images
开发者ID:gedisony,项目名称:repo-plugins,代码行数:10,代码来源:slideshow.py
示例20: scanFolder
def scanFolder(self, path):
#Scan set folder for images with png and jpg extension
self.log('scanFolder started with path: %s' % repr(path))
dirs, files = xbmcvfs.listdir(path)
images = [
xbmc.validatePath(path + f) for f in files
if f.lower()[-3:] in ('jpg', 'png')
]
if addon.getSetting('recursive') == 'true':
for directory in dirs:
if directory.startswith('.'):
continue
images.extend(
self.scanFolder(
xbmc.validatePath('/'.join((path, directory, '')))
)
)
self.log('scanFolder ends')
return images
开发者ID:reversTeam,项目名称:sualfreds-repo,代码行数:19,代码来源:screensaver.py
注:本文中的xbmc.validatePath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论