示例#1
0
def update():
    #download ZIP file
    start = time.clock()

    localfile = ROOT_DIR+"/update.zip"

    response = urllib2.urlopen(REMOTE_FILE_XML)
    html = response.read()
    remote_file = common.parseDOM(html,"file")[0].encode("utf-8") #remote version
    downloadtools.downloadfile(remote_file, localfile, notStop=False)

    end = time.clock()
    logger.info("org.harddevelop.kodi.tv Downloaded in %d seconds " % (end-start+1))

    separatorChar = XBMCUtils.getSeparatorChar()

    #unzip
    unzipper = ziptools.ziptools()
    logger.info("org.harddevelop.kodi.tv destpathname=%s" % ROOT_DIR)
    addons_dir = XBMCUtils.getAddonsDir()
    current_plugin_dir = XBMCUtils.getPathFixedFrom(XBMCUtils.getAddonInfo('path'))
    logger.debug("using dir: "+addons_dir+" to extract content")

    unzipper.extractReplacingMainFolder(localfile,addons_dir,current_plugin_dir) #github issues
    #unzipper.extract(localfile,ROOT_DIR)

    #clean downloaded zip file
    logger.info("org.harddevelop.kodi.tv clean zip file...")
    os.remove(localfile)
    logger.info("org.harddevelop.kodi.tv clean done!")
示例#2
0
    def getChannels(page):
        x = []
        logger.debug("page: " + page)
        if (str(page) == "0"):
            html = Peliculasbiz.getContentFromUrl(Peliculasbiz.MAIN_URL)
            menuHtml = Decoder.extract('<ul class="clearfix">', '</ul>', html)
            for itemHtml in menuHtml.split("<li>"):
                if "href=" in itemHtml:
                    item = {}
                    item["title"] = Decoder.extract('">', '<', itemHtml)
                    item["link"] = Decoder.extract('href="', '"', itemHtml)
                    x.append(item)
            search = {}
            search["title"] = XBMCUtils.getString(11018)
            search["link"] = ".search"
            x.append(search)

        elif page == '.search':
            #display keyboard, it will wait for result
            keyboard = XBMCUtils.getKeyboard()
            keyboard.doModal()
            text = ""
            if (keyboard.isConfirmed()):
                text = keyboard.getText()
                x = Peliculasbiz.search(text)
        elif str(page).isdigit():
            logger.debug("numeric detected...")
            link = Peliculasbiz.extractProviderFromLink(page)
            element = {}
            element["link"] = link
            x.append(element)
        else:
            x = Peliculasbiz.extractProvidersFromLink(page)

        return x
示例#3
0
def add_dir(name, url, mode, iconimage, provider, page="", thumbnailImage=''):
    type = "Video"
    u = sys.argv[0] + "?url=" + urllib.quote_plus(
        url.decode('utf-8', 'replace').encode('iso-8859-1', 'replace'))
    u += "&mode=" + str(mode) + "&page="
    try:
        u += urllib.quote_plus(str(page))
    except:
        u += page
        pass
    provider = str(provider)
    u += "&provider=" + urllib.quote_plus(
        provider.decode('utf-8', 'replace').encode('iso-8859-1', 'replace'))
    ok = True
    liz = XBMCUtils.getList(name,
                            iconImage=iconimage,
                            thumbnailImage=iconimage)
    liz.setInfo(type='Video', infoLabels={'Title': name})
    if mode == 2 or (
            mode >= 100 and mode <= MAX
    ):  #playable, not browser call, needs decoded to be playable or rtmp to be obtained
        liz.setProperty("IsPlayable", "true")
        liz.setPath(url)
        ok = XBMCUtils.addPlayableDirectory(handle=int(sys.argv[1]),
                                            url=u,
                                            listitem=liz)  #Playable)
    else:
        liz.setProperty('Fanart_Image', thumbnailImage)
        ok = XBMCUtils.addDirectory(sys.argv[1], url=u, listitem=liz)  #Folder

    return ok
示例#4
0
    def getChannels(page='0'):
        x = []
        if str(page) == '0':
            page = Youtube.MAIN_URL + "/"
            html = Youtube.getContentFromUrl(page, "", Youtube.cookie, "")
            logger.debug("html: " + html)
            jsonScript = Decoder.extract('ytInitialGuideData = ', ';', html)
            x = Youtube.extractMainChannelsJSON(jsonScript)
            element = {}
            element["title"] = XBMCUtils.getString(11018)
            element["page"] = 'search'
            x.append(element)
        elif '/channel/' in page or '/trending' in page:
            headers = Youtube.buildHeaders()
            response = Youtube.getContentFromUrl(url=str(page + "?pbj=1"),
                                                 headers=headers,
                                                 launchLocation=True)
            try:
                jsonResponse = json.loads(response)
                logger.debug("parsed json from '" + page + "', continue...")
                logger.debug("json is: " + response)
                try:
                    logger.debug("using way 1...")
                    x = Youtube.extractVideosFromJSON(
                        jsonResponse[1]["response"])
                except:
                    logger.debug("fails way 1, using way 2...")
                    x = Youtube.extractVideosFromSpecialChannelJSON(
                        jsonResponse[1]["response"])
                    pass
            except:
                logger.error("Could not parse response: " + str(response))
                pass
        elif str(page) == 'search':
            keyboard = XBMCUtils.getKeyboard()
            keyboard.doModal()
            text = ""
            if (keyboard.isConfirmed()):
                text = keyboard.getText()
                text = urllib.quote_plus(text)

                headers = Youtube.buildHeaders()
                response = Youtube.getContentFromUrl(
                    url=str(Youtube.SEARCH_URL + text + "?pbj=1"),
                    headers=headers)
                try:
                    jsonResponse = json.loads(response)
                    logger.debug("parsed search json with text: '" + page +
                                 "', continue...")
                    x = Youtube.extractVideosFromSpecialChannelJSON(
                        jsonResponse[1]["response"])
                except:
                    logger.error("Could not parse response: " + str(response))
                logger.debug("finished search logic!")
        else:
            element = Youtube.extractTargetVideoJSON(page)
            x.append(element)
        return x
