Python xbmc.translatePath() Examples
The following are 30
code examples of xbmc.translatePath().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xbmc
, or try the search function
.
Example #1
Source File: playutils.py From plugin.video.emby with GNU General Public License v3.0 | 6 votes |
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
Example #2
Source File: __init__.py From plugin.video.emby with GNU General Public License v3.0 | 6 votes |
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
Example #3
Source File: views.py From plugin.video.emby with GNU General Public License v3.0 | 6 votes |
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')))
Example #4
Source File: views.py From plugin.video.emby with GNU General Public License v3.0 | 6 votes |
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')))
Example #5
Source File: library.py From plugin.video.netflix with MIT License | 6 votes |
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)
Example #6
Source File: xbmclibrary.py From plugin.video.ustvvod with GNU General Public License v2.0 | 6 votes |
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")
Example #7
Source File: advancedfunctions.py From program.plexus with GNU General Public License v2.0 | 6 votes |
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()
Example #8
Source File: __init__.py From plugin.video.emby with GNU General Public License v3.0 | 6 votes |
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
Example #9
Source File: ResetDatabase.py From script.tvguide.fullscreen with GNU General Public License v2.0 | 6 votes |
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
Example #10
Source File: sutils.py From plugin.video.sosac.ph with GNU General Public License v2.0 | 6 votes |
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
Example #11
Source File: utils.py From plugin.video.emby with GNU General Public License v3.0 | 6 votes |
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)
Example #12
Source File: webservice.py From plugin.video.emby with GNU General Public License v3.0 | 6 votes |
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()
Example #13
Source File: source.py From script.tvguide.fullscreen with GNU General Public License v2.0 | 6 votes |
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()
Example #14
Source File: am_upnext_notifier.py From plugin.video.netflix with MIT License | 6 votes |
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
Example #15
Source File: ResizeLogos.py From script.tvguide.fullscreen with GNU General Public License v2.0 | 6 votes |
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)
Example #16
Source File: acecore.py From program.plexus with GNU General Public License v2.0 | 5 votes |
def _get_skin_resolution(self): 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] return int(res.attrib["width"]), int(res.attrib["height"])
Example #17
Source File: library_updater.py From plugin.video.netflix with MIT License | 5 votes |
def update_kodi_library(self, data=None): # pylint: disable=unused-argument # Update only the elements in the addon export folder for faster processing with a large library (on Kodi 18.x) # If a scan is already in progress, the scan is delayed until onScanFinished event if not self.scan_in_progress: common.debug('Kodi library update requested from library auto-update') self.scan_awaiting = False common.scan_library( makeLegalFilename( xbmc.translatePath( kodi_library.library_path()))) else: self.scan_awaiting = True
Example #18
Source File: addon.py From plugin.video.sparkle with GNU General Public License v3.0 | 5 votes |
def get_profile(self): ''' Returns the full path to the addon profile directory (useful for storing files needed by the addon such as cookies). ''' return xbmc.translatePath(self.addon.getAddonInfo('profile'))
Example #19
Source File: vpnplatform.py From service.vpn.manager with GNU General Public License v2.0 | 5 votes |
def getTestFilePath(): # Return the full filename for the VPN log file # It's platform dependent, but can be forced to the Kodi log location use_kodi_dir = xbmcaddon.Addon(getID()).getSetting("openvpn_log_location") p = getPlatform() if p == platforms.WINDOWS or use_kodi_dir == "true" : # Putting this with the other logs on Windows return xbmc.translatePath("special://logpath/command_test.txt") if p == platforms.LINUX or p == platforms.RPI: # This should be a RAM drive so doesn't wear the media return "/run/command_text.txt" # **** ADD MORE PLATFORMS HERE **** return ""
Example #20
Source File: vpnplatform.py From service.vpn.manager with GNU General Public License v2.0 | 5 votes |
def getVPNLogFilePath(): # Return the full filename for the VPN log file # It's platform dependent, but can be forced to the Kodi log location use_kodi_dir = xbmcaddon.Addon(getID()).getSetting("openvpn_log_location") p = getPlatform() if p == platforms.WINDOWS or use_kodi_dir == "true" : # Putting this with the other logs on Windows return xbmc.translatePath("special://logpath/openvpn.log") if p == platforms.LINUX or p == platforms.RPI: # This should be a RAM drive so doesn't wear the media return "/run/openvpn.log" # **** ADD MORE PLATFORMS HERE **** return ""
Example #21
Source File: db_utils.py From plugin.video.netflix with MIT License | 5 votes |
def get_local_db_path(db_filename): # First ensure database folder exists db_folder = g.py2_decode(xbmc.translatePath(os.path.join(g.DATA_PATH, 'database'))) if not folder_exists(db_folder): xbmcvfs.mkdirs(db_folder) return os.path.join(db_folder, db_filename)
Example #22
Source File: library_items.py From plugin.video.netflix with MIT License | 5 votes |
def _write_nfo_file(nfo_data, nfo_filename): """Write the NFO file""" filehandle = xbmcvfs.File(xbmc.translatePath(nfo_filename), 'wb') try: filehandle.write(bytearray('<?xml version=\'1.0\' encoding=\'UTF-8\'?>'.encode('utf-8'))) filehandle.write(bytearray(ET.tostring(nfo_data, encoding='utf-8', method='xml'))) finally: filehandle.close()
Example #23
Source File: advancedfunctions.py From program.plexus with GNU General Public License v2.0 | 5 votes |
def delete_advancedxml(): userdatapath = xbmc.translatePath(os.path.join('special://home/userdata'.decode('utf-8'),''.decode('utf-8'))) advancedsettings_var = os.path.join(userdatapath,'advancedsettings.xml') advancedsettingsbackup_var = os.path.join(userdatapath,'advancedsettingsbackup.xml') xbmcvfs.delete(advancedsettings_var) mensagemok(translate(40000),translate(40066)) xbmc.executebuiltin("Container.Refresh")
Example #24
Source File: advancedfunctions.py From program.plexus with GNU General Public License v2.0 | 5 votes |
def recoverbackup_advancedxml(): userdatapath = xbmc.translatePath(os.path.join('special://home/userdata'.decode('utf-8'),''.decode('utf-8'))) advancedsettings_var = os.path.join(userdatapath,'advancedsettings.xml') advancedsettingsbackup_var = os.path.join(userdatapath,'advancedsettingsbackup.xml') xbmcvfs.delete(advancedsettings_var) xbmcvfs.rename(advancedsettingsbackup_var,advancedsettings_var) mensagemok(translate(40000),translate(40062)) xbmc.executebuiltin("Container.Refresh")
Example #25
Source File: advancedfunctions.py From program.plexus with GNU General Public License v2.0 | 5 votes |
def backup_advancedxml(): userdatapath = xbmc.translatePath(os.path.join('special://home/userdata'.decode('utf-8'),''.decode('utf-8'))) advancedsettings_var = os.path.join(userdatapath,'advancedsettings.xml') advancedsettingsbackup_var = os.path.join(userdatapath,'advancedsettingsbackup.xml') if xbmcvfs.exists(advancedsettingsbackup_var): xbmcvfs.delete(advancedsettingsbackup_var) xbmcvfs.copy(advancedsettings_var,advancedsettingsbackup_var) mensagemok(translate(40000),translate(40064)) xbmc.executebuiltin("Container.Refresh")
Example #26
Source File: advancedfunctions.py From program.plexus with GNU General Public License v2.0 | 5 votes |
def import_advancedxml(): userdatapath = xbmc.translatePath(os.path.join('special://home/userdata'.decode('utf-8'),''.decode('utf-8'))) advancedsettings_var = os.path.join(userdatapath,'advancedsettings.xml') advancedsettingsbackup_var = os.path.join(userdatapath,'advancedsettingsbackup.xml') if xbmcvfs.exists(advancedsettings_var): print("An advanced settings XML file already exists") if xbmcvfs.exists(advancedsettingsbackup_var): print("An advanced settings backup already exists") xbmcvfs.delete(advancedsettingsbackup_var) xbmcvfs.rename(advancedsettings_var,advancedsettingsbackup_var) advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"] advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"] index = xbmcgui.Dialog().select(translate(40185), advancedname) if index > -1: download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000)) mensagemok(translate(40000),translate(40060)) else: xbmcvfs.rename(advancedsettings_var,advancedsettingsbackup_var) advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"] advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"] index = xbmcgui.Dialog().select(translate(40185), advancedname) if index > -1: download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000)) mensagemok(translate(40000),translate(40060)) else: print("No advancedsettings.xml in the system yet") advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"] advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"] index = xbmcgui.Dialog().select(translate(40185), advancedname) if index > -1: download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000)) mensagemok(translate(40000),translate(40060)) xbmc.executebuiltin("Container.Refresh")
Example #27
Source File: util.py From romcollectionbrowser with GNU General Public License v2.0 | 5 votes |
def getAddonDataPath(): path = u'' path = convertToUnicodeString(xbmc.translatePath('special://profile/addon_data/%s' % (SCRIPTID))) if not os.path.exists(path): try: os.makedirs(path) except: path = '' return path
Example #28
Source File: cloudservice.py From ownCloud-for-KODI with GNU General Public License v2.0 | 5 votes |
def traverse(self, path, cacheType, folderID, savePublic, level): import os import xbmcvfs xbmcvfs.mkdir(path) folders = self.getFolderList(folderID) files = self.getMediaList(folderID,cacheType) if files: for media in files: filename = xbmc.translatePath(os.path.join(path, media.title+'.strm')) strmFile = open(filename, "w") strmFile.write(self.PLUGIN_URL+'?mode=streamURL&url=' + self.FILE_URL+ media.id +'\n') strmFile.close() if folders and level == 1: count = 1 progress = xbmcgui.DialogProgress() progress.create(self.addon.getLocalizedString(30000),self.addon.getLocalizedString(30036),'\n','\n') for folder in folders: max = len(folders) progress.update(count/max*100,self.addon.getLocalizedString(30036),folder.title,'\n') self.traverse( path+'/'+folder.title + '/',cacheType,folder.id,savePublic,0) count = count + 1 if folders and level == 0: for folder in folders: self.traverse( path+'/'+folder.title + '/',cacheType,folder.id,savePublic,0)
Example #29
Source File: main.py From bugatsinho.github.io with GNU General Public License v3.0 | 5 votes |
def isa_enable(): if addon_version('xbmc.python') < 2250: dialog.ok(addonName, 'System is not compatible with inputstream type addons') return try: enabled = addon_details('inputstream.adaptive').get('enabled') except Exception: enabled = False try: if enabled: #dialog.notification(addonName, 'Inputstream adaptive addon is already enabled') return else: xbmc_path = os.path.join('special://xbmc', 'addons', 'inputstream.adaptive') home_path = os.path.join('special://home', 'addons', 'inputstream.adaptive') if os.path.exists(xbmc.translatePath(xbmc_path)) or os.path.exists(xbmc.translatePath(home_path)): yes = dialog.yesno(addonName, 'Inputstream adaptive (DASH) is not enabled. Do you to enabled it now?', yeslabel='YES', nolabel='NO') if yes: enable_addon('inputstream.adaptive') dialog.notification(addonName, 'Success') else: try: xbmc.executebuiltin('InstallAddon(inputstream.adaptive)') except Exception: dialog.ok(addonName, line1='Could not install requested addon,' 'to install it you have to try another way,' ' such as your distribution\'s repositories.') return except Exception: dialog.notification(addonName, 'Inputstream adaptive addon could not be enabled')
Example #30
Source File: playerMP3.py From bugatsinho.github.io with GNU General Public License v3.0 | 5 votes |
def __init__(self, title, artist, album, track, url, filename): super(Downloader, self).__init__() self._signal = False self.title = title self.artist = artist self.album = album self.track = int(track) self.url = url self.filename = xbmc.translatePath(filename) self.complete = False