Ejemplo n.º 1
0
def decode_adfly(data):
    import base64
    ysmm = scrapertools.find_single_match(data, "var ysmm = '([^']+)'")
    left = ''
    right = ''
    for c in [ysmm[i:i + 2] for i in range(0, len(ysmm), 2)]:
        left += c[0]
        right = c[1] + right

    decoded_url = base64.b64decode(left.encode() + right.encode())[2:].decode()
    return decoded_url
Ejemplo n.º 2
0
def get_server_parameters(server):
    server=scrapertools.find_single_match(server,'([^\.]+)')
    try:
      JSONFile =  xml2dict(os.path.join(config.get_runtime_path(),"servers", server + ".xml"))["server"]
      if type(JSONFile["premium"]) == dict: JSONFile["premium"]=JSONFile["premium"]["value"]
      if JSONFile["premium"] == "": JSONFile["premium"]=[]
      if type(JSONFile["premium"]) == str and not JSONFile["premium"] == "": JSONFile["premium"]=[JSONFile["premium"]]
      return JSONFile
    except:
      logger.info("Error al cargar el servidor: " + server)
      import traceback
      logger.info(traceback.format_exc())
      return {}
Ejemplo n.º 3
0
def start():
    tecla_guardada = config.get_setting("keymap_edit", "editor_keymap")
    nuevakey = KeyListener().record_key()
    if nuevakey and tecla_guardada != nuevakey:
        from resources.lib.httpkir import filetools
        from platformcode import platformtools
        import xbmc
        file_xml = "special://profile/keymaps/deportesalacarta.xml"
        data = '<keymap><global><keyboard><key id="%s">' % nuevakey + 'runplugin(plugin://' \
               'plugin.video.dss/?ewogICAgImFjdGlvbiI6ICJzdGFydCIsIAogICAgImNoYW5uZWwiOiAibWF0Y2hjZ' \
               'W50ZXIiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D))</key></keyboard></global></keymap>'
        filetools.write(xbmc.translatePath(file_xml), data)
        platformtools.dialog_notification(
            "Tecla guardada", "Reinicia Kodi para que se apliquen los cambios")

        from resources.lib.httpkir import scrapertools
        config.set_setting("keymap_edit", nuevakey, "editor_keymap")
        file_idioma = filetools.join(config.get_runtime_path(), 'resources',
                                     'language', 'Spanish', 'strings.xml')
        data = filetools.read(file_idioma)
        value_xml = scrapertools.find_single_match(
            data, '<string id="31100">([^<]+)<')
        if "tecla" in value_xml:
            data = data.replace(
                value_xml,
                'Cambiar tecla/botón para abrir la ventana (Guardada: %s)' %
                nuevakey)
        elif "key" in value_xml:
            data = data.replace(
                value_xml,
                'Change key/button to open the window (Saved: %s)' % nuevakey)
        else:
            data = data.replace(
                value_xml,
                'Cambiamento di chiave/pulsante per aprire la finestra (Salvato: %s)'
                % nuevakey)
        filetools.write(file_idioma, data)

    return
Ejemplo n.º 4
0
def get_video_url(page_url,
                  premium=False,
                  user="",
                  password="",
                  video_password=""):
    logger.info("(page_url='%s')" % page_url)

    if not page_url.startswith("http"):
        page_url = "http://www.youtube.com/watch?v=%s" % page_url
        logger.info(" page_url->'%s'" % page_url)

    if "shared?ci=" in page_url:
        response = httptools.downloadpage(page_url, follow_redirects=False)
        if "watch?v=" in response.headers.get("location", ""):
            page_url = response.headers["location"]

    video_id = scrapertools.find_single_match(page_url, 'v=([A-z0-9_-]{11})')
    video_urls = extract_videos(video_id)
    video_urls.reverse()

    for video_url in video_urls:
        logger.info(str(video_url))

    return video_urls