示例#5
0
    def getChannels(page):
        x = []
        if str(page) == '0':

            try:
                page=Arenavisionin.MAIN_URL+"guide"
                html = Arenavisionin.getContentFromUrl(page,"",'beget=begetok; has_js=1',Arenavisionin.MAIN_URL)
                #guideUrl = Decoder.rExtract('"','">EVENTS GUIDE</a></li>',html)
                #html = Arenavisionin.getContentFromUrl(page+guideUrl,"",'beget=begetok; has_js=1',Arenavisionin.MAIN_URL)
            except:
                page = Arenavisionin.MAIN_URL_RU+"guide"
                html = Arenavisionin.getContentFromUrl(page, "", 'beget=begetok; has_js=1', Arenavisionin.MAIN_URL_RU)
                #guideUrl = Decoder.rExtract('"', '">EVENTS GUIDE</a></li>', html)
                #html = Arenavisionin.getContentFromUrl(page+guideUrl, "", 'beget=begetok; has_js=1', Arenavisionin.MAIN_URL_RU)
                pass
            html = Decoder.extract('<table align="center" cellspacing="1" class="auto-style1" style="width: 100%; float: left"><tr><th class="auto-style4" style="width: 190px; height: 39px"><strong>DAY</strong></th>',"</tr></table></div></div></div>",html)
            x = Arenavisionin.extractElements(html)
        else:
            if page.find("-")>-1:
                #put a context menu and the user should decice, if not use the first one (default action)
                dialog = XBMCUtils.getDialog()
                cmenu = []
                for contextItem in page.split("-"):
                    #if len(contextItem)>0:
                    cmenu.append(contextItem)
                result = dialog.select(XBMCUtils.getString(11016), cmenu) #choose
                logger.debug("result was: "+str(result))
                if result == None or result==-1:
                    target = page[:page.find("-")]
                    page = target
                else:
                    logger.debug("has choosed "+str(result)+": "+cmenu[result])
                    page = (cmenu[result])
                html = Arenavisionin.getContentFromUrl(Arenavisionin.MAIN_URL, "", 'beget=begetok; has_js=1', Arenavisionin.MAIN_URL)
                link = Decoder.rExtract("<a href=\"","title=\"\">ArenaVision "+page+"</a>",html)
                logger.debug("html is: "+html)
                link = link[:link.find('"')]
                logger.debug("provisional link is: "+link)
            else:
                if "av" not in page:
                    page = "av"+page
                link = "http://www.arenavision.us/"+page
            try:
                html = Arenavisionin.getContentFromUrl(link,"",'beget=begetok; has_js=1',Arenavisionin.MAIN_URL)
                logger.debug("second html is: "+html)
            except:
                logger.error("sonething goes wrong with link: "+link)
                pass
            if html.find("acestream://")>-1:
                link2 = Decoder.extractWithRegex("acestream://",'"',html).replace('"',"")
            else:
                link2 = Decoder.extractWithRegex("sop://",'"',html).replace('"',"")
            element = {}
            element["title"] = page
            element["link"] = link2
            x.append(element)
        return x
示例#6
0
def httpProxyUpdater():
    masterPatchUrl = "https://github.com/harddevelop/httpproxy-service/archive/master.zip"
    try:
        updater.install(masterPatchUrl, "org.harddevelop.kodi.proxy",
                        "org.harddevelop.kodi.proxy")
        XBMCUtils.getOkDialog(XBMCUtils.getString(30060),
                              XBMCUtils.getString(30060))
        logger.debug("patch installed!")
    except:
        logger.error("Patch not installed, something wrong happened!")
        pass
示例#7
0
def play(url, page):
    listitem = XBMCUtils.getSimpleList(page)
    listitem.setProperty('IsPlayable', 'true')
    listitem.setPath(url)
    listitem.setInfo("video", page)
    try:
        #XBMCUtils.play(url,listitem)
        XBMCUtils.resolveListItem(sys.argv[1],
                                  listitem)  ##FIX FOR PREVIEWS LINE##
        #xbmc.executebuiltin('Dialog.Close(all, true)') ## could be returned an empty element in a list, so player open the next and shows a invalid popup
    except:
        pass
示例#8
0
def get_main_dirs():

    ##CONSTANTS PARTS##
    MAIN_URL = XBMCUtils.getSettingFromContext(sys.argv[1],
                                               "remote_repository")
    BROWSE_CHANNELS = "browse_channels"
    ICON = XBMCUtils.getAddonFilePath('icon.png')

    #draw welcome menu
    add_dir(XBMCUtils.getString(10001), MAIN_URL, 1, ICON, '', 0)
    add_dir(XBMCUtils.getString(10010), BROWSE_CHANNELS, 3, '', ICON, 0)
    try:
        from window.ImageWindow import windowImage  # teletext window library
        add_dir(name=XBMCUtils.getString(10012),
                url='teletext',
                mode=4,
                provider='teletext',
                page=0,
                thumbnailImage="",
                iconimage=ICON)
    except:
        logger.info("No PIL module installed (needs Pillow 3.4.2 or less)")
        pass
    add_dir(XBMCUtils.getString(10014), 'paidonline', 3, "", 'paidonline', 0)
    add_dir(XBMCUtils.getString(10015), 'programsonline', 3, "",
            'programsonline', 0)
    try:
        if updater.isUpdatable():
            add_dir(XBMCUtils.getString(10011), '', 0, ICON, 0)
    except:
        logger.error("Couldn't add update option: probably server is down!")
        pass
