Python xbmcvfs.copy() Examples

The following are 30 code examples of xbmcvfs.copy(). 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 xbmcvfs , or try the search function .
Example #1
Source File: db.py    From plugin.program.openwizard with GNU General Public License v3.0 6 votes vote down vote up
def fix_update():
    if os.path.exists(os.path.join(CONFIG.USERDATA, 'autoexec.py')):
        temp = os.path.join(CONFIG.USERDATA, 'autoexec_temp.py')
        if os.path.exists(temp):
            xbmcvfs.delete(temp)
        xbmcvfs.rename(os.path.join(CONFIG.USERDATA, 'autoexec.py'), temp)
    xbmcvfs.copy(os.path.join(CONFIG.PLUGIN, 'resources', 'libs', 'autoexec.py'),
                 os.path.join(CONFIG.USERDATA, 'autoexec.py'))
    dbfile = os.path.join(CONFIG.DATABASE, latest_db('Addons'))
    try:
        os.remove(dbfile)
    except:
        logging.log("Unable to remove {0}, Purging DB".format(dbfile))
        purge_db_file(dbfile)

    from resources.libs.common import tools
    tools.kill_kodi(over=True) 
Example #2
Source File: vpnproviders.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
def populateSupportingFromGit(vpn_provider):
    # Copy all files from download to the directory that are not .ovpn, ignoring the metadata
    try:
        filelist = getDownloadList(vpn_provider, "*")
        debugTrace("Copying supporting files into addon directory for " + vpn_provider)
        for file in filelist:
            if not file.endswith(".ovpn") and not file.endswith("METADATA.txt"):
                name = os.path.basename(file)
                fullname = getAddonPath(True, vpn_provider + "/" + name)
                xbmcvfs.copy(file, fullname)
                if not xbmcvfs.exists(fullname): raise IOError('Failed to copy supporting file ' + file + " to " + fullname)
        return True
    except Exception as e:
        errorTrace("vpnproviders.py", "Can't copy " + file + " for VPN " + vpn_provider)
        errorTrace("vpnproviders.py", str(e))
        return False 
Example #3
Source File: main.py    From plugin.video.iptv.recorder with GNU General Public License v3.0 6 votes vote down vote up
def convert(path):
    input = xbmcvfs.File(path,'rb')
    output = xbmcvfs.File(path.replace('.ts','.mp4'),'wb')
    error = open(xbmc.translatePath("special://profile/addon_data/plugin.video.iptv.recorder/errors.txt"),"w")

    cmd = [ffmpeg_location(),"-fflags","+genpts","-y","-i","-","-vcodec","copy","-acodec","copy","-f", "mpegts", "-"]
    p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=error, shell=windows())
    t = threading.Thread(target=read_thread,args=[p,output])
    t.start()

    while True:
        data = input.read(100000)
        log(("read",len(data)))
        if not data:
            break
        p.stdin.write(data)
    p.stdin.close()
    error.close() 
Example #4
Source File: vpnproviders.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
def copyUserDefinedFiles():    
    # Copy everything in the user directory to the addon directory
    infoTrace("vpnproviders.py", "Copying user defined files from userdata directory")
    source_path = getUserDataPath((user_def_str)+"/")
    dest_path = getAddonPath(True, user_def_str + "/")
    # Get the list of connection profiles and another list of strings to abuse for the selection screen    
    try:
        files = getUserDataList(user_def_str, "*")
        if len(files) == 0:
            errorTrace("vpnproviders.py", "No User Defined files available to copy from " + source_path)
            return False
        for file in files:
            name = file[file.rfind(getSeparator())+1:]
            dest_file = dest_path + getSeparator() + name
            xbmcvfs.copy(file, dest_file)
            if not xbmcvfs.exists(dest_file): raise IOError('Failed to copy user def file ' + file + " to " + dest_file)
        return True
    except Exception as e:
        errorTrace("vpnproviders.py", "Error copying files from " + source_path + " to " + dest_path)
        errorTrace("vpnproviders.py", str(e))
        return False 
