本文整理汇总了Python中xbmcswift2.xbmcvfs.exists函数的典型用法代码示例。如果您正苦于以下问题:Python exists函数的具体用法?Python exists怎么用?Python exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: 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)")
示例3: add_channel_to_library
def add_channel_to_library(library_folder, channel, play_plugin=None):
changed = False
# create channel folder
channel_folder = os.path.join(library_folder, str(channel) + "/")
if not xbmcvfs.exists(channel_folder):
try:
xbmcvfs.mkdir(channel_folder)
except:
pass
# create nfo file
nfo_filepath = os.path.join(channel_folder, str(channel) + ".nfo")
if not xbmcvfs.exists(nfo_filepath):
changed = True
nfo_file = xbmcvfs.File(nfo_filepath, "w")
content = "%s" % str(channel)
nfo_file.write(content)
nfo_file.close()
# Create play with file
if play_plugin is not None:
player_filepath = os.path.join(channel_folder, "player.info")
player_file = xbmcvfs.File(player_filepath, "w")
content = "{0}".format(play_plugin)
player_file.write(content)
player_file.close()
# create strm file
strm_filepath = os.path.join(channel_folder, str(channel) + ".strm")
if not xbmcvfs.exists(strm_filepath):
changed = True
strm_file = xbmcvfs.File(strm_filepath, "w")
content = plugin.url_for("live_play", channel=channel, program="None", language="en", mode="library")
strm_file.write(content)
strm_file.close()
return changed
示例4: batch_add_movies_to_library
def batch_add_movies_to_library(library_folder, id):
if id == None:
return
changed = False
movie_folder = os.path.join(library_folder, str(id) + "/")
if not xbmcvfs.exists(movie_folder):
try:
xbmcvfs.mkdir(movie_folder)
except:
pass
nfo_filepath = os.path.join(movie_folder, str(id) + ".nfo")
if not xbmcvfs.exists(nfo_filepath):
changed = True
nfo_file = xbmcvfs.File(nfo_filepath, "w")
content = "http://www.imdb.com/title/%s/" % str(id)
nfo_file.write(content)
nfo_file.close()
strm_filepath = os.path.join(movie_folder, str(id) + ".strm")
src = "imdb"
if not xbmcvfs.exists(strm_filepath):
changed = True
strm_file = xbmcvfs.File(strm_filepath, "w")
try:
content = plugin.url_for("movies_play", src=src, id=id, mode="library")
strm_file.write(content)
strm_file.close()
except:
pass
if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"):
xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")
if xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"):
xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
return changed
示例5: batch_add_tvshows_to_library
def batch_add_tvshows_to_library(library_folder, show):
id = show['id']
showname = to_utf8(show['seriesname'])
playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
if not xbmcvfs.exists(playlist_folder):
try: xbmcvfs.mkdir(playlist_folder)
except: dialogs.notify(msg=_('Creation of [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] Playlist Folder'), title=_('Failed'), delay=5000, image=get_icon_path("lists"))
playlist_file = os.path.join(playlist_folder, id+".xsp")
if not xbmcvfs.exists(playlist_file):
playlist_file = xbmcvfs.File(playlist_file, 'w')
content = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><smartplaylist type="tvshows"><name>%s</name><match>all</match><rule field="path" operator="contains"><value>%s%s</value></rule><rule field="playcount" operator="is"><value>0</value></rule><order direction="ascending">numepisodes</order></smartplaylist>' % (showname, plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, unicode).replace('special://profile',''), str(id))
playlist_file.write(str(content))
playlist_file.close()
show_folder = os.path.join(library_folder, str(id)+'/')
if not xbmcvfs.exists(show_folder):
try: xbmcvfs.mkdir(show_folder)
except: pass
player_filepath = os.path.join(show_folder, 'player.info')
player_file = xbmcvfs.File(player_filepath, 'w')
content = "default"
player_file.write(content)
player_file.close()
nfo_filepath = os.path.join(show_folder, 'tvshow.nfo')
if not xbmcvfs.exists(nfo_filepath):
nfo_file = xbmcvfs.File(nfo_filepath, 'w')
content = "http://thetvdb.com/index.php?tab=series&id=%s" % str(id)
nfo_file.write(content)
nfo_file.close()
clean_needed = True
return clean_needed
示例6: library_tv_remove_strm
def library_tv_remove_strm(show, folder, id, season, episode):
enc_season = ('Season %s' % season).translate(None, '\/:*?"<>|').strip('.')
enc_name = 'S%02dE%02d' % (season, episode)
season_folder = os.path.join(folder, enc_season)
stream_file = os.path.join(season_folder, enc_name + "%s" % plugin.get_setting(SETTING_LIBRARY_TAGS, unicode) + '.strm')
if xbmcvfs.exists(stream_file):
xbmcvfs.delete(stream_file)
while not xbmc.abortRequested and xbmcvfs.exists(stream_file):
xbmc.sleep(1000)
a,b = xbmcvfs.listdir(season_folder)
if not a and not b:
xbmcvfs.rmdir(season_folder)
return True
return False
示例7: playlist_folders_setup
def playlist_folders_setup():
movies_playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER)
if not xbmcvfs.exists(movies_playlist_folder):
xbmcvfs.mkdir(movies_playlist_folder)
elif xbmcvfs.exists(movies_playlist_folder):
plugin.notify(msg="Movie playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
else:
plugin.notify(msg="Movie playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
tv_playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER)
if not xbmcvfs.exists(tv_playlist_folder):
xbmcvfs.mkdir(tv_playlist_folder)
elif xbmcvfs.exists(tv_playlist_folder):
plugin.notify(msg="TVShow playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
else:
plugin.notify(msg="TVShow playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
music_playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER)
if not xbmcvfs.exists(music_playlist_folder):
xbmcvfs.mkdir(music_playlist_folder)
elif xbmcvfs.exists(music_playlist_folder):
plugin.notify(msg="Music playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
else:
plugin.notify(msg="Music playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
live_playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER)
if not xbmcvfs.exists(live_playlist_folder):
xbmcvfs.mkdir(live_playlist_folder)
elif xbmcvfs.exists(live_playlist_folder):
plugin.notify(msg="Live playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
else:
plugin.notify(msg="Live playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
plugin.notify(msg="Playlists folder creation", title="Completed", delay=1000, image=get_icon_path("lists"))
return True
示例8: auto_tvshows_setup
def auto_tvshows_setup(library_folder):
if library_folder[-1] != "/": library_folder += "/"
playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
if plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
if not xbmcvfs.exists(library_folder):
try:
xbmcvfs.mkdir(library_folder)
source_thumbnail = get_icon_path("tv")
source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("TV shows")
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)
return True
except: False
示例9: export_tv_library
def export_tv_library():
folder_path = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, unicode)
if not xbmcvfs.exists(folder_path): return dialogs.notify(msg='TVShows folder', title='Absent', delay=5000, image=get_icon_path("tv"))
ids = ""
shows = xbmcvfs.listdir(folder_path)[0]
if len(shows) < 1: return dialogs.notify(msg='TVShows folder', title='Empty', delay=5000, image=get_icon_path("tv"))
else :
for show in shows: ids = ids + str(show) + '\n'
shows_backup_file_path = "special://profile/addon_data/plugin.video.metalliq/shows_to_add.bak"
if xbmcvfs.exists(shows_backup_file_path): os.remove(xbmc.translatePath(shows_backup_file_path))
if not xbmcvfs.exists(shows_backup_file_path):
batch_add_file = xbmcvfs.File(shows_backup_file_path, 'w')
batch_add_file.write(ids)
batch_add_file.close()
dialogs.notify(msg="TVShows", title="Backed up", delay=5000, image=get_icon_path("tv"))
示例10: export_movies_library
def export_movies_library():
folder_path = plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)
if not xbmcvfs.exists(folder_path): return dialogs.notify(msg='Movies folder', title='Absent', delay=5000, image=get_icon_path("movies"))
ids = ""
movies = xbmcvfs.listdir(folder_path)[0]
if len(movies) < 1: return dialogs.notify(msg='Movies folder', title='Empty', delay=5000, image=get_icon_path("movies"))
else :
for movie in movies: ids = ids + str(movie) + '\n'
movies_backup_file_path = "special://profile/addon_data/plugin.video.metalliq/movies_to_add.bak"
if xbmcvfs.exists(movies_backup_file_path): os.remove(xbmc.translatePath(movies_backup_file_path))
if not xbmcvfs.exists(movies_backup_file_path):
batch_add_file = xbmcvfs.File(movies_backup_file_path, 'w')
batch_add_file.write(ids)
batch_add_file.close()
dialogs.notify(msg="Movies", title="Backed up", delay=5000, image=get_icon_path("movies"))
示例11: update_folder
def update_folder(self, details, folder):
"""
:type details: Details
:type folder: Folder
"""
media_path = self.get_media_path(details.section, details.title)
if not direxists(media_path):
self.log.info("Creating library folder: %s", media_path)
xbmcvfs.mkdir(media_path)
else:
self.log.info("Updating library folder: %s", media_path)
self.storage[folder.id] = (details.media_id, media_path, details.section)
files = folder.files
""" :type : list of File """
for f in files:
file_path = os.path.join(media_path, self.get_file_name(folder.id, f.title))
if not xbmcvfs.exists(file_path):
self.log.info("Adding file: %s", file_path)
fp = xbmcvfs.File(file_path, 'w')
can_mark_watched = len(files) == 1 and not details.section.is_series()
url = plugin.url_for('play_file', section=details.section.filter_val,
media_id=details.media_id, url=f.link,
title=f.title, can_mark_watched=int(can_mark_watched))
fp.write(ensure_str(url))
fp.close()
return media_path
示例12: update_library
def update_library():
import_tvdb()
folder_path = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)
if not xbmcvfs.exists(folder_path):
return
# get library folder
library_folder = setup_library(folder_path)
# get shows in library
try:
shows = xbmcvfs.listdir(library_folder)[0]
except:
shows = []
# update each show
clean_needed = False
updated = 0
for id in shows:
id = int(id)
# add to library
with tvdb.session.cache_disabled():
if add_tvshow_to_library(library_folder, tvdb[id]):
clean_needed = True
updated += 1
if clean_needed:
set_property("clean_library", 1)
# start scan
if updated > 0:
scan_library()
示例13: __init__
def __init__(self, name, version=None):
self.name = name
self.version = version or self.find_last_version(name)
self.conn = None
if not xbmcvfs.exists(self.full_path):
raise MediaDatabaseException("KODI database '%s', %s not found" %
(self.name, "version %d" % self.version if self.version else "last version"))
示例14: library_tv_strm
def library_tv_strm(show, folder, id, season, episode):
# Create season folder
enc_season = ('Season %s' % season).translate(None, '\/:*?"<>|').strip('.')
folder = os.path.join(folder, enc_season)
try:
xbmcvfs.mkdir(folder)
except:
pass
# Create episode strm
enc_name = 'S%02dE%02d' % (season, episode)
stream = os.path.join(folder, enc_name + '.strm')
if not xbmcvfs.exists(stream):
file = xbmcvfs.File(stream, 'w')
content = plugin.url_for("tv_play", id=id, season=season, episode=episode, mode='library')
file.write(str(content))
file.close()
if plugin.get_setting(SETTING_LIBRARY_SET_DATE, converter=bool):
try:
firstaired = show[season][episode]['firstaired']
t = date_to_timestamp(firstaired)
os.utime(stream, (t,t))
except:
pass
示例15: auto_movie_setup
def auto_movie_setup(library_folder):
if library_folder[-1] != "/":
library_folder += "/"
playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)
if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
# create folders
if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
if not xbmcvfs.exists(library_folder):
try:
xbmcvfs.mkdir(library_folder)
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 True
except:
False