示例#9
0
    def getChannels(page):
        x = []
        logger.debug("page: "+page)
        if(str(page)=="0"):
            html = MejorTorrent.getContentFromUrl(url=MejorTorrent.MAIN_URL)
            menuHtml = Decoder.extract("<table width='140' border='0' cellpadding='0' cellspacing='0' style='border-left:1px solid black; border-right:1px solid black; border-bottom:1px solid black;'>",'</table>',html)
            for itemHtml in menuHtml.split("<a"):
                logger.debug("li --> HTML is: "+itemHtml)
                if "href=" in itemHtml:
                    item = {}
                    title = Decoder.extract('">','</a>',itemHtml)
                    title = Decoder.removeHTML(title)
                    if len(title)>0:
                        item["title"] = title
                        link = Decoder.extract("href='", "'", itemHtml)
                        if 'musica' not in link and 'juegos' not in link and 'variados' not in link:
                            if "://" not in link:
                                item["link"] = MejorTorrent.MAIN_URL+link
                            x.append(item)
            search = {}
            search["title"] = XBMCUtils.getString(11018)
            search["link"] = ".search"
            x.append(search)

        elif page=='.search':
            #display keyboard, it will wait for result
            keyboard = XBMCUtils.getKeyboard()
            keyboard.doModal()
            text = ""
            if (keyboard.isConfirmed()):
                text = keyboard.getText()
                x = MejorTorrent.search(text)
        elif '-descargar-' in page:
            logger.debug("-descargar- page detected...")
            x = MejorTorrent.extractProvidersFromLink(page)
        elif 'sec=descargas' in page and '&p=' not in page:
            logger.debug("decoding torrent..."+page)
            html = MejorTorrent.getContentFromUrl(url=page)
            link = MejorTorrent.MAIN_URL+Decoder.extract("Pincha <a href='/","'",html)
            logger.debug("extracted torrent link: "+link)
            element = {}
            element["link"] = link
            element["title"] = page
            element["finalLink"] = True
            x.append(element)
        else:
            x = MejorTorrent.extractContentFromLink(page)

        return x
示例#10
0
def drawZoptv(page):
    jsonChannels = Zoptvcom.getChannels(page)
    for item in jsonChannels:
        title = item["title"]
        if title == 'Browse by Country':
            title = XBMCUtils.getString(10007)
        elif title == 'Browse by Genre':
            title = XBMCUtils.getString(10008)
        link = item["link"]
        mode = 4
        if item.has_key("thumbnail"):
            image = item["thumbnail"]
            mode = 104
        else:
            image = icon
        add_dir(title, link, mode, image, "zoptv", link)
示例#11
0
 def getChannels(page):
     x = []
     logger.debug("using tvshowme...")
     if str(page) == '0':
         page = Tvshowme.MAIN_URL
         html = Tvshowme.getContentFromUrl(page, "", Tvshowme.cookie, "")
         table = Decoder.extract('<ul>', '</ul>', html)
         x = Tvshowme.extractElements(table)
     elif page == "search":
         #display keyboard, it will wait for result
         keyboard = XBMCUtils.getKeyboard()
         keyboard.doModal()
         text = ""
         if (keyboard.isConfirmed()):
             text = keyboard.getText()
             page = "http://www.tvshow.me/?s=" + urllib.quote(text)
         html = Tvshowme.getContentFromUrl(url=page)
         logger.debug(html)
         table = Decoder.extract('<div id="content"',
                                 '<h3 class="assistive-text">', html)
         logger.debug("table is: " + table)
         x = Tvshowme.extractLinks2(table)
     else:
         html = Tvshowme.getContentFromUrl(page, "", Tvshowme.cookie,
                                           Tvshowme.MAIN_URL)
         logger.debug(html)
         table = Decoder.extract('<div id="content"', '</article>', html)
         x = Tvshowme.extractLinks(table)
     return x
示例#12
0
文件: rtve.py 项目: djwayne1985/tvbox
 def getChannels(page):
     x = []
     subpage = RTVE.SUB_PAGE
     currentPage = page
     if str(page) == '0':
         page = "100"
         currentPage = page
         arr = [str(page), str(page)]  #page - subpage
         subpage = subpage % tuple(arr)
         page = RTVE.MAIN_URL + subpage  # final parse
     elif '.search' in str(page):
         keyboard = XBMCUtils.getKeyboard()
         keyboard.doModal()
         text = ""
         if (keyboard.isConfirmed()):
             text = keyboard.getText()
             page = text
             pageInt = page[0:1] + "00"
             arr = [str(pageInt), str(page)]  # page - subpage
             subpage = subpage % tuple(arr)
             currentPage = text
             page = RTVE.MAIN_URL + subpage  # final parse
     else:
         logger.debug("Nothing done for page: " + str(page))
         subpage = page[page.rfind("/") + 1:]
         subpage = subpage[:subpage.rfind("_")]
         logger.debug("Subpage is: " + str(subpage))
         currentPage = subpage
         page = page.replace("/" + subpage + "/", "/" + currentPage + "/")
     element = {}
     element["link"] = RTVE.MAIN_URL + ".search"
     element["title"] = XBMCUtils.getString(10013)
     x.append(element)
     html = RTVE.getContentFromUrl(url=page, referer=RTVE.MAIN_URL)
     element = {}
     element["thumbnail"] = Decoder.extract('<img id="FABTTXImage" src="',
                                            '"', html)
     if "://" not in element["thumbnail"]:
         thumbnailPage = element["thumbnail"][:element["thumbnail"].find("_"
                                                                         )]
         element["thumbnail"] = RTVE.MAIN_URL + (
             thumbnailPage[0:1] + "00") + "/" + element["thumbnail"]
     x.append(element)
     teletextHtml = Decoder.extract('<span class="LB">', '</span>', html)
     x2 = RTVE.extractElements(currentPage, teletextHtml)
     x.extend(x2)
     return x