Example #5
Source File: vpnplatform.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
def copySystemdFiles():
    # Delete any existing openvpn.service and copy openvpn service file to config directory
    service_source = getAddonPath(True, "openvpn.service")
    service_dest = getSystemdPath("system.d/openvpn.service")
    debugTrace("Copying openvpn.service " + service_source + " to " + service_dest)
    if not fakeSystemd():
        if xbmcvfs.exists(service_dest): xbmcvfs.delete(service_dest)
        xbmcvfs.copy(service_source, service_dest)
        if not xbmcvfs.exists(service_dest): raise IOError('Failed to copy service ' + service_source + " to " + service_dest)
    
    # Delete any existing openvpn.config and copy first VPN to openvpn.config
    config_source = sudo_setting = xbmcaddon.Addon(getID()).getSetting("1_vpn_validated")
    if service_source == "": errorTrace("vpnplatform.py", "Nothing has been validated")
    config_dest = getSystemdPath("openvpn.config")
    debugTrace("Copying openvpn.config " + config_source + " to " + config_dest)
    if not fakeSystemd():
        if xbmcvfs.exists(config_dest): xbmcvfs.delete(config_dest)
        xbmcvfs.copy(config_source, config_dest)
        if not xbmcvfs.exists(config_dest): raise IOError('Failed to copy service ovpn ' + config_source + " to " + config_dest) 
Example #6
Source File: util.py    From xbmc.service.pushbullet with GNU General Public License v3.0 6 votes vote down vote up
def youtubeDLDownload(self,vid,path,target=None):
        import YDStreamExtractor as StreamExtractor 
        import YDStreamUtils as StreamUtils    
        if not target: target = self.chooseDirectory()
        if not target: return
        
        with StreamUtils.DownloadProgress() as prog:
            try:
                StreamExtractor.disableDASHVideo(True)
                StreamExtractor.setOutputCallback(prog)
                result = StreamExtractor.downloadVideo(vid,path)
            finally:
                StreamExtractor.setOutputCallback(None)
        if not result and result.status != 'canceled':
                xbmcgui.Dialog().ok(T(32103),'[CR]',result.message)
        elif result:
            xbmcgui.Dialog().ok(T(32062),T(32104),'[CR]',result.filepath)
        if target:
            xbmcvfs.copy(result.filepath,os.path.join(target,os.path.basename(result.filepath)))
            xbmcvfs.delete(result.filepath) 
Example #7
Source File: service.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 6 votes vote down vote up
def set_indx_properties(self, dictionary):
        if not isinstance(dictionary, dict):
            return

        indxprops = set()
        for k, v in dictionary.items():
            if k in self.properties or k in _setprop_ratings or k in _setmain_artwork:
                continue
            try:
                v = v or ''
                self.set_property(k, v)
                indxprops.add(k)
            except Exception as exc:
                utils.kodi_log(u'k: {0} v: {1} e: {2}'.format(k, v, exc), 1)

        for k in (self.indxproperties - indxprops):
            self.clear_property(k)
        self.indxproperties = indxprops.copy() 
Example #8
Source File: reporting.py    From script.artwork.beef with MIT License 6 votes vote down vote up
def _rotate_file():
    newdate = ndate = pykodi.get_infolabel('System.Date(yyyy-mm-dd)')
    count = 0
    while _exists(newdate):
        count += 1
        newdate = ndate + '.' + str(count)
    if not xbmcvfs.copy(_get_filepath(), _get_filepath(newdate)):
        log("Could not copy latest report to new filename", xbmc.LOGWARNING, 'reporting')
        return False
    if not xbmcvfs.delete(_get_filepath()):
        log("Could not delete old copy of latest report", xbmc.LOGWARNING, 'reporting')
        return False

    # delete old reports
    _, files = xbmcvfs.listdir(settings.datapath)
    reportfiles = sorted(f[:-4] for f in files if f.startswith(REPORT_NAME))
    while len(reportfiles) > REPORT_COUNT:
        filename = reportfiles[0] + '.txt'
        if not xbmcvfs.delete(settings.datapath + filename):
            log("Could not delete old report '{0}'".format(filename), xbmc.LOGWARNING, 'reporting')
            return False
        del reportfiles[0]
    report_startup()
    return True 
Example #9
Source File: dbupdate.py    From romcollectionbrowser with GNU General Public License v2.0 6 votes vote down vote up
def download_thumb(self, thumburl, destfilename):
        log.info("begin download_thumb using requests module: thumburl = %s" % thumburl)

        # Download file to tmp folder
        tmp = util.joinPath(util.getTempDir(), os.path.basename(destfilename))

        log.info("download_thumb: start downloading to temp file: %s" % tmp)
        response = requests.get(thumburl, headers=WebScraper._headers, stream=True)
        log.info("download_thumb: status code = %s" % response.status_code)
        if response.status_code != 200:
            log.info("download_thumb: invalid response status code. Can't download image.")
            return

        with open(tmp, 'wb') as f:
            response.raw.decode_content = True
            shutil.copyfileobj(response.raw, f)

        log.info("download_thumb: copy from temp file to final destination: %s" % destfilename)

        # Copy from the tmp folder to the target location
        xbmcvfs.copy(tmp, destfilename)
        xbmcvfs.delete(tmp)
        log.info("end download_thumb") 
