def getfilefromtitle(url,title):
# Imprime en el log lo que va a descartar
logger.info("streamondemand-pureita.core.downloadtools getfilefromtitle: title="+title )
logger.info("streamondemand-pureita.core.downloadtools getfilefromtitle: url="+url )
#logger.info("streamondemand-pureita.core.downloadtools downloadtitle: title="+urllib.quote_plus( title ))
plataforma = config.get_system_platform();
logger.info("streamondemand-pureita.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("streamondemand-pureita.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 "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("streamondemand-pureita.core.downloadtools getfilefromtitle: nombrefichero=%s" % nombrefichero)
nombrefichero = limpia_nombre_caracteres_especiales(nombrefichero)
logger.info("streamondemand-pureita.core.downloadtools getfilefromtitle: nombrefichero=%s" % nombrefichero)
fullpath = os.path.join( config.get_setting("downloadpath") , nombrefichero )
logger.info("streamondemand-pureita.core.downloadtools getfilefromtitle: fullpath=%s" % fullpath)
return fullpath
downloadtools.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录