當前位置: 首頁>>代碼示例>>Python>>正文


Python xbmc.makeLegalFilename方法代碼示例

本文整理匯總了Python中xbmc.makeLegalFilename方法的典型用法代碼示例。如果您正苦於以下問題:Python xbmc.makeLegalFilename方法的具體用法?Python xbmc.makeLegalFilename怎麽用?Python xbmc.makeLegalFilename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xbmc的用法示例。


在下文中一共展示了xbmc.makeLegalFilename方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: GetTitleFromFile

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
def GetTitleFromFile(title):
    # Imprime en el log lo que va a descartar
    logger.info("tvalacarta.core.downloadtools GetTitleFromFile: titulo="+title )
    #logger.info("tvalacarta.core.downloadtools downloadtitle: title="+urllib.quote_plus( title ))
    plataforma = config.get_system_platform();
    logger.info("tvalacarta.core.downloadtools GetTitleFromFile: plataforma="+plataforma)
    
    #nombrefichero = xbmc.makeLegalFilename(title + url[-4:])
    if plataforma=="xbox":
        nombrefichero = title[:38] + title[-4:]
        nombrefichero = limpia_nombre_excepto_1(nombrefichero)
    else:
        nombrefichero = title
    return nombrefichero 
開發者ID:tvalacarta,項目名稱:tvalacarta,代碼行數:16,代碼來源:downloadtools.py

示例2: install_addon_pack

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
def install_addon_pack(self, name, url):
        from resources.libs.downloader import Downloader
        from resources.libs import db
        from resources.libs import extract
        from resources.libs.common import logging
        from resources.libs.common import tools

        progress_dialog = xbmcgui.DialogProgress()

        response = tools.open_url(url, check=True)

        if not response:
            logging.log_notify("[COLOR {0}]Addon Installer[/COLOR]".format(CONFIG.COLOR1),
                               '[COLOR {0}]{1}:[/COLOR] [COLOR {2}]Invalid Zip Url![/COLOR]'.format(CONFIG.COLOR1, name, CONFIG.COLOR2))
            return

        if not os.path.exists(CONFIG.PACKAGES):
            os.makedirs(CONFIG.PACKAGES)
        
        progress_dialog.create(CONFIG.ADDONTITLE,
                      '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name),
                      '', '[COLOR {0}]Please Wait[/COLOR]'.format(CONFIG.COLOR2))
        urlsplits = url.split('/')
        lib = xbmc.makeLegalFilename(os.path.join(CONFIG.PACKAGES, urlsplits[-1]))
        try:
            os.remove(lib)
        except:
            pass
        Downloader().download(url, lib)
        title = '[COLOR {0}][B]Installing:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name)
        progress_dialog.update(0, title, '', '[COLOR {0}]Please Wait[/COLOR]'.format(CONFIG.COLOR2))
        percent, errors, error = extract.all(lib, CONFIG.ADDONS, title=title)
        installed = db.grab_addons(lib)
        db.addon_database(installed, 1, True)
        progress_dialog.close()
        logging.log_notify("[COLOR {0}]Addon Installer[/COLOR]".format(CONFIG.COLOR1),
                           '[COLOR {0}]{1}: Installed![/COLOR]'.format(CONFIG.COLOR2, name))
        xbmc.executebuiltin('UpdateAddonRepos()')
        xbmc.executebuiltin('UpdateLocalAddons()')
        xbmc.executebuiltin('Container.Refresh()') 
開發者ID:a4k-openproject,項目名稱:plugin.program.openwizard,代碼行數:42,代碼來源:addon_menu.py

示例3: getfilefromtitle

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
def getfilefromtitle(url, title):
    # Imprime en el log lo que va a descartar
    logger.info("title=" + title)
    logger.info("url=" + url)
    plataforma = config.get_system_platform()
    logger.info("plataforma=" + plataforma)

    # nombrefichero = xbmc.makeLegalFilename(title + url[-4:])
    from . import scrapertools

    nombrefichero = title + scrapertools.get_filename_from_url(url)[-4:]
    logger.info("nombrefichero=%s" % nombrefichero)
    if "videobb" in url or "videozer" in url or "putlocker" in url:
        nombrefichero = title + ".flv"
    if "videobam" in url:
        nombrefichero = title + "." + url.rsplit(".", 1)[1][0:3]

    logger.info("nombrefichero=%s" % nombrefichero)

    nombrefichero = limpia_nombre_caracteres_especiales(nombrefichero)

    logger.info("nombrefichero=%s" % nombrefichero)

    fullpath = filetools.join(config.get_setting("downloadpath"), nombrefichero)
    logger.info("fullpath=%s" % fullpath)

    if config.is_xbmc() and fullpath.startswith("special://"):
        import xbmc
        fullpath = xbmc.translatePath(fullpath)

    return fullpath 
開發者ID:alfa-addon,項目名稱:addon,代碼行數:33,代碼來源:downloadtools.py

示例4: GetTitleFromFile

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
def GetTitleFromFile(title):
    # Imprime en el log lo que va a descartar
    logger.info("titulo=" + title)
    plataforma = config.get_system_platform()
    logger.info("plataforma=" + plataforma)

    # nombrefichero = xbmc.makeLegalFilename(title + url[-4:])
    nombrefichero = title
    return nombrefichero 
開發者ID:alfa-addon,項目名稱:addon,代碼行數:11,代碼來源:downloadtools.py

示例5: getfilefromtitle

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
def getfilefromtitle(url, title):
    # Imprime en el log lo que va a descartar
    logger.info("title=" + title)
    logger.info("url=" + url)
    # logger.info("pelisalacarta.core.downloadtools downloadtitle: title="+urllib.quote_plus( title ))
    plataforma = config.get_system_platform()
    logger.info("plataforma=" + plataforma)

    # nombrefichero = xbmc.makeLegalFilename(title + url[-4:])
    import scrapertools
    if plataforma == "xbox":
        nombrefichero = title[:38] + scrapertools.get_filename_from_url(url)[-4:]
        nombrefichero = limpia_nombre_excepto_1(nombrefichero)
    else:
        nombrefichero = title + scrapertools.get_filename_from_url(url)[-4:]
        logger.info("nombrefichero=%s" % nombrefichero)
        if "videobb" in url or "videozer" in url or "putlocker" in url:
            nombrefichero = title + ".flv"
        if "videobam" in url:
            nombrefichero = title + "." + url.rsplit(".", 1)[1][0:3]

        logger.info("nombrefichero=%s" % nombrefichero)

        nombrefichero = limpia_nombre_caracteres_especiales(nombrefichero)

    logger.info("nombrefichero=%s" % nombrefichero)

    fullpath = os.path.join(config.get_setting("downloadpath"), nombrefichero)
    logger.info("fullpath=%s" % fullpath)

    if config.is_xbmc() and fullpath.startswith("special://"):
        import xbmc
        fullpath = xbmc.translatePath(fullpath)

    return fullpath 
開發者ID:pelisalacarta-ce,項目名稱:pelisalacarta-ce,代碼行數:37,代碼來源:downloadtools.py

示例6: GetTitleFromFile

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
def GetTitleFromFile(title):
    # Imprime en el log lo que va a descartar
    logger.info("titulo=" + title)
    # logger.info("pelisalacarta.core.downloadtools downloadtitle: title="+urllib.quote_plus( title ))
    plataforma = config.get_system_platform()
    logger.info("plataforma=" + plataforma)

    # nombrefichero = xbmc.makeLegalFilename(title + url[-4:])
    if plataforma == "xbox":
        nombrefichero = title[:38] + title[-4:]
        nombrefichero = limpia_nombre_excepto_1(nombrefichero)
    else:
        nombrefichero = title
    return nombrefichero 
開發者ID:pelisalacarta-ce,項目名稱:pelisalacarta-ce,代碼行數:16,代碼來源:downloadtools.py

示例7: downloadMovie

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
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:mrknow,項目名稱:filmkodi,代碼行數:28,代碼來源:downloader.py

示例8: getfilefromtitle

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
def getfilefromtitle(url,title,folder=""):
    logger.info("tvalacarta.core.downloadtools getfilefromtitle: title="+title+" url="+url+" folder="+folder )

    #logger.info("tvalacarta.core.downloadtools downloadtitle: title="+urllib.quote_plus( title ))
    plataforma = config.get_system_platform();
    logger.info("tvalacarta.core.downloadtools getfilefromtitle: plataforma="+plataforma)
    
    #nombrefichero = xbmc.makeLegalFilename(title + url[-4:])
    import scrapertools
    if plataforma=="xbox":
        nombrefichero = title[:38] + scrapertools.get_filename_from_url(url)[-4:]
        nombrefichero = limpia_nombre_excepto_1(nombrefichero)
    else:
        nombrefichero = title + scrapertools.get_filename_from_url(url)[-4:]
        logger.info("tvalacarta.core.downloadtools getfilefromtitle: nombrefichero=%s" % nombrefichero)
        if "videobb" in url or "videozer" in url or "putlocker" in url:
            nombrefichero = title + ".flv"
        if "videobam" in url:
            nombrefichero = title+"."+url.rsplit(".",1)[1][0:3]
        if "dibujos.tv" in url:
            nombrefichero = title + ".mp4"
        if "filenium" in url:
            # Content-Disposition	filename="filenium_El.Gato.con.Botas.TSScreener.Latino.avi"
            import scrapertools
            content_disposition_header = scrapertools.get_header_from_response(url,header_to_get="Content-Disposition")
            logger.info("content_disposition="+content_disposition_header)
            partes=content_disposition_header.split("=")
            if len(partes)<=1:
                raise Exception('filenium', 'no existe')
                
            extension = partes[1][-5:-1]
            nombrefichero = title + extension
        logger.info("tvalacarta.core.downloadtools getfilefromtitle: nombrefichero=%s" % nombrefichero)

        nombrefichero = limpia_nombre_caracteres_especiales(nombrefichero)

    logger.info("tvalacarta.core.downloadtools getfilefromtitle: nombrefichero=%s" % nombrefichero)

    if folder=="":
        fullpath = os.path.join( config.get_setting("downloadpath") , nombrefichero )
    else:
        fullpath = os.path.join( config.get_setting("downloadpath") , folder , nombrefichero )

    logger.info("tvalacarta.core.downloadtools getfilefromtitle: fullpath=%s" % fullpath)
    
    return fullpath 
開發者ID:tvalacarta,項目名稱:tvalacarta,代碼行數:48,代碼來源:downloadtools.py

示例9: downloadfileGzipped

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
def downloadfileGzipped(url,pathfichero):
    logger.info("tvalacarta.core.downloadtools downloadfileGzipped: url="+url)
    nombrefichero = pathfichero
    logger.info("tvalacarta.core.downloadtools downloadfileGzipped: nombrefichero="+nombrefichero)

    import xbmc
    nombrefichero = xbmc.makeLegalFilename(nombrefichero)
    logger.info("tvalacarta.core.downloadtools downloadfileGzipped: nombrefichero="+nombrefichero)
    patron = "(http://[^/]+)/.+"
    matches = re.compile(patron,re.DOTALL).findall(url)
    
    if len(matches):
        logger.info("tvalacarta.core.downloadtools 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
    import xbmcgui
    progreso = xbmcgui.DialogProgress()
    progreso.create( "addon" , "Descargando..." , 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:
        logger.info("tvalacarta.core.downloadtools 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
        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:tvalacarta,項目名稱:tvalacarta,代碼行數:60,代碼來源:downloadtools.py

示例10: install_skin

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
def install_skin(self, name, url):
        from resources.libs.downloader import Downloader
        from resources.libs import db
        from resources.libs import extract
        from resources.libs.common import logging
        from resources.libs import skin
        from resources.libs.common import tools

        progress_dialog = xbmcgui.DialogProgress()

        response = tools.open_url(url, check=False)

        if not response:
            logging.log_notify("[COLOR {0}]Addon Installer[/COLOR]".format(CONFIG.COLOR1),
                               '[COLOR {0}]{1}:[/COLOR] [COLOR {2}]Invalid Zip Url![/COLOR]'.format(CONFIG.COLOR1, name, CONFIG.COLOR2))
            return

        if not os.path.exists(CONFIG.PACKAGES):
            os.makedirs(CONFIG.PACKAGES)
        
        progress_dialog.create(CONFIG.ADDONTITLE,
                      '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name),
                      '', '[COLOR {0}]Please Wait[/COLOR]'.format(CONFIG.COLOR2))

        urlsplits = url.split('/')
        lib = xbmc.makeLegalFilename(os.path.join(CONFIG.PACKAGES, urlsplits[-1]))
        try:
            os.remove(lib)
        except:
            pass
        Downloader().download(url, lib)
        title = '[COLOR {0}][B]Installing:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format(CONFIG.COLOR2, CONFIG.COLOR1, name)
        progress_dialog.update(0, title, '', '[COLOR {0}]Please Wait[/COLOR]'.format(CONFIG.COLOR2))
        percent, errors, error = extract.all(lib, CONFIG.HOME, title=title)
        installed = db.grab_addons(lib)
        db.addon_database(installed, 1, True)
        progress_dialog.close()
        logging.log_notify("[COLOR {0}]Addon Installer[/COLOR]".format(CONFIG.COLOR1),
                           '[COLOR {0}]{1}: Installed![/COLOR]'.format(CONFIG.COLOR2, name))
        xbmc.executebuiltin('UpdateAddonRepos()')
        xbmc.executebuiltin('UpdateLocalAddons()')
        for item in installed:
            if item.startswith('skin.') and not item == 'skin.shortcuts':
                if not CONFIG.BUILDNAME == '' and CONFIG.DEFAULTIGNORE == 'true':
                    CONFIG.set_setting('defaultskinignore', 'true')
                skin.switch_to_skin(item, 'Skin Installer')
        xbmc.executebuiltin('Container.Refresh()') 
開發者ID:a4k-openproject,項目名稱:plugin.program.openwizard,代碼行數:49,代碼來源:addon_menu.py

示例11: download_file

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
def download_file(self):
        logger.info("Direct download")

        headers=[]

        # Se asegura de que el fichero se podrá crear
        logger.info("nombrefichero="+self.file_name)
        self.file_name = xbmc.makeLegalFilename(self.file_name)
        logger.info("nombrefichero="+self.file_name)
        logger.info("url="+self.url)
    
        # Crea el fichero
        existSize = 0
        f = open(self.file_name, 'wb')
        grabado = 0

        # Interpreta las cabeceras en una URL como en XBMC
        if "|" in self.url:
            additional_headers = self.url.split("|")[1]
            if "&" in additional_headers:
                additional_headers = additional_headers.split("&")
            else:
                additional_headers = [ additional_headers ]
    
            for additional_header in additional_headers:
                logger.info("additional_header: "+additional_header)
                name = re.findall( "(.*?)=.*?" , additional_header )[0]
                value = urllib.unquote_plus(re.findall( ".*?=(.*?)$" , additional_header )[0])
                headers.append( [ name,value ] )
    
            self.url = self.url.split("|")[0]
            logger.info("url="+self.url)
    
        # Timeout del socket a 60 segundos
        socket.setdefaulttimeout(60)

        # Crea la petición y añade las cabeceras
        h=urllib2.HTTPHandler(debuglevel=0)
        request = urllib2.Request(self.url)
        for header in headers:
            logger.info("Header="+header[0]+": "+header[1])
            request.add_header(header[0],header[1])

        # Lanza la petición
        opener = urllib2.build_opener(h)
        urllib2.install_opener(opener)
        try:
            connexion = opener.open(request)
        except urllib2.HTTPError,e:
            logger.error("error %d (%s) al abrir la url %s" % (e.code,e.msg,self.url))
            #print e.code
            #print e.msg
            #print e.hdrs
            #print e.fp
            f.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:pelisalacarta-ce,項目名稱:pelisalacarta-ce,代碼行數:63,代碼來源:download_and_play.py

示例12: downloadfileGzipped

# 需要導入模塊: import xbmc [as 別名]
# 或者: from xbmc import makeLegalFilename [as 別名]
def downloadfileGzipped(url, pathfichero):
    logger.info("url=" + url)
    nombrefichero = pathfichero
    logger.info("nombrefichero=" + nombrefichero)

    import xbmc
    nombrefichero = xbmc.makeLegalFilename(nombrefichero)
    logger.info("nombrefichero=" + nombrefichero)
    patron = "(http://[^/]+)/.+"
    matches = re.compile(patron, re.DOTALL).findall(url)

    if len(matches):
        logger.info("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
    from platformcode import platformtools
    progreso = platformtools.dialog_progress("addon", "Descargando...", url.split("|")[0], 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:
        logger.error("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
        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:pelisalacarta-ce,項目名稱:pelisalacarta-ce,代碼行數:62,代碼來源:downloadtools.py


注:本文中的xbmc.makeLegalFilename方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。