def savebookmark(canal=CHANNELNAME, titulo="", url="", thumbnail="", server="", plot="", fulltitle="", savepath=BOOKMARK_PATH): logger.info("streamondemand.channels.favoritos savebookmark(path="+savepath+")") # Crea el directorio de favoritos si no existe if not samba.usingsamba(savepath): try: os.mkdir(savepath) except: pass # Lee todos los ficheros if samba.usingsamba(savepath): ficheros = samba.get_files(savepath) else: ficheros = os.listdir(savepath) ficheros.sort() # Averigua el último número if len(ficheros) > 0: # XRJ: Linea problemática, sustituida por el bucle siguiente # filenumber = int( ficheros[len(ficheros)-1][0:-4] )+1 filenumber = 1 for fichero in ficheros: logger.info("streamondemand.channels.favoritos fichero="+fichero) try: tmpfilenumber = int(fichero[0:8])+1 if tmpfilenumber > filenumber: filenumber = tmpfilenumber except: pass else: filenumber = 1 # Genera el contenido filecontent = "" filecontent = filecontent + urllib.quote_plus(titulo)+'\n' filecontent = filecontent + urllib.quote_plus(url)+'\n' filecontent = filecontent + urllib.quote_plus(thumbnail)+'\n' filecontent = filecontent + urllib.quote_plus(server)+'\n' filecontent = filecontent + urllib.quote_plus(plot)+'\n' filecontent = filecontent + urllib.quote_plus(fulltitle)+'\n' filecontent = filecontent + urllib.quote_plus(canal)+'\n' # Genera el nombre de fichero from core import scrapertools filename = '%08d-%s.txt' % (filenumber, scrapertools.slugify(fulltitle)) logger.info("streamondemand.channels.favoritos savebookmark filename="+filename) # Graba el fichero if not samba.usingsamba(savepath): fullfilename = os.path.join(savepath, filename) bookmarkfile = open(fullfilename, "w") bookmarkfile.write(filecontent) bookmarkfile.flush() bookmarkfile.close() else: samba.store_File(filename, filecontent, savepath)
def mainlist(item): logger.info("streamondemand.channels.favoritos mainlist") itemlist = [] # Crea un listado con las entradas de favoritos if samba.usingsamba(BOOKMARK_PATH): ficheros = samba.get_files(BOOKMARK_PATH) else: ficheros = os.listdir(BOOKMARK_PATH) # Ordena el listado por nombre de fichero (orden de incorporación) ficheros.sort() # Rellena el listado for fichero in ficheros: try: # Lee el bookmark canal, titulo, thumbnail, plot, server, url, fulltitle = readbookmark(fichero) if canal == "": canal = "favoritos" # Crea la entrada # En extra va el nombre del fichero para poder borrarlo # <-- Añado fulltitle con el titulo de la peli itemlist.append(Item(channel=canal, action="play", url=url, server=server, title=fulltitle, thumbnail=thumbnail, plot=plot, fanart=thumbnail, extra=os.path.join(BOOKMARK_PATH, fichero), fulltitle=fulltitle, folder=False)) except: for line in sys.exc_info(): logger.error("%s" % line) return itemlist
def readbookmark(filename, readpath=BOOKMARK_PATH): logger.info("deportesalacarta.channels.favoritos readbookmark") if samba.usingsamba(readpath): bookmarkfile = samba.get_file_handle_for_reading(filename, readpath) else: filepath = os.path.join(readpath, filename) # Lee el fichero de configuracion logger.info("deportesalacarta.channels.favoritos filepath=" + filepath) bookmarkfile = open(filepath) lines = bookmarkfile.readlines() try: titulo = urllib.unquote_plus(lines[0].strip()) except: titulo = lines[0].strip() try: url = urllib.unquote_plus(lines[1].strip()) except: url = lines[1].strip() try: thumbnail = urllib.unquote_plus(lines[2].strip()) except: thumbnail = lines[2].strip() try: server = urllib.unquote_plus(lines[3].strip()) except: server = lines[3].strip() try: plot = urllib.unquote_plus(lines[4].strip()) except: plot = lines[4].strip() # Campos fulltitle y canal añadidos if len(lines) >= 6: try: fulltitle = urllib.unquote_plus(lines[5].strip()) except: fulltitle = lines[5].strip() else: fulltitle = titulo if len(lines) >= 7: try: canal = urllib.unquote_plus(lines[6].strip()) except: canal = lines[6].strip() else: canal = "" bookmarkfile.close() return canal, titulo, thumbnail, plot, server, url, fulltitle
def readbookmark(filename, readpath=BOOKMARK_PATH): logger.info("streamondemand.channels.favoritos readbookmark") if samba.usingsamba(readpath): bookmarkfile = samba.get_file_handle_for_reading(filename, readpath) else: filepath = os.path.join(readpath, filename) # Lee el fichero de configuracion logger.info("streamondemand.channels.favoritos filepath="+filepath) bookmarkfile = open(filepath) lines = bookmarkfile.readlines() try: titulo = urllib.unquote_plus(lines[0].strip()) except: titulo = lines[0].strip() try: url = urllib.unquote_plus(lines[1].strip()) except: url = lines[1].strip() try: thumbnail = urllib.unquote_plus(lines[2].strip()) except: thumbnail = lines[2].strip() try: server = urllib.unquote_plus(lines[3].strip()) except: server = lines[3].strip() try: plot = urllib.unquote_plus(lines[4].strip()) except: plot = lines[4].strip() # Campos fulltitle y canal añadidos if len(lines) >= 6: try: fulltitle = urllib.unquote_plus(lines[5].strip()) except: fulltitle = lines[5].strip() else: fulltitle = titulo if len(lines) >= 7: try: canal = urllib.unquote_plus(lines[6].strip()) except: canal = lines[6].strip() else: canal = "" bookmarkfile.close() return canal, titulo, thumbnail, plot, server, url, fulltitle
def deletebookmark(fullfilename, deletepath=BOOKMARK_PATH): logger.info("streamondemand.channels.favoritos deletebookmark(fullfilename="+fullfilename+",deletepath="+deletepath+")") if not samba.usingsamba(deletepath): os.remove(os.path.join(urllib.unquote_plus(deletepath), urllib.unquote_plus(fullfilename))) else: fullfilename = fullfilename.replace("\\", "/") partes = fullfilename.split("/") filename = partes[len(partes)-1] logger.info("streamondemand.channels.favoritos filename="+filename) logger.info("streamondemand.channels.favoritos deletepath="+deletepath) samba.delete_files(filename, deletepath)
from core import downloadtools from core import logger from core import servertools from core.item import Item from lib.sambatools import libsmb as samba from platformcode import library import favoritos CHANNELNAME = "descargas" DEBUG = config.get_setting("debug") DOWNLOAD_LIST_PATH = config.get_setting("downloadlistpath") IMAGES_PATH = os.path.join(config.get_runtime_path(), 'resources', 'images') ERROR_PATH = library.join_path(DOWNLOAD_LIST_PATH, 'error') usingsamba = samba.usingsamba(DOWNLOAD_LIST_PATH) def mainlist(item): logger.info("[descargas.py] mainlist") itemlist = [] # Lee la ruta de descargas downloadpath = config.get_setting("downloadpath") logger.info("[descargas.py] downloadpath=" + downloadpath) itemlist.append(Item(channel="descargas", action="pendientes", title="Descargas pendientes")) itemlist.append(Item(channel="descargas", action="errores", title="Descargas con error")) # Añade al listado de XBMC
# logger.info("channels.descargas DOWNLOAD_LIST_PATH convertido= " + # DOWNLOAD_LIST_PATH) # Lee la ruta de descargas if downloadpath.startswith("special://"): downloadpath = xbmc.translatePath(downloadpath) # logger.info("channels.descargas downloadpath convertido= " + downloadpath) else: # logger.info("channels.descargas DOWNLOAD_LIST_PATH (no Kodi)=" + DOWNLOAD_LIST_PATH) # logger.info("channels.descargas downloadpath (no Kodi)=" + downloadpath) pass IMAGES_PATH = filetools.join(config.get_runtime_path(), 'resources', 'images') ERROR_PATH = filetools.join(DOWNLOAD_LIST_PATH, 'error') usingsamba = samba.usingsamba(DOWNLOAD_LIST_PATH) def mainlist(item): logger.info("[descargas.py] mainlist") itemlist = [] logger.info("[descargas.py] downloadpath=" + downloadpath) itemlist.append( Item(channel="descargas", action="pendientes", title="download in sospeso")) itemlist.append( Item(channel="descargas", action="errores",
import os import sys import urllib from lib.sambatools import libsmb as samba from core import config from core import logger from core.item import Item CHANNELNAME = "favoritos" DEBUG = config.get_setting("debug") BOOKMARK_PATH = config.get_setting("bookmarkpath") if not samba.usingsamba(BOOKMARK_PATH): if BOOKMARK_PATH == "": BOOKMARK_PATH = os.path.join(config.get_data_path(), "bookmarks") def mainlist(item): logger.info("pelisalacarta.channels.favoritos mainlist") itemlist = [] # Crea un listado con las entradas de favoritos if samba.usingsamba(BOOKMARK_PATH): ficheros = samba.get_files(BOOKMARK_PATH) else: ficheros = os.listdir(BOOKMARK_PATH) # Ordena el listado por nombre de fichero (orden de incorporación) ficheros.sort()