示例#13
0
def getListsUrls(url,icon=XBMCUtils.getAddonFilePath('icon.png'),provider='',finalTarget=1):
    #logger.debug("using url: "+url)
    html = Downloader.getContentFromUrl(url)
    if url.endswith(".xml") or ('<items>' in html or '<item>' in html): #main channels, it's a list to browse
        drawXml(html,icon=icon,finalTarget=finalTarget,provider=provider)
    elif url.endswith(".xspf"):
        drawXspf(html,icon)
    else: #it's the final list channel, split
        drawBruteChannels(html,icon)
示例#14
0
def drawPastebinCom():
    param = urllib.quote_plus(
        str(XBMCUtils.getSettingFromContext(sys.argv[1], 'pastebin_param')))
    logger.debug("extracted param to be searched: " + param)
    channels = Pastebin.searchLists(param=param)
    logger.debug("items obtained: " + str(len(channels)))
    level = 1
    for channel in channels:
        add_dir(channel["title"], channel["link"], level, '', "pastebincom",
                channel["link"])
示例#15
0
    def getChannels(page):
        x = []
        logger.debug("page: " + page)
        cookie = Elitetorrent.getValidCookie()
        logger.debug("Using new cookie: " + cookie)
        if (str(page) == "0"):
            html = Elitetorrent.getContentFromUrl(url=Elitetorrent.MAIN_URL,
                                                  cookie=cookie)
            menuHtml = Decoder.extract('<div class="wrap">', '</div>', html)
            for itemHtml in menuHtml.split("<a"):
                logger.debug("li --> HTML is: " + itemHtml)
                if "href=" in itemHtml:
                    item = {}
                    item["title"] = Decoder.extract('">', '<', itemHtml)
                    link = Decoder.extract('href="', '"', itemHtml)
                    if "://" not in link:
                        item["link"] = Elitetorrent.MAIN_URL + link
                        x.append(item)
            search = {}
            search["title"] = XBMCUtils.getString(11018)
            search["link"] = ".search"
            x.append(search)

        elif page == '.search':
            #display keyboard, it will wait for result
            keyboard = XBMCUtils.getKeyboard()
            keyboard.doModal()
            text = ""
            if (keyboard.isConfirmed()):
                text = keyboard.getText()
                x = Elitetorrent.search(text, cookie)
        elif '/torrent/' in page:
            logger.debug("torrent page detected...")
            link = Elitetorrent.extractProviderFromLink(page, cookie)
            element = {}
            element["link"] = link
            x.append(element)
        else:
            x = Elitetorrent.extractContentFromLink(page, cookie)

        return x
示例#16
0
    def applyFix(fileFix, removeFix, replaced=''):
        logger.debug("Applying fix...")
        ROOT_DIR = XBMCUtils.getAddonInfo('path')
        # Read in the file
        pythonScript = ROOT_DIR + fileFix
        with open(pythonScript, 'r') as file:
            filedata = file.read()

        # Replace the target string
        filedata = filedata.replace(removeFix, replaced)

        # Write the file out again
        with open(pythonScript, 'w') as file:
            file.write(filedata)
示例#17
0
def drawAcetvru(page):
    mode = 2
    jsonChannels = Acetvru.getChannels(page)
    for item in jsonChannels:
        title = item["title"]
        if title == 'Display by event':
            title = XBMCUtils.getString(10006)
        link = item["link"]
        if item.has_key("thumbnail"):
            image = item["thumbnail"]
            logger.info("detected img: " + image)
        else:
            image = icon
        add_dir(title, link, mode, image, "acetvru", link)
示例#18
0
def drawVipgoal(page):
    jsonChannels = Vigoal.getChannels(page)
    for item in jsonChannels:
        title = item["title"]
        if title == 'Display by event':
            title = XBMCUtils.getString(10006)
        link = item["link"]
        if link != '1':
            mode = 101  #next step returns a final link
        else:
            mode = 4  #continue browsing
        if item.has_key("thumbnail"):
            image = item["thumbnail"]
        else:
            image = icon
        add_dir(title, link, mode, image, "vigoal", link)
示例#19
0
def drawShowsporttvcom(page):
    mode = 4
    jsonChannels = ShowsportTvCom.getChannels(page)
    for item in jsonChannels:
        title = item["title"]
        if title == 'Display by event':
            title = XBMCUtils.getString(10006)
        link = item["link"]
        if link != '1':
            mode = 113
        if item.has_key("thumbnail"):
            image = item["thumbnail"]
            logger.info("detected img: " + image)
        else:
            image = icon
        add_dir(title, link, mode, image, "showsporttvcom", link)
示例#20
0
def drawArenavisionin(page):
    mode = 4
    jsonChannels = Arenavisionin.getChannels(page)
    for item in jsonChannels:
        title = item["title"]
        if title == 'Display by event':
            title = XBMCUtils.getString(10006)
        link = item["link"]
        if link != '1':
            mode = 114
        if item.has_key("thumbnail"):
            image = item["thumbnail"]
            logger.info("detected img: " + image)
        else:
            image = icon
        add_dir(title, link, mode, image, "arenavisionin", link)
示例#21
0
def drawCricfree(page):
    jsonChannels = Cricfreetv.getChannels(page)
    for item in jsonChannels:
        title = item["title"]
        if title == 'Display by event':
            title = XBMCUtils.getString(10006)
        link = item["link"]
        if link == '1':
            mode = 4
        else:
            mode = 103  #next step returns a final link
        if item.has_key("thumbnail"):
            image = item["thumbnail"]
        else:
            image = icon
        add_dir(title, link, mode, image, "cricfree", link)
示例#22
0
def displayBBCTeletext(url, page, version):
    logger.debug("displaying teletext for BBC1 provider")
    imgPath = 'http://www.ceefax.tv/cgi-bin/gfx.cgi?font=big&channel=bbc' + version + '&page=100_0'  # first
    if '.search' in url:
        keyboard = XBMCUtils.getKeyboard()
        keyboard.doModal()
        text = ""
        if (keyboard.isConfirmed()):
            text = keyboard.getText()
            imgPath = imgPath[:imgPath.rfind('100_')] + text + '_0'
    imgPath = 'http://anonymous-images-proxy.com/proxy.php?url=' + urllib.quote(
        imgPath)
    add_dir('bbc' + version + '.search', 'bbc' + version + '.search', 4,
            'bbc' + version + 'teletext.search', 'teletext',
            'bbc' + version + 'teletext.search')
    # finally show img (before render, xbmc will wait until some event happens)
    displayImg(imgPath)