Example #10
Source File: launcher.py    From romcollectionbrowser with GNU General Public License v2.0 6 votes vote down vote up
def __copyLauncherScriptsToUserdata(self):
        log.info('__copyLauncherScriptsToUserdata')

        oldBasePath = os.path.join(util.getAddonInstallPath(), 'resources', 'scriptfiles')
        newBasePath = os.path.join(util.getAddonDataPath(), 'scriptfiles')

        files = []
        # Copy applaunch shell script/batch file
        if self.env == 'win32':
            files.append('applaunch.bat')
        else:
            files.append('applaunch.sh')

        # Copy VBS files
        if self.env == 'win32' and __addon__.getSetting(util.SETTING_RCB_USEVBINSOLOMODE).lower() == 'true':
            files += ['applaunch-vbs.bat', 'LaunchKodi.vbs', 'Sleep.vbs']

        for f in files:
            if not xbmcvfs.exists(os.path.join(newBasePath, f)):
                log.debug("Copying file {0} from {1} to {2}".format(f, oldBasePath, newBasePath))
                if not xbmcvfs.copy(os.path.join(oldBasePath, f), os.path.join(newBasePath, f)):
                    log.warn("Error copying file") 
Example #11
Source File: advancedsettings.py    From script.artwork.beef with MIT License 5 votes vote down vote up
def restore_backup():
    if xbmcvfs.exists(FILENAME_BAK):
        xbmcvfs.copy(FILENAME_BAK, FILENAME)
        xbmcvfs.delete(FILENAME_BAK)
        result = xbmcvfs.exists(FILENAME)
        if result:
            xbmcgui.Dialog().notification("Artwork Beef", L(RESTORE_SUCCESSFUL))
        else:
            xbmcgui.Dialog().notification("Artwork Beef", L(RESTORE_UNSUCCESSFUL), xbmc.LOGWARNING)
        return result
    log("advancedsettings.xml.beef.bak doesn't exist, can't restore backup", xbmc.LOGWARNING)
    return False 
Example #12
Source File: backup.py    From plugin.program.openwizard with GNU General Public License v3.0 5 votes vote down vote up
def _backup_info(self, name, extractsize, programs, video, music, picture, repos, scripts, binaries):
        backup_path = CONFIG.MYBUILDS
        zipname = name + '.zip'
        txtname = name + '.txt'
        backup_zip = os.path.join(backup_path, zipname)
        temp_txt = os.path.join(CONFIG.PACKAGES, txtname)
        info_txt = os.path.join(backup_path, txtname)
        
        _skin_root = xbmc.translatePath('special://skin/')
        _skin_id = os.path.basename(os.path.normpath(_skin_root))
        _skin = xbmcaddon.Addon(_skin_id)
        _skin_name = xbmc.translatePath(_skin.getAddonInfo('name'))

        with open(temp_txt, 'w') as f:
            f.write('name="{0}"\n'.format(name))
            f.write('extracted="{0}"\n'.format(extractsize))
            f.write('zipsize="{0}"\n'.format(os.path.getsize(backup_zip)))
            f.write('skin="{0}"\n'.format(_skin_name))
            f.write('created="{0}"\n'.format(tools.get_date(formatted=True)))
            f.write('programs="{0}"\n'.format(', '.join(programs)) if len(programs) > 0 else 'programs="none"\n')
            f.write('video="{0}"\n'.format(', '.join(video)) if len(video) > 0 else 'video="none"\n')
            f.write('music="{0}"\n'.format(', '.join(music)) if len(music) > 0 else 'music="none"\n')
            f.write('picture="{0}"\n'.format(', '.join(picture)) if len(picture) > 0 else 'picture="none"\n')
            f.write('repos="{0}"\n'.format(', '.join(repos)) if len(repos) > 0 else 'repos="none"\n')
            f.write('scripts="{0}"\n'.format(', '.join(scripts)) if len(scripts) > 0 else 'scripts="none"\n')
            f.write('binaries="{0}"\n'.format(', '.join(binaries)) if len(binaries) > 0 else 'binaries="none"\n')
            
        xbmcvfs.copy(temp_txt, info_txt)
        xbmcvfs.delete(temp_txt) 
