def create_tvshows_from_json(_actualizado):
    logger.info(
        "streamondemand.platformcode.library_service create_tvshows_from_json")
    fname = filetools.join(config.get_data_path(), library.TVSHOW_FILE)

    if filetools.exists(fname):
        if not _actualizado:
            platformtools.dialog_ok(
                "Biblioteca: Actualizando formato",
                "Espere por favor mientras se completa el proceso")

        try:
            data = jsontools.loads(filetools.read(fname))
            for tvshow in data:
                for channel in data[tvshow]["channels"]:

                    serie = Item(contentSerieName=data[tvshow]["channels"]
                                 [channel]["tvshow"],
                                 url=data[tvshow]["channels"][channel]["url"],
                                 channel=channel,
                                 action="episodios",
                                 title=data[tvshow]["name"],
                                 active=True)
                    if not tvshow.startswith("t_"):
                        serie.infoLabels["tmdb_id"] = tvshow
                    library.save_library_tvshow(serie, list())

            filetools.rename(fname, "series.json.old")

        except EnvironmentError:
            logger.info("ERROR al leer el archivo: {0}".format(fname))
Beispiel #2
0
    def fromurl(self, url):
        '''
        Genera un item a partir de una cadena de texto. La cadena puede ser creada por la funcion tourl() o tener
        el formato antiguo: plugin://plugin.video.pelisalacarta/?channel=... (+ otros parametros)
        Uso: item.fromurl("cadena")
        '''
        if "?" in url: url = url.split("?")[1]
        try:
            STRItem = base64.b64decode(urllib.unquote(url))
            JSONItem = json.loads(STRItem, object_hook=self.toutf8)
            self.__dict__.update(JSONItem)
        except:
            url = urllib.unquote_plus(url)
            dct = dict([[param.split("=")[0],
                         param.split("=")[1]] for param in url.split("&")
                        if "=" in param])
            self.__dict__.update(dct)
            self.__dict__ = self.toutf8(self.__dict__)

        if 'infoLabels' in self.__dict__ and not isinstance(
                self.__dict__['infoLabels'], InfoLabels):
            self.__dict__['infoLabels'] = InfoLabels(
                self.__dict__['infoLabels'])

        return self
def create_tvshows_from_json(_actualizado):
    logger.info("pelisalacarta.platformcode.library_service create_tvshows_from_json")
    fname = filetools.join(config.get_data_path(), library.TVSHOW_FILE)

    if filetools.exists(fname):
        if not _actualizado:
            platformtools.dialog_ok("Biblioteca: Actualizando formato",
                                    "Espere por favor mientras se completa el proceso")

        try:
            data = jsontools.loads(filetools.read(fname))
            for tvshow in data:
                for channel in data[tvshow]["channels"]:

                    serie = Item(contentSerieName=data[tvshow]["channels"][channel]["tvshow"],
                                 url=data[tvshow]["channels"][channel]["url"], channel=channel, action="episodios",
                                 title=data[tvshow]["name"], active=True)
                    if not tvshow.startswith("t_"):
                        serie.infoLabels["tmdb_id"] = tvshow
                    library.save_library_tvshow(serie, list())

            filetools.rename(fname, "series.json.old")

        except EnvironmentError:
            logger.info("ERROR al leer el archivo: {0}".format(fname))
 def fromurl(self, url):
     """
     Genera un item a partir de la cadena de texto creada por la funcion tourl()
     Uso: item.fromurl("cadena")
     """
     STRItem = base64.b64decode(urllib.unquote(url))
     JSONItem = json.loads(STRItem, object_hook=self.toutf8)
     self.__dict__.update(JSONItem)
     return self
 def fromurl(self, url):
     '''
     Genera un item a partir de la cadena de texto creada por la funcion tourl()
     Uso: item.fromurl("cadena")
     '''
     STRItem = base64.b64decode(urllib.unquote(url))
     JSONItem = json.loads(STRItem, object_hook=self.toutf8)
     self.__dict__.update(JSONItem)
     return self
    def fromjson(self, STRItem={}, path=""):
        """
        Genera un item a partir de un archivo JSON
        Si se especifica un path, lee directamente el archivo, si no, lee la cadena de texto pasada.
        Usos: item = Item().fromjson(path="ruta\archivo\json.json")
              item = Item().fromjson("Cadena de texto json")
        """
        if path:
            if os.path.exists(path):
                STRItem = open(path, "rb").read()
            else:
                STRItem = {}

        JSONItem = json.loads(STRItem, object_hook=self.toutf8)
        self.__dict__.update(JSONItem)
        return self
    def fromjson(self, STRItem={}, path=""):
        '''
        Genera un item a partir de un archivo JSON
        Si se especifica un path, lee directamente el archivo, si no, lee la cadena de texto pasada.
        Usos: item = Item().fromjson(path="ruta\archivo\json.json")
              item = Item().fromjson("Cadena de texto json")
        '''
        if path:
            if os.path.exists(path):
                STRItem = open(path, "rb").read()
            else:
                STRItem = {}

        JSONItem = json.loads(STRItem, object_hook=self.toutf8)
        self.__dict__.update(JSONItem)
        return self
Beispiel #8
0
 def fromurl(self, url):
     '''
     Genera un item a partir de una cadena de texto. La cadena puede ser creada por la funcion tourl() o tener
     el formato antiguo: plugin://plugin.video.pelisalacarta/?channel=... (+ otros parametros)
     Uso: item.fromurl("cadena")
     '''
     if "?" in url: url = url.split("?")[1]
     try:
         STRItem = base64.b64decode(urllib.unquote(url))
         JSONItem = json.loads(STRItem, object_hook=self.toutf8)
         self.__dict__.update(JSONItem)
     except:
         url = urllib.unquote_plus(url)
         dct = dict([[param.split("=")[0], param.split("=")[1]] for param in url.split("&") if "=" in param])
         self.__dict__.update(dct)
         self.__dict__ = self.toutf8(self.__dict__)
     return self