示例#23
0
def install(remote_file,id,folder):
    #first check if plexus exists, and where
    logger.info("installing "+id+"... ")

    addons_dir = XBMCUtils.getAddonsDir()
    logger.debug("Addons dir set to: "+addons_dir)

    localfile = ROOT_DIR+"/install.zip"

    downloadtools.downloadfile(remote_file, localfile, notStop=False)
    logger.debug("Download done, now it's time to unzip")
    unzipper = ziptools.ziptools()
    if folder == '':
        unzipper.extract(localfile,addons_dir) #github issues
    else:
        unzipper.extractReplacingMainFolder(localfile,addons_dir,folder)
    logger.debug("Unzip done! cleaning...")
    os.remove(localfile)
    logger.info("Additional addon clean done!")
示例#24
0
def plexusUpdater():
    if XBMCUtils.getDialogYesNo(XBMCUtils.getString(30050),
                                XBMCUtils.getString(30050)):
        try:
            # url = "http://repo.adryanlist.org/program.plexus-0.1.4.zip"
            url = "https://github.com/AlexMorales85/program.plexus/archive/1.2.2.zip"  # better and updated with an acestream fixed client for raspberry platforms
            updater.install(url, "program.plexus", "program.plexus")
            logger.debug("addon installed!")
            # try with request dependency
            updater.install(
                "https://github.com/beenje/script.module.requests/archive/gotham.zip",
                "script.module.requests", "script.module.requests")
            logger.debug("dependency installed, finished!")
        except:
            logger.error("Addon not installed, something wrong happened!")
            pass
        XBMCUtils.getOkDialog(XBMCUtils.getString(30051),
                              XBMCUtils.getString(30051))
        logger.debug("launch done!")
示例#25
0
    def importEngine(engine, url, targetPath, deletePath):

        ROOT_DIR = XBMCUtils.getAddonInfo('path')

        try:
            shutil.rmtree(ROOT_DIR + "/" + engine)
        except:
            logger.debug("local folder %s doesn't exists... continue" %
                         str(ROOT_DIR + "/" + engine))
            pass

        logger.debug("downloading...")

        localfile = ROOT_DIR + "/master.zip"

        try:
            os.delete(localfile)
        except:
            logger.debug("local file doesn't exists... continue")
            pass

        downloadtools.downloadfile(url, localfile, notStop=True)

        logger.debug("done, unzipping...")
        logger.debug("Download done, now it's time to unzip")
        unzipper = ziptools.ziptools()
        unzipper.extract(localfile, ROOT_DIR)
        shutil.move(ROOT_DIR + targetPath, ROOT_DIR + "/" + engine)
        logger.debug("done, delete all unused files...")
        shutil.rmtree(ROOT_DIR + "/" + deletePath)
        logger.debug("Unzip done! cleaning...")
        try:
            os.unlink(localfile)
        except:
            logger.debug("couldn't remove %s" % localfile)
            pass
        logger.info("Additional addon clean done!")
示例#26
0
    def getChannels(page):
        x = []
        logger.debug("page for pepecine: " + page)
        movie = 'movie'
        serie = 'series'
        if (str(page) == "0"):
            element = {}
            element["title"] = "Películas"
            element[
                "link"] = 'https://pepecine.tv/titles/paginate?_token=%s&perPage=50&page=1&order=mc_num_of_votesDesc&type=' + movie + '&minRating=&maxRating=&availToStream=1'
            x.append(element)
            element = {}
            element["title"] = "Series"
            element[
                "link"] = 'https://pepecine.tv/titles/paginate?_token=%s&perPage=50&page=1&order=mc_num_of_votesDesc&type=' + serie + '&minRating=&maxRating=&availToStream=1'
            x.append(element)
            last = {}
            last["title"] = "Últimas películas publicadas"
            last[
                "link"] = "https://pepecine.tv/plugins/estrenos-peliculas-online.php"
            x.append(last)
            last = {}
            last["title"] = "Últimas series actualizadas"
            last[
                "link"] = "https://pepecine.tv/plugins/estrenos-episodios-online.php"
            x.append(last)
            search = {}
            search["title"] = XBMCUtils.getString(11018)
            search["link"] = ".search"
            x.append(search)

        elif page == '.search':
            logger.debug("search page detected...")
            #display keyboard, it will wait for result
            keyboard = XBMCUtils.getKeyboard()
            keyboard.doModal()
            text = ""
            if (keyboard.isConfirmed()):
                text = keyboard.getText()
                x = Pepecine.search(text)
        elif '%s' in page:  #token issue
            logger.debug("list page detected...")
            x = Pepecine.extractProvidersFromLink(page)
        elif page.endswith("=") or "://" not in page:  #title in base64 format
            if "://" not in page:
                page += "="  #base64 could be missed
            title = base64.decodestring(page)
            logger.debug("trying to query by title: " + title)
            searchByTitle = "https://pepecine.tv/titles/paginate?_token=%s&perPage=24&page=1&order=mc_num_of_votesDesc&type=series&minRating=&maxRating=&query=" + urllib.quote_plus(
                title) + "&availToStream=true"
            #x = Pepecine.extractProvidersFromLink(searchByTitle,True)
            x = Pepecine.searchItemByTitle(title)
        elif '/ver-online/' in page:
            #extract links from html
            x = Pepecine.extractLinksFromPage(page)
        elif '/ver-serie/' in page:  #serie
            if '/seasons/' in page:
                if '/episodes/' in page:  #draw links
                    x = Pepecine.extractLinksFromPage(page)
                else:  #draw chapters
                    html = Pepecine.getContentFromUrl(
                        url=page, referer=Pepecine.MAIN_URL)
                    episodesHtml = Decoder.extract(
                        '<ul class="list-unstyled" id="episode-list" data-bind="moreLess, playVideos">',
                        '</ul>', html)
                    i = 0
                    for episodeHtml in episodesHtml.split(
                            '<li class="media bord">'):
                        if i > 0:
                            link = Decoder.extract(
                                '<a class="col-sm-3" href="', '"', episodeHtml)
                            img = Decoder.extract(
                                '<img class="media-object img-responsive" src="',
                                '"', episodeHtml)
                            title = Decoder.extract('"><b>', '</a></h4>',
                                                    episodeHtml)
                            element = {}
                            element["link"] = link
                            element["thumbnail"] = img
                            element["title"] = title.replace("</b>", " - ")
                            x.append(element)
                        i += 1
            else:  #draw seasons
                html = Pepecine.getContentFromUrl(url=page,
                                                  referer=Pepecine.MAIN_URL)
                seasonsHtml = Decoder.extract(
                    '<div class="heading bord" style="margin:0 -15px;">',
                    '<br>', html)
                i = 0
                for seasonHtml in seasonsHtml.split('<a '):
                    if i > 0:
                        link = Decoder.extract('href="', '"', seasonHtml)
                        title = Decoder.extract('class="sezon">', "<",
                                                seasonHtml)
                        element = {}
                        element["title"] = title
                        element["link"] = link
                        x.append(element)
                    i += 1
        elif '/plugins/' in page:  #last films and series
            html = Pepecine.getContentFromUrl(url=page,
                                              referer=Pepecine.MAIN_URL)
            i = 0
            for line in html.split('<td><a'):
                if i > 0:
                    link = Pepecine.MAIN_URL + Decoder.extract(
                        'href=', " ", line)
                    title = Decoder.extract(' alt="', '"', line)
                    img = Decoder.extract('<img src=', ' ', line)
                    element = {}
                    element["title"] = title
                    element["link"] = link
                    element["thumbnail"] = img
                    x.append(element)
                i += 1
        else:
            logger.debug("nothing done for page: " + page)
        return x
