Exemple #1
0
def playMovie(url, name, thumb):
    movies = BeautifulSoup(httpReq(url)).findAll("div", {"class": "btn"})
    for movie in movies:
        if movie.text.lower().find("vezi film") > -1:
            print movie
            url = None
            while url == None:
                movie = movie.next
                try:
                    if movie.name == "a":
                        break
                except:  #movie doesn't have field name (string)
                    continue
            break
    url = movie['href']
    url = yt.getYoutubeMovie(url)

    win = xbmcgui.Window(10000)
    win.setProperty('cinepub.playing.title', name.lower())
    item = xbmcgui.ListItem(name,
                            iconImage="DefaultVideo.png",
                            thumbnailImage=thumbnail)
    item.setInfo(type="Video", infoLabels={"title": name})
    item.setPath(url)

    xbmcplugin.setResolvedUrl(addonHandle, True, item)
    return True
Exemple #2
0
def listMovies(url):
    progress = xbmcgui.DialogProgress()
    progress.create(localise(1006), localise(1007))
    progress.update(1, "", progressReport(1), "")

    list = []
    #TODO: caching
    movieList = BeautifulSoup(httpReq(url)).find(
        "div", {
            "class": "categoryThumbnailList"
        }).contents
    total = len(movieList)
    current = 0
    for movie in movieList:
        link = movie.next
        url = link['href']
        title = link['title']
        title = title[:title.find("<")]
        img = link.find("img")
        if img:
            img = img['src']
        addDir(title, url, 8, img, folder=False)

        if progress.iscanceled():
            sys.exit()

        current += 1
        percent = int((current * 100) / total)
        progress.update(percent, "", progressReport(percent), "")

    progress.close()

    xbmcplugin.endOfDirectory(addonHandle)
Exemple #3
0
def getFilmes(url):
    link = openURL(url)
    link = unicode(link, 'utf-8', 'ignore')

    soup = BeautifulSoup(link)
    conteudo = soup("div", {"class": "ib-miniaturas lista-miniaturas"})
    filmes = conteudo[0]("div", {"class": "ib-miniatura"})

    totF = len(filmes)

    for filme in filmes:
        titF = filme.img["alt"].encode('utf-8', 'ignore')
        titF = titF.replace('Assistir ', '').replace('Filme ', '')
        urlF = filme.a["href"].encode('utf-8', 'ignore')
        imgF = filme.img["src"].encode('utf-8', 'ignore')

        addDirF(titF, urlF, 100, imgF, False, totF)

    try:
        proxima = re.findall('link rel="next" href="(.*?)"', link)[0]
        addDir('Próxima Página >>', proxima, 20, artfolder + 'proxima.png')
    except:
        pass

    setViewFilmes()
Exemple #4
0
def getMovieLens(url):

        req = urllib2.Request(url)
        req.add_header('User-Agent', "%s %s" % (sys.modules[ "__main__" ].__plugin__, sys.modules[ "__main__" ].__version__))
        response = urllib2.urlopen(req)
        soup = BeautifulSoup(response)
        mySpans= soup.findAll('span',attrs={"class" : "movieTitle"})
	##mySpans = mySpans[1], mySpans[2]
        mydirs = list()
	pDialog = xbmcgui.DialogProgress()
	ret = pDialog.create('XBMC', 'Initializing script...')
	i = 0.0
	total = len(mySpans)


        for span in mySpans:
            i += 1
            percent = int( (i * 100) / total)
            pDialog.update(percent, 'Searching ' + span.a.string,str(int(i))+'/'+str(total))


            s = span.a.string
            year = s[len(s)-7 : len(s)]
            year = year.replace('(','').replace(')','')
	    year = year.strip()
            s = s.split('(',1)[0].strip()
            s = s.replace(', The','')
				
            #print s
	    xbmc.log('s=%s' % s)
            dirs= getter.searchDirs(s + ' ' + year)
            if dirs:
                for d in dirs:
                            id = d.getElementsByTagName('id').item(0).firstChild.data
                            name = d.getElementsByTagName('name').item(0).firstChild.data
                            date = d.getElementsByTagName('date').item(0).firstChild.data
                            thumb = d.getElementsByTagName('thumb').item(0).firstChild.data
                            url = sys.argv[0] + '?action=files&did=' + id
			    clean = CleanFileName(name,False)
		            clean = clean.replace('(', '')
                            clean = clean.replace('[', '')
                            clean = clean.replace(']', '')
			    clean = clean.replace(')', '')

                            if s.lower() in clean.lower() and year in name:
			   	##xbmc.log('name=%s' % name)
				mydirs.append(d)
	    if (pDialog.iscanceled()):
		print 'Canceled search'
	        pDialog.close()
                return


        pDialog.close() 
        return mydirs  
def get_lcs_standings(teamName):
    # This method loads the latest standings from the Gamepedia server
    url = ''
    if (teamName in TEAMS_EU):
        url = PluginUtils.unescape(PluginUtils.get_string(30104))
    if (teamName in TEAMS_NA):
        url = PluginUtils.unescape(PluginUtils.get_string(30103))

    if (url != ''):
        response = PluginUtils.do_request(url)
        if (response is not None):

            # Lets process the html
            # decoded_data = json.load(response)
            soup = BeautifulSoup(response)

            tables = soup.findAll('table')

            if (tables is not None):
                for table in tables:
                    # We have the table, now lets try and get the right row
                    rows = table.find('tbody').findAll('tr')

                    if (rows is not None):
                        for idx, row in enumerate(rows):
                            columns = row.findAll('td')
                            if (columns is not None):
                                if (columns[2] is not None):
                                    if (teamName in TEAMS_EU):
                                        if (columns[2].find('a').text.lower()
                                                == TEAMS_EU[teamName].lower()):
                                            return {
                                                'standing':
                                                idx + 1,
                                                'record':
                                                columns[3].find('span').text +
                                                "W-" +
                                                columns[4].find('span').text +
                                                "L"
                                            }
                                    if (teamName in TEAMS_NA):
                                        if (columns[2].find('a').text.lower()
                                                == TEAMS_NA[teamName].lower()):
                                            return {
                                                'standing':
                                                idx + 1,
                                                'record':
                                                columns[3].find('span').text +
                                                "W-" +
                                                columns[4].find('span').text +
                                                "L"
                                            }
    return None
Exemple #6
0
def recentlyAdded(cat):
    html = http_req(siteUrl)

    soup = BeautifulSoup(html).findAll('div', {'id': 'tab1'})

    if cat == 'tvshows':
        soup = soup[0]
        param = 'seriale'

    elif cat == 'movies':
        soup = soup[1]
        param = 'filme'

    results = soup.findAll('a', href=re.compile(param), limit=20)

    total = len(results)
    current = 0

    for a in results:
        ep_year = a.parent.parent.findAll('div')[1].text.strip()
        title = htmlFilter(a.text)
        url = urlFilter(a['href'])

        if cat == 'tvshows':
            eps = re.search(r'S(\d+)E(\d+-?\d*)', ep_year)

            season = str(eps.group(1)) if eps else ''
            episode = str(eps.group(2)) if eps else ''

            name = '%s %sx%s' % (title, season, episode)

            addDir(name,
                   url,
                   8,
                   "",
                   title,
                   season,
                   episode,
                   folder=False,
                   totalItems=total)

        elif cat == 'movies':
            year = re.search('(\d{4,4})', ep_year)
            year = str(year.group(1)) if year else 'unknown'
            name = '%s (%s)' % (title, year)

            addDir(name, url, 8, "", name, folder=False, totalItems=total)

    xbmcplugin.endOfDirectory(int(sys.argv[1]))
Exemple #7
0
def getMovies(url):
    progress = xbmcgui.DialogProgress()
    progress.create('Progress', 'Please wait...')
    progress.update(1, "", "Loading list - 1%", "")

    soup = BeautifulSoup(http_req(url))

    pages = str(soup.find("div", {"id": "numarpagini"}))
    pages = max(int(x) for x in re.findall(r'([\d]+)</a>', pages))
    page = int(re.search('pagina=(\d+)', url).group(1))

    div = soup.find("div", {"id": "content"})
    links = div.findAll("a", {"class": "link"})
    thumbs = re.findall(r'<img src="../(.+?)"', str(div))
    years = re.findall(r'Aparitie: ?(\d+)', str(div))

    total = len(links)
    current = 0

    while current <= total - 1:
        year = re.search('(\d{4,4})', years[current])
        year = str(year.group(1)) if year else 'unknown'
        name = "%s (%s)" % (htmlFilter(links[current].text), year)
        link = urlFilter(links[current]['href'])
        thumbnail = urlFilter(thumbs[current])

        addDir(name, link, 8, thumbnail, name, folder=False)

        if progress.iscanceled(): sys.exit()

        percent = int(((current + 1) * 100) / total)
        message = "Loading list - " + str(percent) + "%"
        progress.update(percent, "", message, "")

        current += 1

    if not page == pages:
        url = re.sub('pagina=\d+', 'pagina=' + str(page + 1), url)
        addDir("Next Page >>", url, 9)

    progress.close()

    xbmcplugin.endOfDirectory(int(sys.argv[1]))
Exemple #8
0
def getCategorias(url):
    link = openURL(url)
    soup = BeautifulSoup(link)

    conteudo = soup("ul", {"class": "m-cat"})

    categorias = conteudo[0]("li")

    totC = len(categorias)

    for categoria in categorias:
        titC = categoria.text.encode('latin-1', 'replace')

        if not 'Lançamento' in titC:
            urlC = categoria.a["href"]
            imgC = artfolder + limpa(titC) + '.png'

            addDir(titC, urlC, 20, imgC)

    setViewMenu()
Exemple #9
0
	def getVideoUrl(self, smil):
		chunkArray = []

		print "Ooyala: --> Calculating video URL..."

		soup = BeautifulSoup(smil)
		rtmpDomain = soup.find('rtmpdomains').string
		rtmpDomain = rtmpDomain.split(',')[0]
		httpDomain = soup.find('domains').string
		httpDomain = httpDomain.split(',')[0]
		vData = soup.find('vdata')
		if vData:
			streams = vData.findAll('stream', attrs={'f':'h264'})
			streams = sorted(streams, key=lambda x: x['w'])
# 			version = vData['version']
			version = "1:1" ## Overriding 'version' for PostTV
			embedCode = vData['embedcode']
			ts = str(vData.find('ts').string)
			tsArray = ts.split(",")
			domain = ""
			if len(tsArray) > 2:
				domain = "http://" + httpDomain + "/"
			else:
				domain = rtmpDomain + "/mp4:s/"
			vidLength = len(tsArray)-1
			for i, startTime in enumerate(tsArray[:vidLength]):
				index = i
				start = int(startTime)
				br = int(streams[-1]['br'])
				width = int(streams[-1]['w'])
				url = self.getChunkUrl(embedCode, version, index, start, br, width)
				url = domain + url
				chunkArray.append(url)
		else:
			print "Ooyala: --> Could not find vData, trying the other."
			promo = soup.find('promo')
			promoVids = re.findall('[A-z0-9]{32}', promo)
			chunkArray.append(rtmpDomain + str(promoVids[0]) + str(promoVids[-1]))
			print "Ooyala: --> Formed the following URL: " + str(chunkArray[0])
		print "Ooyala: --> Successfully formed URL."
		return chunkArray
Exemple #10
0
def player(name, url, iconimage):
    OK = True
    mensagemprogresso = xbmcgui.DialogProgress()
    mensagemprogresso.create('HORA DA PIPOCA', 'Obtendo Fontes para ' + name,
                             'Por favor aguarde...')
    mensagemprogresso.update(0)

    titsT = []
    idsT = []

    matriz = []

    link = openURL(url)
    soup = BeautifulSoup(link)

    try:
        conteudo = soup("div", {"class": "pn-opcoes pn-dub"})
        srvsdub = conteudo[0]("li")

        totD = len(srvsdub)

        tipo = "Dublado"

        for i in range(totD):
            t**S = srvsdub[i].text.encode('utf-8', 'ignore') + " (%s)" % tipo

            if not 'Principal' in t**S:
                if not 'DropVideo' in t**S:
                    if not 'Vídeo PW' in t**S:
                        if not 'YouWatch' in t**S:
                            if not 'Youwatch' in t**S:
                                if not 'NeoDrive' in t**S:
                                    idS = srvsdub[i]["data-pid"]
                                    titsT.append(t**S)
                                    idsT.append(idS)
    except:
        pass

    try:
        conteudo = soup("div", {"class": "pn-opcoes pn-leg"})
        srvsleg = conteudo[0]("li")

        totL = len(srvsleg)

        tipo = "Legendado"

        for i in range(totL):
            t**S = srvsleg[i].text.encode('utf-8', 'ignore') + " (%s)" % tipo

            if not 'Principal' in t**S:
                if not 'DropVideo' in t**S:
                    if not 'Vídeo PW' in t**S:
                        if not 'YouWatch' in t**S:
                            if not 'Youwatch' in t**S:
                                if not 'NeoDrive' in t**S:
                                    idS = srvsleg[i]["data-pid"]
                                    titsT.append(t**S)
                                    idsT.append(idS)
    except:
        pass

    if not titsT: return

    index = xbmcgui.Dialog().select('Selecione uma das fontes suportadas :',
                                    titsT)

    if index == -1: return

    ind = idsT[index]

    conteudo = soup("li", {"class": "pi-item" + ind})

    links = conteudo[0]("iframe")

    if len(links) == 0: links = conteudo[0]("embed")

    for link in links:
        urlVideo = link["data-src"]

    print "URLVIDEO " + urlVideo

    mensagemprogresso.update(50, 'Resolvendo fonte para ' + name,
                             'Por favor aguarde...')

    if 'nowvideo.php' in urlVideo:
        nowID = urlVideo.split("id=")[1]
        urlVideo = 'http://embed.nowvideo.sx/embed.php?v=%s' % nowID

    elif 'video.tt' in urlVideo:
        vttID = urlVideo.split('e/')[1]
        urlVideo = 'http://www.video.tt/watch_video.php?v=%s' % vttID

    elif 'flashx.php' in urlVideo:
        fxID = urlVideo.split('id=')[1]
        urlVideo = 'http://www.flashx.tv/embed-%s.html' % fxID

    elif 'thevid.net' in urlVideo:
        linkTV = openURL(urlVideo)
        js_data = jsunpack.unpack(linkTV)

        url2Play = re.findall('var vurl2="(.*?)"', js_data)[0]

        OK = False

    if OK: url2Play = urlresolver.resolve(urlVideo)

    if not url2Play: return

    legendas = '-'

    mensagemprogresso.update(75, 'Abrindo Sinal para ' + name,
                             'Por favor aguarde...')

    playlist = xbmc.PlayList(1)
    playlist.clear()

    listitem = xbmcgui.ListItem(name, thumbnailImage=iconimage)
    listitem.setPath(url2Play)
    listitem.setProperty('mimetype', 'video/mp4')
    listitem.setProperty('IsPlayable', 'true')
    playlist.add(url2Play, listitem)

    xbmcPlayer = xbmc.Player(xbmc.PLAYER_CORE_AUTO)
    xbmcPlayer.play(playlist)

    mensagemprogresso.update(100)
    mensagemprogresso.close()

    if legendas != '-':
        if 'timedtext' in legendas:
            import os.path
            sfile = os.path.join(xbmc.translatePath("special://temp"),
                                 'sub.srt')
            sfile_xml = os.path.join(xbmc.translatePath("special://temp"),
                                     'sub.xml')  #timedtext
            sub_file_xml = open(sfile_xml, 'w')
            sub_file_xml.write(urllib2.urlopen(legendas).read())
            sub_file_xml.close()
            xmltosrt.main(sfile_xml)
            xbmcPlayer.setSubtitles(sfile)
        else:
            xbmcPlayer.setSubtitles(legendas)