Example #13
Source File: advancedsettings.py    From script.artwork.beef with MIT License 5 votes vote down vote up
def save_backup():
    if xbmcvfs.exists(FILENAME):
        xbmcvfs.copy(FILENAME, FILENAME_BAK)
        result = xbmcvfs.exists(FILENAME_BAK)
        if result:
            xbmcgui.Dialog().notification("Artwork Beef", L(BACKUP_SUCCESSFUL))
        else:
            xbmcgui.Dialog().notification("Artwork Beef", L(BACKUP_UNSUCCESSFUL), xbmc.LOGWARNING)
        return result
    log("advancedsettings.xml doesn't exist, can't save backup", xbmc.LOGNOTICE)
    return True 
Example #14
Source File: utils.py    From plugin.video.emby with GNU General Public License v3.0 5 votes vote down vote up
def unzip_file(path, dest):

    ''' Unzip specific file. Path should start with zip://
    '''
    xbmcvfs.copy(path, dest)
    LOG.debug("unzip: %s to %s", path, dest) 
Example #15
Source File: filemanager.py    From script.artwork.beef with MIT License 5 votes vote down vote up
def recyclefile(filename):
    firstdir = utils.parent_dir(filename)
    directory = TEMP_DIR
    pathsep = utils.get_pathsep(directory)
    if firstdir in ('extrafanart', 'extrathumbs'):
        directory += utils.parent_dir(os.path.dirname(filename)) + pathsep
    directory += firstdir
    if not xbmcvfs.exists(directory):
        xbmcvfs.mkdirs(directory)
    recycled_filename = directory + pathsep + os.path.basename(filename)
    if not xbmcvfs.copy(filename, recycled_filename):
        raise FileError(L(CANT_WRITE_TO_FILE).format(recycled_filename)) 
Example #16
Source File: util.py    From xbmc.service.pushbullet with GNU General Public License v3.0 5 votes vote down vote up
def downloadURL(self,targetdir,url,fname=None,final_target_dir=None):
        if not fname:
            fname = os.path.basename(urlparse.urlsplit(url)[2])
            if not fname: fname = 'file'
        f,e = os.path.splitext(fname)
        fn = f
        ct=0
        while ct < 1000:
            ct += 1
            path = os.path.join(targetdir,fn + e)
            finalPath = os.path.join(final_target_dir,fn + e)
            if not xbmcvfs.exists(path): break
            fn = f + str(ct)
        else:
            raise Exception
        
        try:
            self.current = 0
            self.display = '{0}: {1}'.format(T(32100),os.path.basename(path))
            self.prog.update(0,self.message,self.display)
            t,ftype = self.getUrlFile(url,path,callback=self.progCallback) #@UnusedVariable
        except:
            ERROR('DOWNLOAD URL ERROR')
            self.prog.close()
            return (None,'')
        finally:
            self.prog.close()
        if final_target_dir:
            xbmcvfs.copy(path,finalPath)
            xbmcvfs.delete(path)
        return (os.path.basename(path),ftype) 
Example #17
Source File: filetools.py    From addon with GNU General Public License v3.0 5 votes vote down vote up
def rename(path, new_name, silent=False, strict=False, vfs=True):
    """
    Renombra un archivo o carpeta
    @param path: ruta del fichero o carpeta a renombrar
    @type path: str
    @param new_name: nuevo nombre
    @type new_name: str
    @rtype: bool
    @return: devuelve False en caso de error
    """
    path = encode(path)
    try:
        if xbmc_vfs and vfs:
            path_end = path
            if path_end.endswith('/') or path_end.endswith('\\'):
                path_end = path_end[:-1]
            dest = encode(join(dirname(path_end), new_name))
            result = xbmcvfs.rename(path, dest)
            if not result and not strict:
                logger.error("ERROR al RENOMBRAR el archivo: %s.  Copiando y borrando" % path)
                if not silent:
                    dialogo = platformtools.dialog_progress("Copiando archivo", "")
                result = xbmcvfs.copy(path, dest)
                if not result:
                    return False
                xbmcvfs.delete(path)
            return bool(result)
        elif path.lower().startswith("smb://"):
            new_name = encode(new_name, True)
            samba.rename(path, join(dirname(path), new_name))
        else:
            new_name = encode(new_name, False)
            os.rename(path, os.path.join(os.path.dirname(path), new_name))
    except:
        logger.error("ERROR al renombrar el archivo: %s" % path)
        if not silent:
            logger.error(traceback.format_exc())
            platformtools.dialog_notification("Error al renombrar", path)
        return False
    else:
        return True 
Example #18
Source File: main.py    From plugin.video.iptv.recorder with GNU General Public License v3.0 5 votes vote down vote up
def ffmpeg_location():
    ffmpeg_src = xbmc.translatePath(plugin.get_setting('ffmpeg'))

    if xbmc.getCondVisibility('system.platform.android'):
        ffmpeg_dst = '/data/data/%s/ffmpeg' % android_get_current_appid()

        if (plugin.get_setting('ffmpeg') != plugin.get_setting('ffmpeg.last')) or (not xbmcvfs.exists(ffmpeg_dst) and ffmpeg_src != ffmpeg_dst):
            xbmcvfs.copy(ffmpeg_src, ffmpeg_dst)
            plugin.set_setting('ffmpeg.last',plugin.get_setting('ffmpeg'))

        ffmpeg = ffmpeg_dst
    else:
        ffmpeg = ffmpeg_src

    if ffmpeg:
        try:
            st = os.stat(ffmpeg)
            if not (st.st_mode & stat.S_IXUSR):
                try:
                    os.chmod(ffmpeg, st.st_mode | stat.S_IXUSR)
                except:
                    pass
        except:
            pass
    if xbmcvfs.exists(ffmpeg):
        return ffmpeg
    else:
        xbmcgui.Dialog().notification("IPTV Recorder", _("ffmpeg exe not found!")) 
Example #19
Source File: vfs.py    From plugin.git.browser with GNU General Public License v3.0 5 votes vote down vote up
def cp(src, dest):
	return xbmcvfs.copy(src, dest) 
Example #20
Source File: skinsettings.py    From script.skin.helper.service with GNU General Public License v2.0 5 votes vote down vote up
def save_skin_image(self, skinstring="", multi_image=False, header=""):
        '''let the user select an image and save it to addon_data for easy backup'''
        cur_value = xbmc.getInfoLabel("Skin.String(%s)" % skinstring).decode("utf-8")
        cur_value_org = xbmc.getInfoLabel("Skin.String(%s.org)" % skinstring).decode("utf-8")

        if not multi_image:
            # single image (allow copy to addon_data)
            value = xbmcgui.Dialog().browse(2, header, 'files', '', True, True, cur_value_org).decode("utf-8")
            if value:
                ext = value.split(".")[-1]
                newfile = (u"special://profile/addon_data/%s/custom_images/%s.%s"
                           % (xbmc.getSkinDir(), skinstring + time.strftime("%Y%m%d%H%M%S", time.gmtime()), ext))
                if "special://profile/addon_data/%s/custom_images/" % xbmc.getSkinDir() in cur_value:
                    xbmcvfs.delete(cur_value)
                xbmcvfs.copy(value, newfile)
                xbmc.executebuiltin("Skin.SetString(%s.org,%s)" % (skinstring.encode("utf-8"), value.encode("utf-8")))
                value = newfile
        else:
            # multi image
            if not cur_value_org.startswith("$"):
                delim = "\\" if "\\" in cur_value_org else "/"
                curdir = cur_value_org.rsplit(delim, 1)[0] + delim
            else:
                curdir = ""
            value = xbmcgui.Dialog().browse(0, self.addon.getLocalizedString(32005),
                                            'files', '', True, True, curdir).decode("utf-8")
        return value 
Example #21
Source File: service.py    From service.subtitles.subdivx with GNU General Public License v2.0 5 votes vote down vote up
def _handle_compressed_subs(workdir, compressed_file, ext):
    """
    Uncompress 'compressed_file' in 'workdir'.
    """
    if ext == 'rar' and kodi_major_version >= 18:
        src = 'archive' + '://' + quote_plus(compressed_file) + '/'
        (cdirs, cfiles) = xbmcvfs.listdir(src)
        for cfile in cfiles:
            fsrc = '%s%s' % (src, cfile)
            xbmcvfs.copy(fsrc, workdir + cfile)
    else:
        xbmc.executebuiltin("XBMC.Extract(%s, %s)" % (
                            compressed_file.encode("utf-8"),
                            workdir.encode("utf-8")), True)

    files = os.listdir(workdir)
    files = [f for f in files if is_subs_file(f)]
    found_files = []
    for fname in files:
        if not isinstance(fname, unicode):
            fname = fname.decode('utf-8')
        found_files.append({
            'forced': is_forced_subs_file(fname),
            'path': pjoin(workdir, fname)
        })
    if not found_files:
        log(u"Failed to unpack subtitles", level=LOGSEVERE)
    return found_files 
Example #22
Source File: generation.py    From service.vpn.manager with GNU General Public License v2.0 5 votes vote down vote up
def generateVanishedVPN():
    files = getProfileList("VanishedVPN")
    destination_path = getProviderPath("VanishedVPN" + "/")
    for file in files:
        xbmcvfs.copy(file, destination_path + os.path.basename(file))
    generateMetaData("VanishedVPN", MINIMUM_LEVEL) 
Example #23
Source File: kodiutils.py    From script.module.inputstreamhelper with MIT License 5 votes vote down vote up
def copy(src, dest):
    """Copy a file (using xbmcvfs)"""
    from xbmcvfs import copy as vfscopy
    log(2, "Copy file '{src}' to '{dest}'.", src=src, dest=dest)
    return vfscopy(from_unicode(src), from_unicode(dest)) 
Example #24
Source File: utils.py    From plugin.video.emby with GNU General Public License v3.0 5 votes vote down vote up
def copy_file(path, dest):

    ''' Copy specific file.
    '''
    if path.endswith('.pyo'):
        return

    xbmcvfs.copy(path, dest)
    LOG.debug("copy: %s to %s", path, dest) 
Example #25
Source File: default.py    From plugin.video.emby with GNU General Public License v3.0 5 votes vote down vote up
def get_video_extras(item_id, path, server_id=None):

    ''' Returns the video files for the item as plugin listing, can be used
        to browse actual files or video extras, etc.
    '''
    if not item_id and 'plugin.video.emby' in path:
        item_id = path.split('/')[-2]

    if not item_id:
        return

    get_server(server_id)
    item = EMBY['api'].get_item(item_id)
    # TODO

    """
    def getVideoFiles(embyId,embyPath):
        #returns the video files for the item as plugin listing, can be used for browsing the actual files or videoextras etc.
        emby = embyserver.Read_EmbyServer()
        if not embyId:
            if "plugin.video.emby" in embyPath:
                embyId = embyPath.split("/")[-2]
        if embyId:
            item = emby.getItem(embyId)
            putils = playutils.PlayUtils(item)
            if putils.isDirectPlay():
                #only proceed if we can access the files directly. TODO: copy local on the fly if accessed outside
                filelocation = putils.directPlay()
                if not filelocation.endswith("/"):
                    filelocation = filelocation.rpartition("/")[0]
                dirs, files = xbmcvfs.listdir(filelocation)
                for file in files:
                    file = filelocation + file
                    li = xbmcgui.ListItem(file, path=file)
                    xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=file, listitem=li)
                for dir in dirs:
                    dir = filelocation + dir
                    li = xbmcgui.ListItem(dir, path=dir)
                    xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=dir, listitem=li, isFolder=True)
        #xbmcplugin.endOfDirectory(int(sys.argv[1]))
    """ 
Example #26
Source File: playwithchannel.py    From script.tvguide.fullscreen with GNU General Public License v2.0 5 votes vote down vote up
def ffmpeg_location():
    ffmpeg_src = xbmc.translatePath(ADDON.getSetting('autoplaywiths.ffmpeg'))

    if xbmc.getCondVisibility('system.platform.android'):
        ffmpeg_dst = '/data/data/%s/ffmpeg' % android_get_current_appid()

        if (ADDON.getSetting('autoplaywiths.ffmpeg') != ADDON.getSetting('ffmpeg.last')) or (not xbmcvfs.exists(ffmpeg_dst) and ffmpeg_src != ffmpeg_dst):
            xbmcvfs.copy(ffmpeg_src, ffmpeg_dst)
            ADDON.setSetting('ffmpeg.last',ADDON.getSetting('autoplaywiths.ffmpeg'))

        ffmpeg = ffmpeg_dst
    else:
        ffmpeg = ffmpeg_src

    if ffmpeg:
        try:
            st = os.stat(ffmpeg)
            if not (st.st_mode & stat.S_IXUSR):
                try:
                    os.chmod(ffmpeg, st.st_mode | stat.S_IXUSR)
                except:
                    pass
        except:
            pass
    if xbmcvfs.exists(ffmpeg):
        return ffmpeg
    else:
        xbmcgui.Dialog().notification("TVGF", "ffmpeg exe not found!") 
Example #27
Source File: playwith.py    From script.tvguide.fullscreen with GNU General Public License v2.0 5 votes vote down vote up
def ffmpeg_location():
    ffmpeg_src = xbmc.translatePath(ADDON.getSetting('autoplaywiths.ffmpeg'))

    if xbmc.getCondVisibility('system.platform.android'):
        ffmpeg_dst = '/data/data/%s/ffmpeg' % android_get_current_appid()

        if (ADDON.getSetting('autoplaywiths.ffmpeg') != ADDON.getSetting('ffmpeg.last')) or (not xbmcvfs.exists(ffmpeg_dst) and ffmpeg_src != ffmpeg_dst):
            xbmcvfs.copy(ffmpeg_src, ffmpeg_dst)
            ADDON.setSetting('ffmpeg.last',ADDON.getSetting('autoplaywiths.ffmpeg'))

        ffmpeg = ffmpeg_dst
    else:
        ffmpeg = ffmpeg_src
    log(ffmpeg)
    if ffmpeg:
        try:
            st = os.stat(ffmpeg)
            if not (st.st_mode & stat.S_IXUSR):
                log(st)
                try:
                    os.chmod(ffmpeg, st.st_mode | stat.S_IXUSR)
                except Exception as e:
                    log(e)
        except Exception as e:
            log(e)
    if xbmcvfs.exists(ffmpeg):
        return ffmpeg
    else:
        xbmcgui.Dialog().notification("TVGF", "ffmpeg exe not found!") 
Example #28
Source File: channel_logos.py    From script.tvguide.fullscreen with GNU General Public License v2.0 5 votes vote down vote up
def onInitialized(success):
        if success:
            channelList = database.getChannelList(onlyVisible=False)
            xbmcvfs.mkdirs("special://profile/addon_data/script.tvguide.fullscreen/channel_logos/")
            for channel in channelList:
                from_file = channel.logo
                regex = '[%s]' % re.escape('[]/\:')
                xbmc.log(regex)
                ext = from_file.rsplit('.',1)[-1]
                to_file = "special://profile/addon_data/script.tvguide.fullscreen/channel_logos/%s.%s" % (re.sub(regex,' ',channel.title),ext)
                xbmcvfs.copy(from_file,to_file)
            database.close(onAutoplaysCleared)
        else:
            database.close() 
Example #29
Source File: playerMP3.py    From bugatsinho.github.io with GNU General Public License v3.0 5 votes vote down vote up
def applyID3(self):
         if ADDON.getSetting('keep_downloads')=='false':
             return 
         if not xbmcvfs.exists(self.filename):
             return

         if self.track < 1:
             return

         log('Applying ID3 tags to %s' % self.title)

         temp = self.filename.rsplit(os.sep, 1)[-1]
         temp = os.path.join(TEMP, temp)

         doCopy = self.filename != temp

         if doCopy:
             xbmcvfs.copy(self.filename, temp)

         #Remove track number from title
         title=self.title
         try: title=title[title.find('. ')+2:]
         except: title=title
		 
         audio = MP3(temp, ID3=EasyID3)
         audio['title']       = title
         audio['artist']      = self.artist
         audio['album']       = self.album
         audio['tracknumber'] = str(self.track)
         audio['date']        = ''
         audio['genre']       = ''
         audio.save(v1=2)
         log(audio.pprint())

         if doCopy:
             del audio 
             deleteFile(self.filename)
             xbmcvfs.copy(temp, self.filename)
             deleteFile(temp) 
Example #30
Source File: util.py    From romcollectionbrowser with GNU General Public License v2.0 5 votes vote down vote up
def getEmuAutoConfigPath():
    settings = getSettings()
    path = settings.getSetting(SETTING_RCB_EMUAUTOCONFIGPATH)
    if path == '':
        path = os.path.join(getAddonDataPath(), u'emu_autoconfig.xml')

    if not xbmcvfs.exists(path):
        oldPath = os.path.join(getAddonInstallPath(), 'resources', 'emu_autoconfig.xml')
        xbmcvfs.copy(oldPath, path)

    return path