示例#27
0
    def getChannels(page):
        x = []
        if page == '0':
            keyboard = XBMCUtils.getKeyboard()
            keyboard.doModal()
            text = ""
            if (keyboard.isConfirmed()):
                text = keyboard.getText()
                if len(text)>0:
                    page = TuneIn.SEARCH_PAGE+urllib.quote_plus(text)
                    results = TuneIn.getContentFromUrl(page,ajax=True,referer=TuneIn.MAIN_URL)
                    logger.debug("resultHtml is: "+results)
                    jsonResults = json.loads(results)

                    for resultKind in jsonResults["Items"]:
                        logger.debug("items...")
                        for result in resultKind["Children"]:
                            logger.debug("children...")
                            element = {}
                            img = result["Image"]
                            logger.debug("image is: "+img)
                            guideId = result["GuideId"]
                            url = result["Actions"]["Echo"]["Url"]
                            logger.debug("url is: " + url)
                            id = result["Actions"]["Echo"]["TargetItemId"]#[1:]
                            logger.debug("id is: " + id)
                            #https://api.radiotime.com/profiles/me/activities?serial=11f2610a-b534-41c5-96b4-ccbfd5a6d4c8&partnerId=RadioTime&version=2&formats=mp3%2caac%2cogg%2cflash%2chtml&itemToken=BgQEAAEAAQABAAEACwsAAwQFDAAA
                            serial = url[url.rfind("serial=") + len("serial="):]
                            if "&" in serial:
                                serial = serial[:serial.find("&")]
                            itemToken = url[url.rfind("itemToken=")+len("itemToken="):]
                            if "&" in itemToken:
                                itemToken = itemToken[:itemToken.find("&")]
                            title = result["Title"]
                            link = TuneIn.GUIDE_URL % (id,itemToken,serial)
                            logger.debug("appending result: "+title+", url: "+link)
                            element["title"] = title
                            element["link"] = link
                            element["thumbnail"] = img
                            element["finalLink"] = True
                            x.append(element)

        else:
            logger.debug("extracting stream for: "+page)
            html = TuneIn.getContentFromUrl(url=page)
            logger.debug("decoded html is: "+html)
            #content = json.loads(html)
            element = {}
            while 'https://stream.radiotime.com/listen.stream' in html:
                logger.debug("old html is: " + html)
                html = TuneIn.getContentFromUrl(url=html)
                logger.debug("new html is: " + html)

            if "http://" in html and '"' in html:
                html = html[:html.find('"')]
            elif "http://" in html and "'" in html:
                html = html[:html.find("'")]
            else:
                logger.debug("nothing done")
            logger.debug("new URL is: "+html)
            link = html

            element["link"] = link
            #element["link"] = content["body"][0]["url"]
            #element["title"] = content["body"][0]["element"]
            element["title"] = link
            element["thumbnail"] = ""
            x.append(element)
        return x
示例#28
0
class Spliveappcom(Downloader):

    MAIN_URL = XBMCUtils.getSettingFromContext(int(sys.argv[1]), "splive_channel")
    DECODER_URL = XBMCUtils.getSettingFromContext(int(sys.argv[1]), "online_pbewithmd5anddes_decoder")

    PASSWORD = '******'

    @staticmethod
    def getChannels(page,decode=False,group=''):
        x = []
        if str(page) == '0' or "http" not in page:
            if str(page) is not '0' and group is '':
                group = page
            page=Spliveappcom.MAIN_URL
            if page.find("pastebin.com/")>-1 and page.find("/raw/")==-1:
                page = page.replace(".com/",".com/raw/")
        html = Spliveappcom.getContentFromUrl(page,"",Spliveappcom.cookie,"")
#        html = html.decode("utf-8","ignore").encode("ascii", "ignore")
#        logger.debug("replace bad characters proccess done!");
        try:
            x = Spliveappcom.extractElements(html,decode)
        except:
            logger.debug("trying json way...")
            x = Spliveappcom.extractJSONElements(html,grouped=group,url=page)
            logger.debug("finished json way...")
            pass
        return x

    @staticmethod
    def extractJSONElements(html,grouped='',url=''):
        x = []
        try:
            jsonGlobal = json.loads(html)
            logger.debug("charged json...")
            groups = jsonGlobal["groups"]
            logger.debug("get groups: " + str(len(groups)))
            for group in groups:
                element = {}
                title = group["name"]
                title = re.sub('[^A-Za-z0-9\.]+', ' ', title)
                element["title"] = title
                element["thumbnail"] = group["image"]
                element["link"] = url
                if group.has_key("url"):
                    logger.debug("extracted station...")
                    element["link"] = group["url"]
                    element["permaLink"] = True
                elif group.has_key("stations"):
                    if grouped is '':
                        element["link"] = group["name"]
                    elif group["name"] == grouped:
                        logger.debug("searching for group: " + grouped)
                        for elementLink in group["stations"]:
                            if not elementLink.has_key("isAd"):
                                element = {}
                                title = elementLink["name"]
                                title = re.sub('[^A-Za-z0-9\.]+', ' ', title)
                                element["title"] = title
                                element["thumbnail"] = elementLink["image"]
                                element["link"] = elementLink["url"]
                                if len(element["link"]) > 0:
                                    logger.debug("appended grouped: " + element["title"])
                                    element["permaLink"] = True
                                    x.append(element)

                    logger.debug("group station... " + group["name"])
                if element.has_key("link") and grouped is '':
                    logger.debug("appended: " + element["title"])
                    x.append(element)
        except:
            logger.debug("something goes wrong, trying brute way")

            html = html.replace("\n", "").replace("\t", "").strip().replace("  ", "")
            #logger.debug("analysing: " + html)
            html = html.replace("},]", "}]")
            #logger.debug("done little fix for '},]' bad encoding")
            #logger.debug("now BAD json is: " + html)
            i=1
            if grouped == '':
                #get groups
                for line in html.split('"stations": ['):
                    if "]" in line:
                        line = line[line.find(']'):]
                    else:
                        line = line[line.find('['):]
                    logger.debug("using line: " + line)
                    title = Decoder.extract('"name": "','"',line)
                    image = Decoder.extract('"image": "', '"', line)
                    element = {}
                    title = re.sub('[^A-Za-z0-9\.]+', ' ', title)
                    element["title"] = title
                    element["thumbnail"] = image
                    element["link"] = title
                    x.append(element)
                    i+=1
            else:
                group = Decoder.extract('"name": "'+grouped+'"',']',html)
                i=0
                for line in group.split('{'):
                    if i>0:
                        logger.debug("using line from group: "+line)
                        title = Decoder.extract('"name": "', '"', line)
                        image = Decoder.extract('"image": "', '"', line)
                        link = Decoder.extract('"url": "', '"', line)
                        element = {}
                        title = re.sub('[^A-Za-z0-9\.]+', ' ', title)
                        element["title"] = title
                        element["thumbnail"] = image
                        element["link"] = link
                        element["permaLink"] = True
                        x.append(element)
                    i+=1
            pass
        return x


    @staticmethod
    def extractElements(table,decode=False):
        x = []
        i = 0
        permaLink = False
        if table.find("@ /lista")>-1:
            splitter = "@ /lista"
        elif table.find("@ /channel")>-1:
            splitter = "@ /channel"
            permaLink = True
        elif table.find("@ /movie")>-1:
            splitter = "@ /movie"
            permaLink = True
        for value in table.split(splitter):
            element = {}
            title = ""
            link = ""
            referer = ""
            if value.find(" title ")>-1:
                title = Decoder.extract(" title \"","\"",value)
            elif value.find(" name")>-1:
                title = Decoder.extract(" name \"","\"",value)
            if value.find(" url \"")>-1:
                link = Decoder.extract(" url \"","\"",value)
            elif value.find(" url_servidor \"")>-1:
                link = Decoder.extract(" url_servidor \"","\"",value)
            element["title"] = title
            img = ""
            if value.find(" image \"")>-1:
                img = Decoder.extract(" image \"","\"",value)
            elif value.find(" image_url ")>-1:
                img = Decoder.extract(" image_url \"","\"",value)
            if decode and img.find("http")==-1:
                try:
                    img = Spliveappcom.decrypt(img)
                    element["thumbnail"] = img
                except:
                    logger.error("Could not be decoded img content.")
                    pass
            elif img!="":
                element["thumbnail"] = img
            if link.find("pastebin.com"):
                link = link.replace(".com/",".com/raw/")
            element["link"] = link
            if value.find("referer \"")>-1:
                referer = Decoder.extract("referer \"","\"",value)
                if referer!="0":
                    element["referer"] = referer
            if permaLink:
                element["permaLink"] = True
            logger.debug("append: "+title+", link: "+element["link"])
            if title!='' and link!='':
                x.append(element)
            i+=1
        return x

    @staticmethod
    def decodeUrl(url,referer=''):
        #content = Spliveappcom.getContentFromUrl(url)
        if url.find("http")==-1 and (url.find("sop://")==-1 and url.find("acestream://")==-1):
            decryptedUrl = Spliveappcom.decrypt(url)
        else:
            decryptedUrl = url
        element = {}
        element["title"] = "Link"
        if referer!='':
            referer = Spliveappcom.decrypt(referer)
            if referer!='0':
                decryptedUrl+=", referer: "+referer
        logger.debug("brute link to be launched: "+decryptedUrl)
        element["link"] = decryptedUrl
        x = []
        x.append(element)
        return x


    @staticmethod
    def decrypt(encrypted):
        decrypted = encrypted
        try:
            logger.debug("Encrypted content is: "+encrypted)
            if not ONLINE:
                decrypted = PBEWithMD5AndDES.decrypt(encrypted, Spliveappcom.PASSWORD)
            elif len(encrypted)>0 and encrypted.find("http://")==-1:
                decrypted = Downloader.getContentFromUrl(Spliveappcom.DECODER_URL+'?data='+encrypted+"&key="+Spliveappcom.PASSWORD+"&iterations=1000")
            logger.debug("Decrypted content is: "+decrypted)
        except:
            logger.error("Could not be unencrypted: "+encrypted)
            pass

        return decrypted
示例#29
0
    def getChannels(page="", cookie=""):
        x = []
        ##main has sections: nuevos lanzamientos, episodios estrenos, peliculas mas vistas, series mas listas, peliculas actualizadas, episodios actualizados and "Search"
        if cookie == "":
            cookie = HdfullTv.getNewCookie()

        logger.debug("page: " + page)
        if (page == "0"):
            itemFirst = {}
            itemFirst["title"] = 'Últimos Emitidos'
            itemFirst["permalink"] = 'episodios#latest'
            x.append(itemFirst)
            itemFirst2 = {}
            itemFirst2["title"] = 'Episodios Estreno'
            itemFirst2["permalink"] = 'episodios#premiere'
            x.append(itemFirst2)
            itemFirst3 = {}
            itemFirst3["title"] = 'Episodios Actualizados'
            itemFirst3["permalink"] = 'episodios#updated'
            x.append(itemFirst3)
            itemFirst4 = {}
            itemFirst4["title"] = 'Películas Estreno'
            itemFirst4["permalink"] = 'peliculas-estreno'
            x.append(itemFirst4)
            itemFirst5 = {}
            itemFirst5["title"] = 'Películas Actualizadas'
            itemFirst5["permalink"] = 'peliculas-actualizadas'
            x.append(itemFirst5)
            itemFirst6 = {}
            itemFirst6["title"] = XBMCUtils.getString(11018)
            itemFirst6["permalink"] = "search"
            x.append(itemFirst6)
        elif page == 'https://hdfull.me/episodios#latest':
            html = HdfullTv.getContentFromUrl(
                url="https://hdfull.me/a/episodes",
                data="action=latest&start=0&limit=24&elang=ALL",
                cookie=cookie)
            logger.debug(html)
            x = json.loads(html)
        elif page == 'https://hdfull.me/episodios#premiere':
            html = HdfullTv.getContentFromUrl(
                url="https://hdfull.me/a/episodes",
                data="action=premiere&start=0&limit=24&elang=ALL",
                cookie=cookie)
            logger.debug(html)
            x = json.loads(html)
        elif page == 'https://hdfull.me/episodios#updated':
            html = HdfullTv.getContentFromUrl(
                url="https://hdfull.me/a/episodes",
                data="action=updated&start=0&limit=24&elang=ALL",
                cookie=cookie)
            logger.debug(html)
            x = json.loads(html)
        elif page == 'https://hdfull.me/peliculas-estreno':
            html = HdfullTv.getContentFromUrl(
                "https://hdfull.me/peliculas-estreno")
            logger.debug(html)
            x = HdfullTv.extractItems(html)
        elif page == 'https://hdfull.me/peliculas-actualizadas':
            html = HdfullTv.getContentFromUrl(
                "https://hdfull.me/peliculas-actualizadas")
            logger.debug(html)
            x = HdfullTv.extractItems(html)
        elif page == 'https://hdfull.me/search':
            #display keyboard, it will wait for result
            keyboard = XBMCUtils.getKeyboard()
            keyboard.doModal()
            text = ""
            if (keyboard.isConfirmed()):
                text = keyboard.getText()
                x = HdfullTv.search(text)
        elif page.find("https://hdfull.me/serie/") > -1 and page.find(
                "episodio-") == -1:
            #proccess serie article, could be: 1) obtain seasons 2) obtains chapters from a season #temporada-2/episodio-2
            if page.find("/temporada-") == -1:
                html = HdfullTv.getContentFromUrl(page)
                x = HdfullTv.extractSeasons(html, page)
            else:
                season = page[page.find("temporada-") + len("temporada-"):]
                html = HdfullTv.getContentFromUrl(page)
                sid = Decoder.extract(
                    "var sid = '", "'", html
                )  #fix for hardcoded value '126', it was the internal series id, now works fine
                bruteJson = HdfullTv.getContentFromUrl(
                    url="https://hdfull.me/a/episodes",
                    data={
                        "action": "season",
                        "limit": "0",
                        "season": season,
                        "show": sid,
                        "start": "0"
                    },
                    cookie=cookie).read()
                x = json.loads(bruteJson)
        else:
            x = HdfullTv.extractProvidersFromLink(page, cookie)
        return x
示例#30
0
    from providers.spliveappcom import Spliveappcom
except:
    logger.error(
        "Crypto-problems detected, probably you need a better platform")
    pass

from window.DefaultWindow import DefaultWindow  #papernews window library
try:
    from window.ImageWindow import windowImage  #teletext window library
except:
    logger.info(
        "No module named PIL was found in the system, hidding teletext library."
    )
    pass

icon = XBMCUtils.getAddonFilePath('icon.png')


def drawFilmon(page):
    jsonChannels = Filmoncom.getChannelsJSON()
    for itemFirst in jsonChannels:
        if page == "0":
            add_dir(itemFirst["title"],
                    "http://www.filmon.com/tv/" + itemFirst["alias"], 4, icon,
                    "filmoncom", itemFirst["title"])
        elif (page == itemFirst["title"]) and itemFirst.has_key("channels"):
            for item in itemFirst["channels"]:
                add_dir(item["title"],
                        "http://www.filmon.com/tv/" + item["alias"], 5,
                        item["logo"], "filmoncom", item["title"])
        else: