• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python xbmc.makeLegalFilename函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xbmc.makeLegalFilename函数的典型用法代码示例。如果您正苦于以下问题:Python makeLegalFilename函数的具体用法?Python makeLegalFilename怎么用?Python makeLegalFilename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了makeLegalFilename函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: CleanExpired

 def CleanExpired(self):
     #delete files more than an hour old
     self.Notification('Hulu Library','Removing Expired Content')
     
     #delete old tv show files
     dir = xbmc.makeLegalFilename(TV_SHOWS_PATH)
     dirs, trash = xbmcvfs.listdir(dir)
     for show in dirs:
         show = xbmc.makeLegalFilename(os.path.join(dir, show))
         trash, files = xbmcvfs.listdir(show)
         for file in files:
             path = xbmc.makeLegalFilename(os.path.join(show,file))
             if (sys.platform == 'win32'): path = path.replace('smb:','')
             if (time.mktime(time.strptime(time.ctime(os.path.getmtime(path)))) < (time.mktime(time.localtime()) - 3600)): xbmcvfs.delete(path)
     
     #delete old movie files
     dir = xbmc.makeLegalFilename(MOVIE_PATH)
     trash, movies = xbmcvfs.listdir(dir)
     for movie in movies:
         path = xbmc.makeLegalFilename(os.path.join(dir, movie))
         if (sys.platform == 'win32'): path = path.replace('smb:','')
         if time.mktime(time.strptime(time.ctime(os.path.getmtime(path)))) < (time.mktime(time.localtime()) - 3600): xbmcvfs.delete(path)
         xbmc.log(path)
         
     self.Notification('Hulu Library','Expired Content Removed')
开发者ID:DuperMan,项目名称:plugin.video.hulu-beta,代码行数:25,代码来源:xbmclibrary.py


示例2: create_legal_filename

def create_legal_filename(title, year):
    filename = title
    if year: filename += ' %s' % (year)
    filename = re.sub(r'(?!%s)[^\w\-_\.]', '.', filename)
    filename = re.sub('\.+', '.', filename)
    xbmc.makeLegalFilename(filename)
    return filename
开发者ID:CYBERxNUKE,项目名称:xbmc-addon,代码行数:7,代码来源:utils.py


示例3: downloadMovie

    def downloadMovie(self, url, path, title, extension):
        if not os.path.exists(path):
            common.log('Path does not exist')
            return None
        if title == '':
            common.log('No title given')
            return None

        file_path = xbmc.makeLegalFilename(os.path.join(path, title + extension))
        file_path = urllib.unquote_plus(file_path)
        # Overwrite existing file?
        if os.path.isfile(file_path):
            self.pDialog = xbmcgui.Dialog()

            if not common.ask('File already exists. Overwrite?\n' + os.path.basename(file_path)):
                title = common.showOSK(urllib.unquote_plus(title), common.translate(30102))
                if not title:
                    return None
                file_path = xbmc.makeLegalFilename(os.path.join(path, title + extension))
                file_path = urllib.unquote_plus(file_path)
        
        success = self.__download(url, file_path)
        if success:
            return file_path
        else:
            return None
开发者ID:aamkTV,项目名称:githamtv.github.io,代码行数:26,代码来源:downloader.py


示例4: legal_filename

 def legal_filename(filename):
     try:
         filename = filename.strip()
         filename = re.sub(r'(?!%s)[^\w\-_\.]', '.', filename)
         filename = re.sub('\.+', '.', filename)
         filename = re.sub(re.compile('(CON|PRN|AUX|NUL|COM\d|LPT\d)\.', re.I), '\\1_', filename)
         xbmc.makeLegalFilename(filename)
         return filename
     except:
         return filename
开发者ID:varunrai,项目名称:repository.magicality,代码行数:10,代码来源:libtools.py


示例5: filename_from_title

def filename_from_title(title, video_type):
    if video_type == 'tvshow':
        filename = '%s S%sE%s.strm'
        filename = filename % (title, '%s', '%s')
    else:
        filename = '%s.strm' % title

    filename = re.sub(r'(?!%s)[^\w\-_\. ]', '_', filename)
    xbmc.makeLegalFilename(filename)
    return filename
开发者ID:MrGHLover,项目名称:1Channel,代码行数:10,代码来源:utils.py


示例6: filename_from_title

def filename_from_title(title, video_type, year=None):
    if video_type == VIDEO_TYPES.TVSHOW:
        filename = '%s S%sE%s.strm'
        filename = filename % (title, '%s', '%s')
    else:
        if year: title = '%s (%s)' % (title, year)
        filename = '%s.strm' % title

    filename = re.sub(r'(?!%s)[^\w\-_\.]', '.', filename)
    filename = re.sub('\.+', '.', filename)
    xbmc.makeLegalFilename(filename)
    return filename
开发者ID:SNAPflix,项目名称:salts,代码行数:12,代码来源:utils.py


示例7: copy

    def copy(orgfilename, newfilename):
        orgfilename = xbmc.makeLegalFilename(orgfilename)
        newfilename = xbmc.makeLegalFilename(newfilename)

        if VFS_AVAILABLE == True:
            xbmcvfs.copy(orgfilename, newfilename)
        else:
            try:
                shutil.copy(orgfilename, newfilename)
            except:
                return False

        return True
开发者ID:00chris00,项目名称:alicanlakot-s-xbmc-plugins,代码行数:13,代码来源:FileAccess.py


示例8: filename_from_title

def filename_from_title(title, video_type, year=None):
    if video_type == VIDEO_TYPES.TVSHOW:
        filename = '%s S%sE%s'
        filename = filename % (title, '%s', '%s')
    else:
        if year: title = '%s.%s' % (title, year)
        filename = title

    filename = re.sub(r'(?!%s)[^\w\-_\.]', '.', filename)
    filename = re.sub('\.+', '.', filename)
    filename = re.sub(re.compile('(CON|PRN|AUX|NUL|COM\d|LPT\d)\.', re.I), '\\1_', filename)
    xbmc.makeLegalFilename(filename)
    return filename
开发者ID:CYBERxNUKE,项目名称:xbmc-addon,代码行数:13,代码来源:utils2.py


示例9: filename_from_title

def filename_from_title(title, video_type, year=None):
    if video_type == VIDEO_TYPES.TVSHOW:
        filename = "%s S%sE%s.strm"
        filename = filename % (title, "%s", "%s")
    else:
        if year:
            title = "%s (%s)" % (title, year)
        filename = "%s.strm" % title

    filename = re.sub(r"(?!%s)[^\w\-_\.]", ".", filename)
    filename = re.sub("\.+", ".", filename)
    xbmc.makeLegalFilename(filename)
    return filename
开发者ID:fergyc,项目名称:tknorris-beta-repo,代码行数:13,代码来源:utils.py


示例10: writeFiles

    def writeFiles(self,fileList,source,dest):
        utils.log("Writing files to: " + dest)
        self.filesTotal = len(fileList)
        self.filesLeft = self.filesTotal

        #write each file from source to destination
        for aFile in fileList:
            if(not self.checkCancel()):
                utils.log('Writing file: ' + source + aFile,xbmc.LOGDEBUG)
                self.updateProgress(aFile)
                if (aFile.startswith("-")):
                    vfs.mkdir(xbmc.makeLegalFilename(dest + aFile[1:],False))
                else:
                    vfs.copy(xbmc.makeLegalFilename(source + aFile),xbmc.makeLegalFilename(dest + aFile,False))
开发者ID:dersphere,项目名称:xbmcbackup,代码行数:14,代码来源:backup.py


示例11: _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


示例12: createNetworkPlaylist

    def createNetworkPlaylist(self, network):
        flename = xbmc.makeLegalFilename(GEN_CHAN_LOC + 'Network_' + network + '.xsp')

        try:
            fle = FileAccess.open(flename, "w")
        except:
            self.log(LANGUAGE(30034) + ' ' + flename, xbmc.LOGERROR)
            return ''

        self.writeXSPHeader(fle, "episodes", self.getChannelName(1, network))
        network = network.lower()
        added = False
        
        fle.write('    <rule field="tvshow" operator="is">\n')
        
        for i in range(len(self.showList)):
            if self.showList[i][1].lower() == network:
                theshow = self.cleanString(self.showList[i][0])
                fle.write('        <value>' + theshow + '</value>\n')
                added = True
        
        fle.write('    </rule>\n')

        self.writeXSPFooter(fle, 0, "random")
        fle.close()

        if added == False:
            return ''

        return flename
开发者ID:rafaelvieiras,项目名称:script.pseudotv,代码行数:30,代码来源:ChannelList.py


示例13: downloadfileGzipped

def downloadfileGzipped(url,pathfichero):
	xbmc.output("[downloadtools.py] downloadfileGzipped: url="+url)
	nombrefichero = pathfichero
	xbmc.output("[downloadtools.py] downloadfileGzipped: nombrefichero="+nombrefichero)

	nombrefichero = xbmc.makeLegalFilename(nombrefichero)
	xbmc.output("[downloadtools.py] downloadfileGzipped: nombrefichero="+nombrefichero)
	patron = "(http://[^/]+)/.+"
	matches = re.compile(patron,re.DOTALL).findall(url)
	
	if len(matches):
		xbmc.output("[downloadtools.py] URL principal :"+matches[0])
		url1= matches[0]
	else:
		url1 = url
	
	txheaders =  {'User-Agent':'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)',
	              'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
	              'Accept-Language':'es-es,es;q=0.8,en-us;q=0.5,en;q=0.3',
	              'Accept-Encoding':'gzip,deflate',
	              'Accept-Charset':'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
	              'Keep-Alive':'115',
	              'Connection':'keep-alive',
	              'Referer':url1,
	              }
	              
		
	txdata = ""
	


	# Crea el diálogo de progreso
	progreso = xbmcgui.DialogProgress()
	progreso.create( 'Pelisalacarta' , "Descargando file..." , url , nombrefichero )

	# Timeout del socket a 60 segundos
	socket.setdefaulttimeout(10)

	h=urllib2.HTTPHandler(debuglevel=0)
	request = urllib2.Request(url, txdata, txheaders)
	#if existSize > 0:
	#	request.add_header('Range', 'bytes=%d-' % (existSize, ))

	opener = urllib2.build_opener(h)
	urllib2.install_opener(opener)
	try:
		connexion = opener.open(request)
	except urllib2.HTTPError,e:
		xbmc.output("[downloadtools.py] downloadfile: error %d (%s) al abrir la url %s" % (e.code,e.msg,url))
		#print e.code
		#print e.msg
		#print e.hdrs
		#print e.fp
		f.close()
		progreso.close()
		# El error 416 es que el rango pedido es mayor que el fichero => es que ya está completo
		if e.code==416:
			return 0
		else:
			return -2
开发者ID:HackJoues,项目名称:pelisalacarta-personal-fork,代码行数:60,代码来源:downloadtools.py


示例14: getVideoLength

    def getVideoLength(self, filename):
        filename = xbmc.makeLegalFilename(filename)
        self.log("getVideoLength " + filename)

        if len(filename) == 0:
            self.log("No file name specified")
            return 0

        self.log("os name is " + os.name)

        if os.path.exists(filename) == False:
            if filename[0:6].lower() == 'smb://':
                filename = self.handleSMB(filename)
            else:
                self.log("Unable to open the file")
                return 0

        base, ext = os.path.splitext(filename)
        ext = ext.lower()

        if ext in self.AVIExts:
            self.parser = AVIParser.AVIParser()
        elif ext in self.MP4Exts:
            self.parser = MP4Parser.MP4Parser()
        elif ext in self.MKVExts:
            self.parser = MKVParser.MKVParser()
        elif ext in self.FLVExts:
            self.parser = FLVParser.FLVParser()
        else:
            self.log("No parser found for extension " + ext)
            return 0

        return self.parser.determineLength(filename)
开发者ID:kyotocafe,项目名称:XBMC-PseudoTV,代码行数:33,代码来源:VideoParser.py


示例15: delDirContent

    def delDirContent(self, r_path):
        """
        Delete the content of a directory ( file and sub direstories)
        but not the directory itself
        path: directory path
        """
        # print "delDirContent"
        # print path
        result = True
        path = xbmc.makeLegalFilename(r_path)
        if os.path.isdir(path):
            dirItems = os.listdir(path)
            for item in dirItems:
                itemFullPath = os.path.join(path, item)
                try:
                    if os.path.isfile(itemFullPath):
                        # Fichier
                        os.remove(itemFullPath)
                    elif os.path.isdir(itemFullPath):
                        # Repertoire
                        self.deleteDir(itemFullPath)
                except:
                    result = False
                    print "delDirContent: Exception la suppression du contenu du reperoire: %s" % path
                    print_exc()
        else:
            print "delDirContent: %s n'est pas un repertoire" % path
            result = False

        return result
开发者ID:Quihico,项目名称:passion-xbmc,代码行数:30,代码来源:FileManager.py


示例16: deleteDir

    def deleteDir(self, r_path):
        """
        Delete a directory and all its content (files and subdirs)
        Note: the directory does NOT need to be empty
        Return True if success, False otherwise
        """
        result = True
        path = xbmc.makeLegalFilename(r_path)
        if os.path.isdir(path):
            dirItems = os.listdir(path)
            for item in dirItems:
                itemFullPath = os.path.join(path, item)
                try:
                    if os.path.isfile(itemFullPath):
                        # Fichier
                        os.remove(itemFullPath)
                    elif os.path.isdir(itemFullPath):
                        # Repertoire
                        self.deleteDir(itemFullPath)
                except:
                    result = False
                    print "deleteDir: Exception deleting directory: %s" % path
                    print_exc()
            # Suppression du repertoire pere
            try:
                os.rmdir(path)
            except:
                result = False
                print "deleteDir: Exception deleting directory: %s" % path
                print_exc()
        else:
            print "deleteDir: %s is not a directory" % path
            result = False

        return result
开发者ID:Quihico,项目名称:passion-xbmc,代码行数:35,代码来源:FileManager.py


示例17: DownloadVideo

def DownloadVideo(url, title):
    fileName = url.split('?')[0].strip()
    extension = os.path.splitext(fileName)[1][1:].strip() 
    #remove  invalid file characters
    title = title.replace("/","")
    title = title + "." + extension
    if settings.getSetting('download_path') == '':
        try:
            downloadPath = xbmcgui.Dialog().browse(3, language(30002),'files', '', False, False, '')
            if downloadPath == '':
                return None
            settings.setSetting(id='download_path', value=downloadPath)
            if not os.path.exists(downloadPath):
                os.mkdir(downloadPath)
        except:
            pass
    filePath = xbmc.makeLegalFilename(os.path.join(settings.getSetting('download_path'), title))
    if os.path.isfile(filePath):
        return None
    global pDialog
    global pFileName
    pFileName = title
    pDialog = xbmcgui.DialogProgress()
    pDialog.create('OneClickMoviez', language(30003), language(30004))
    try:
        print 'DownloadVideoURL:',url
        print 'DownloadVideoFilePath:',filePath
        urllib.urlretrieve(url, filePath, VideoReportHook)
        #urllib.urlretrieve(url, filePath)
        print 'DownloadedVideo'
        pDialog.close()
        return filePath
    except Exception, e:
        print "URLRetrieve Error:",e
        pass
开发者ID:jasanand,项目名称:plugin.video.oneclickmoviez,代码行数:35,代码来源:default.py


示例18: add_to_library

def add_to_library(video_type, url, title, img, year, imdbnum, movie_num=''):
    try: IW_addon.log('Creating .strm for %s %s %s %s %s %s' % (video_type, title, imdbnum, url, img, year))
    except: pass
    if video_type == 'tvshow':
        save_path = IW_addon.get_setting('tvshow-folder')
        save_path = xbmc.translatePath(save_path)
        strm_string = IW_addon.build_plugin_url(
            {'mode': 'NightlyNewsSubMenu','dialog': '1'})
        if year: title = '%s (%s)' % (title, year)
        filename = filename_from_title(title + ' s1e1', 'movie')
        title = re.sub(r'[^\w\-_\. ]', '_', title)
        titles = title
        final_path = os.path.join(save_path, title, filename)
        final_path = xbmc.makeLegalFilename(final_path)
        if not xbmcvfs.exists(os.path.dirname(final_path)):
            try:
                try: xbmcvfs.mkdirs(os.path.dirname(final_path))
                except: os.path.mkdir(os.path.dirname(final_path))
            except Exception, e:
                try: IW_addon.log('Failed to create directory %s' % final_path)
                except: pass
        try:
            file_desc = xbmcvfs.File(final_path, 'w')
            file_desc.write(strm_string)
            file_desc.close()
        except Exception, e:
            IW_addon.log('Failed to create .strm file: %s\n%s' % (final_path, e))
开发者ID:Spinalcracker,项目名称:infowars,代码行数:27,代码来源:default.py


示例19: createShowPlaylist

    def createShowPlaylist(self, show, setting2):
        order = 'random'

        try:
            setting = int(setting2)

            if setting & MODE_ORDERAIRDATE > 0:
                order = 'episode'
        except:
            pass

        flename = xbmc.makeLegalFilename(GEN_CHAN_LOC + 'Show_' + show + '_' + order + '.xsp')

        try:
            fle = FileAccess.open(flename, "w")
        except:
            self.log(LANGUAGE(30034) + ' ' + flename, xbmc.LOGERROR)
            return ''

        self.writeXSPHeader(fle, 'episodes', self.getChannelName(6, show))
        show = self.cleanString(show)
        fle.write('    <rule field="tvshow" operator="is">\n')
        fle.write('        <value>' + show + '</value>\n')
        fle.write('    </rule>\n')
        self.writeXSPFooter(fle, 0, order)
        fle.close()
        return flename
开发者ID:rafaelvieiras,项目名称:script.pseudotv,代码行数:27,代码来源:ChannelList.py


示例20: fetchBinary

def fetchBinary(url):
	fn = ''
	try:
		fn = os.path.join(DIR_USERDATA, os.path.basename(url))
		fn = xbmc.translatePath(fn)
		fn = xbmc.makeLegalFilename(fn)
		log('fetchBinary() url=%s fn=%s' % (url,fn))
		if not os.path.isfile(fn):
			opener = urllib.FancyURLopener()
			fn, resp = opener.retrieve(url, fn)
			opener.close()
			os.path.isfile(fn)
	except:
		msg = sys.exc_info()[ 1 ]
		print msg
		url = 'http://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk/XBMC/skin/Project%20Mayhem%20III/media/defaultVideoBig.png'
		fn = os.path.join(DIR_USERDATA, 'defaultVideoBig.png')
		fn = xbmc.translatePath(fn)
		log('fetchBinary() url=%s fn=%s' % (url,fn))
		if not os.path.isfile(fn):
			opener = urllib.FancyURLopener()
			fn, resp = opener.retrieve(url, fn)
			opener.close()
			os.path.isfile(fn)

	if fn and os.path.isfile(fn):
		return fn
	else:
		return ''
开发者ID:drrlramsey,项目名称:xbmc-addons,代码行数:29,代码来源:default.py



注:本文中的xbmc.makeLegalFilename函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python xbmc.output函数代码示例发布时间:2022-05-26
下一篇:
Python xbmc.log函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap