def saveposter(self):
     if  __addon__.getSetting("saveposter")=="false": return False
     if self.thumb.startswith("http"):
         import torrents
         image_data = torrents.url_get(self.thumb)
         if image_data =="": return False
         if ".png" in self.thumb.lower(): ext=".png"
         elif ".gif" in self.thumb.lower(): ext=".gif"
         elif ".jpg" in self.thumb.lower(): ext= ".jpg"
         else: ext = ".img"
         try:
             f = open(self.filename.replace(".avi","").replace(".mp4","").replace("mkv","") + ext  , "wb+")
             f.write(image_data)
             f.close()
             return True
         except: return False
     else: return False
Beispiel #2
0
 def saveposter(self):
     if __addon__.getSetting("saveposter") == "false": return False
     if self.thumb.startswith("http"):
         import torrents
         image_data = torrents.url_get(self.thumb)
         if image_data == "": return False
         if ".png" in self.thumb.lower(): ext = ".png"
         elif ".gif" in self.thumb.lower(): ext = ".gif"
         elif ".jpg" in self.thumb.lower(): ext = ".jpg"
         else: ext = ".img"
         try:
             f = open(
                 self.filename.replace(".avi", "").replace(
                     ".mp4", "").replace("mkv", "") + ext, "wb+")
             f.write(image_data)
             f.close()
             return True
         except:
             return False
     else:
         return False
Beispiel #3
0
def guardar_magnet(uri,player,image,torr_folder,teclado=False):
    title =""
    try:
        title = uri.rsplit("dn=")[1] 
        title = title.rsplit("&")[0] 
        title = urllib.unquote_plus(title)
        title = title.replace("+"," ").replace(",","").replace("¿","").replace("?","").replace("*","")
        title = unicode(title,'utf-8')
        title = tools.latin1_to_ascii(title)
    except: pass
    if title == "" or teclado:
        keyboard = xbmc.Keyboard(title)
        keyboard.doModal()
        if (keyboard.isConfirmed()):
            title = keyboard.getText()
        else: return
    if title == "":
        xbmcgui.Dialog().ok("Torrentin" , "Tienes que escribir un nombre para el magnet,","Repite el proceso y escribelo con el teclado.")
        if __addon__.getSetting('reopen') == "true": principal(uri,player,image)
        return
    try:
        f = open(os.path.join( torr_folder , title + ".magnet") , "wb+")
        f.write(uri)
        f.close()
    except:
        mensaje('ERROR al guardar el magnet, revisa el nombre.', 5000)
        guardar_magnet(uri,player,image,torr_folder,True)
        return
    # Guardamos la caratula
    if image != "":
        image_data = ""
        if image.startswith("http"):
            image_data = torrents.url_get(image)
        else:
            try:
                f = open(image, "rb+")
                image_data=f.read()
                f.close()
            except: pass
        if image_data =="":
            mensaje('ERROR al obtener la caratula.', 4000)
            try:
                f = open(os.path.join( __cwd__ ,"resources","images","magnetlogo.png") , "rb+")
                image_data=f.read()
                f.close()
                f = open(os.path.join( torr_folder , title + ".png" ) , "wb+")
                f.write(image_data)
                f.close()
            except: pass
            if __addon__.getSetting('reopen') == "true": principal(uri,player,image)
            return
        if ".png" in image.lower(): ext=".png"
        elif ".gif" in image.lower(): ext=".gif"
        elif ".jpg" in image.lower(): ext= ".jpg"
        else: ext = ".img"
        try:
            f = open(os.path.join( torr_folder , title + ext ) , "wb+")
            f.write(image_data)
            f.close()
        except:
            mensaje('ERROR al guardar la caratula.', 3000)
            if __addon__.getSetting('reopen') == "true": principal(uri,player,image)
            return
    else:
        try:
            f = open(os.path.join( __cwd__ ,"resources","images","magnetlogo.png") , "rb+")
            image_data=f.read()
            f.close()
            f = open(os.path.join( torr_folder , title + ".png" ) , "wb+")
            f.write(image_data)
            f.close()
        except:
            mensaje('ERROR al guardar la caratula.', 3000)
            if __addon__.getSetting('reopen') == "true": principal(uri,player,image)
            return
    show_Msg('Magnet y Caratula guardados:',title,5000)
    if __addon__.getSetting('reopen') == "true": principal(uri,player,image)