Ejemplo n.º 5
0
        elif hasattr(e, 'code'):
            logger.info("dss.platformcode.launcher codigo de error HTTP : %d" %
                        e.code)
            # "El sitio web no funciona correctamente (error http %d)"
            platformtools.dialog_ok(
                "plugin",
                config.get_localized_string(30051) % e.code)

    except:
        import traceback
        logger.error("dss.platformcode.launcher " + traceback.format_exc())

        patron = 'File "' + os.path.join(config.get_runtime_path(), "channels",
                                         "").replace("\\",
                                                     "\\\\") + '([^.]+)\.py"'
        canal = scrapertools.find_single_match(traceback.format_exc(), patron)

        try:
            xbmc_version = int(
                xbmc.getInfoLabel("System.BuildVersion").split(".", 1)[0])
            if xbmc_version > 13:
                log_name = "kodi.log"
            else:
                log_name = "xbmc.log"
            log_message = "Ruta: " + xbmc.translatePath(
                "special://logpath") + log_name
        except:
            log_message = ""

        if canal:
            platformtools.dialog_ok(
Ejemplo n.º 6
0
def extract_videos(video_id):
    fmt_value = {
        5: "240p h263 flv",
        6: "240p h263 flv",
        18: "360p h264 mp4",
        22: "720p h264 mp4",
        26: "???",
        33: "???",
        34: "360p h264 flv",
        35: "480p h264 flv",
        36: "3gpp",
        37: "1080p h264 mp4",
        38: "4K h264 mp4",
        43: "360p vp8 webm",
        44: "480p vp8 webm",
        45: "720p vp8 webm",
        46: "1080p vp8 webm",
        59: "480p h264 mp4",
        78: "480p h264 mp4",
        82: "360p h264 3D",
        83: "480p h264 3D",
        84: "720p h264 3D",
        85: "1080p h264 3D",
        100: "360p vp8 3D",
        101: "480p vp8 3D",
        102: "720p vp8 3D"
    }

    url = 'http://www.youtube.com/get_video_info?video_id=%s&eurl=https://youtube.googleapis.com/v/%s&ssl_stream=1' % \
          (video_id, video_id)
    data = httptools.downloadpage(url).data

    video_urls = []
    params = dict(urlparse.parse_qsl(data))
    if params.get('hlsvp'):
        video_urls.append(["(LIVE .m3u8) [youtube]", params['hlsvp']])
        return video_urls

    if config.is_xbmc():
        import xbmc
        xbmc_version = int(
            xbmc.getInfoLabel("System.BuildVersion").split(".", 1)[0])
        if xbmc_version > 16 and xbmc.getCondVisibility('System.HasAddon(inputstream.adaptive)') \
                             and params.get('dashmpd'):
            if params.get('use_cipher_signature', '') != 'True':
                video_urls.append(
                    ['mpd  HD [youtube]', params['dashmpd'], 0, '', True])

    js_signature = ""
    youtube_page_data = httptools.downloadpage(
        "http://www.youtube.com/watch?v=%s" % video_id).data
    params = extract_flashvars(youtube_page_data)
    if params.get('url_encoded_fmt_stream_map'):
        data_flashvars = params["url_encoded_fmt_stream_map"].split(",")
        for url_desc in data_flashvars:
            url_desc_map = dict(urlparse.parse_qsl(url_desc))
            if not url_desc_map.get("url") and not url_desc_map.get("stream"):
                continue

            try:
                key = int(url_desc_map["itag"])
                if not fmt_value.get(key):
                    continue

                if url_desc_map.get("url"):
                    url = urllib.unquote(url_desc_map["url"])
                elif url_desc_map.get("conn") and url_desc_map.get("stream"):
                    url = urllib.unquote(url_desc_map["conn"])
                    if url.rfind("/") < len(url) - 1:
                        url += "/"
                    url += urllib.unquote(url_desc_map["stream"])
                elif url_desc_map.get(
                        "stream") and not url_desc_map.get("conn"):
                    url = urllib.unquote(url_desc_map["stream"])

                if url_desc_map.get("sig"):
                    url += "&signature=" + url_desc_map["sig"]
                elif url_desc_map.get("s"):
                    sig = url_desc_map["s"]
                    if not js_signature:
                        urljs = scrapertools.find_single_match(
                            youtube_page_data, '"assets":.*?"js":\s*"([^"]+)"')
                        urljs = urljs.replace("\\", "")
                        if urljs:
                            if not re.search(r'https?://', urljs):
                                urljs = urlparse.urljoin(
                                    "https://www.youtube.com", urljs)
                            data_js = httptools.downloadpage(urljs).data
                            from jsinterpreter import JSInterpreter
                            funcname = scrapertools.find_single_match(
                                data_js, '\.sig\|\|([A-z0-9$]+)\(')
                            if not funcname:
                                funcname = scrapertools.find_single_match(
                                    data_js, '["\']signature["\']\s*,\s*'
                                    '([A-z0-9$]+)\(')
                            jsi = JSInterpreter(data_js)
                            js_signature = jsi.extract_function(funcname)

                    signature = js_signature([sig])
                    url += "&signature=" + signature
                url = url.replace(",", "%2C")
                video_urls.append(["" + fmt_value[key] + " -YouTube", url])
            except:
                import traceback
                logger.info(traceback.format_exc())

    return video_urls