예제 #1
0
def IndexCategory(baseUrl, fileName):
    progress_dialog = xbmcgui.DialogProgress()
    progress_dialog.create("Indeksējam tvfilmas.lv")

    currentPage = 1

    url = baseUrl + str(currentPage)
    html = network.getHTML(url)

    entries = common.parseDOM(html, "span", attrs={"id": "num_entries"})
    indexed = 0

    movieEntriesList = common.parseDOM(html,
                                       "ul",
                                       attrs={"id": "uEntriesList"})
    screenList = common.parseDOM(movieEntriesList,
                                 "div",
                                 attrs={"class": "ve-screen"})
    movieUrls = common.parseDOM(screenList, "a", ret="href")
    # print movieUrls, len(movieUrls)
    movieURLIndex = 0

    localFile = kodi_func.home + "/resources/" + fileName  # xbmc.translatePath('special://temp/'+fileName )
    temp = codecs.open(localFile, 'w', "utf-8")

    movieIndexes = []
    if len(entries) == 1:
        for indexed in range(0, int(entries[0])):
            progress = int(float((float(indexed) / int(entries[0])) * 100))
            # print "Progress: " + str(progress)
            progress_dialog.update(
                progress, "Lūdzu uzgaidi...", "Indeksējam Latviešu Filmas ",
                "Atlicis: " + str(int(entries[0]) - indexed))
            if (progress_dialog.iscanceled()): return

            # print movieUrls[movieURLIndex]
            result = IndexPage(movieUrls[movieURLIndex])
            temp.write(result['title'] + "|" + result['url'] + "|" +
                       result['thumb'] + "\n")
            movieIndexes.append(result)

            movieURLIndex += 1

            if len(movieUrls) == movieURLIndex:
                currentPage += 1
                html = network.getHTML(baseUrl + str(currentPage))
                movieEntriesList = common.parseDOM(
                    html, "ul", attrs={"id": "uEntriesList"})
                screenList = common.parseDOM(movieEntriesList,
                                             "div",
                                             attrs={"class": "ve-screen"})
                movieUrls = common.parseDOM(screenList, "a", ret="href")
                # print movieUrls, len(movieUrls)
                movieURLIndex = 0

    temp.close()
    return movieIndexes
예제 #2
0
def HomeNavigation():
    print "Opening CinemaLive.tv"
    url = 'https://cinemalive.tv/filmaslatviski'
    html = network.getHTML(url)
    # print 'html: ' + html
    nav_links_list = common.parseDOM(html, "ul", attrs={"class":
                                                        "sub-menu"})[0]
    nav_links = common.parseDOM(nav_links_list, "a", ret="href")
    nav_links_name = common.parseDOM(nav_links_list, "a")
    kodi_func.addDir('Meklēt',
                     '',
                     'state_search',
                     '%s/meklet2.png' % kodi_func.iconpath,
                     source_id=mySourceId)

    # pagirasList = u'https://openload.co/embed/dLuET3ML86E/Deadpool.%28Dedpuls%29.2016.720p.LAT.THEVIDEO.LV.mkv.mp4'
    # link = urlresolver.resolve(pagirasList)
    # addDir('Dedpūls', pagirasList, 'state_play', None)
    # addLink("Dedpūls", link.encode('utf-8'), None)
    # print nav_links
    # print nav_links_name
    for i in range(0, len(nav_links)):
        if kodi_func.isLinkUseful(nav_links[i]):
            # print mainURL + nav_links[i]
            kodi_func.addDir(nav_links_name[i].encode('utf-8'),
                             nav_links[i],
                             'state_movies',
                             kodi_func.GetCategoryImage(nav_links_name[i]),
                             source_id=mySourceId)
예제 #3
0
def SearchRaw(searchStr):

	result = []
	
	if searchStr == False or len(searchStr) == 0: return result
	
	html = network.getHTML("http://movieplace.lv/search/?q=" + searchStr)
	
	print html
	# found_items = common.parseDOM(html, "div", attrs = { "style": "height:78px" })
	found_links = common.parseDOM(html, "a", attrs = { "itemprop": "url" }, ret = "href")
	imgTitleContainer = common.parseDOM(html, "a", attrs = { "itemprop": "url" })
	for i in range(0,len(imgTitleContainer)):
		imgTitleContainer[i] = imgTitleContainer[i].replace("<b>", "").replace("</b>","")
	found_name = common.parseDOM(imgTitleContainer, "img", ret = "title")
	found_image = common.parseDOM(imgTitleContainer, "img", ret = "src")
	print found_links
	print found_name
	print found_image
	print imgTitleContainer
	
	for i in range(0, len(found_links)):		
		result.append({
			'title': network.cleanHTML(found_name[i]).encode('utf-8'),
			'url': found_links[i],
			'thumb': mainURL+found_image[i],
			'state': 'state_play',
			'source_id': mySourceId
		})
	
	return result
예제 #4
0
def IndexPage(url):
    baseUrl = "http://tvkanali.lv"
    url = baseUrl + url

    html = network.getHTML(url)

    videoBlock = common.parseDOM(html,
                                 "div",
                                 attrs={"class": "vep-video-block"})
    print videoBlock
    result = {'title': None, 'url': None, 'thumb': None}
    searchObj = re.search('src=\\\\"[:\/\w\d\.=?\-&]*', videoBlock[0])
    if searchObj:
        resolvedUrl = searchObj.group().replace('src=\\"', '')
        print resolvedUrl
        if resolvedUrl.startswith("//"):
            resolvedUrl = "http:" + resolvedUrl
        # resolvedUrl = resolvedUrl[:-2]
        result['url'] = resolvedUrl

    title = common.parseDOM(html, "h1", attrs={"class": "vep-title"})

    imageBlock = common.parseDOM(html, "a", attrs={"class": "vep-playvideo"})
    image = common.parseDOM(imageBlock, "img", ret="src")

    result['title'] = title[0]
    result['thumb'] = image[0]

    return result
def resolve(url):
    link = urlresolver.resolve(url)
    if link == False or link == "":
        if url.startswith("https://cloudsany.com"):
            print "CloudsAny detected..."
            html = network.getHTML(url)
            playerCode = common.parseDOM(html,
                                         "div",
                                         attrs={"id": "player_code"})
            scripts = common.parseDOM(playerCode, "script")
            js = scripts[-1]

            js = js.replace("eval", "fnRes=")
            print "return" in js
            js = str(js2py.eval_js(js))
            print "Decoded js", js

            searchObj = re.search("file:\"[\'\w\d:\/.?=]*\"", js)
            if searchObj:
                resolvedUrl = searchObj.group().replace("file:\"", "")
                resolvedUrl = resolvedUrl[:-1]
                print "Decoded URL", resolvedUrl
                return resolvedUrl
            else:
                return False

    return link
예제 #6
0
def SearchRaw(searchStr):
    result = []

    # post_fields = {'search': searchStr}
    # html = network.postHTML("https://cinemalive.tv/scripts/search.php", post_fields)
    html = network.getHTML("https://cinemalive.tv/?s=" + searchStr)

    print html
    found_items = common.parseDOM(html, "div", attrs={"class": "result-item"})
    found_title = common.parseDOM(found_items, "div", attrs={"class": "title"})
    found_links = common.parseDOM(found_title, "a", ret="href")
    found_name = common.parseDOM(found_title, "a")
    found_image = common.parseDOM(found_items, "img", ret="src")
    print found_links
    print found_name
    print found_image

    for i in range(0, len(found_links)):
        result.append({
            'title':
            found_name[i].replace(
                '<span class="search-everything-highlight-color" style="background-color:#6dbd4d">',
                '').replace('</span>', '').encode('utf-8'),
            'url':
            found_links[i],
            'thumb':
            mainURL + found_image[i].replace(mainURL, "").replace(
                '150x150.jpg', '185x278.jpg'),
            'state':
            'state_play',
            'source_id':
            mySourceId
        })

    return result
예제 #7
0
def PlayMovie(url, title, picture):
    print "url: " + url
    html = network.getHTML(url)
    # print "html: " + html

    streamLangNames = []

    movieDivContainer = common.parseDOM(
        html, "div", attrs={"class": "featured-movie-player"})
    movieIframeSrc = common.parseDOM(movieDivContainer, "iframe", ret="src")

    movieID = urlparse.parse_qs(urlparse.urlparse(
        movieIframeSrc[0]).query)['id'][0]
    print "MoviedID: ", movieID

    jsonRaw = network.getHTML("http://playapi.mtgx.tv/v3/videos/stream/" +
                              movieID)
    print "RAW JSON: ", jsonRaw
    if jsonRaw:
        jsonDecoded = json.loads(jsonRaw)
    else:
        jsonDecoded = ""

    if 'streams' not in jsonDecoded:
        jsonRaw = network.getHTML(
            "http://dev.morf.lv/mirror.php?url=http://playapi.mtgx.tv/v3/videos/stream/"
            + movieID).replace(
                '<base href="http://playapi.mtgx.tv/v3/videos/stream/' +
                movieID + '" />', '')
        print "fallback json raw:", jsonRaw
        jsonDecoded = json.loads(jsonRaw)

    print "Movie Elements: ", movieDivContainer, movieIframeSrc, jsonDecoded

    if jsonDecoded['streams']['high'] != None:
        kodi_func.addLink(
            title.decode('utf-8').encode('utf-8') + " - HIGH",
            jsonDecoded['streams']['high'], picture)

    if jsonDecoded['streams']['hls'] != None:
        kodi_func.addLink(
            title.decode('utf-8').encode('utf-8') + " - HLS",
            jsonDecoded['streams']['hls'], picture)

    # if jsonDecoded['streams']['medium'] != None:
    # kodi_func.addLink(title.decode('utf-8').encode('utf-8') + " - MEDIUM", jsonDecoded['streams']['medium'], picture)
예제 #8
0
def SearchRaw_old(searchStr):
    result = []

    html = network.getHTML("http://www.fof.lv/search/?q=" + searchStr)

    allEntries = common.parseDOM(html, "div", attrs={"id": "allEntries"})
    if len(allEntries) == 0:
        allEntries = common.parseDOM(html,
                                     "table",
                                     attrs={"id": "entry_table"})
    # print allEntries
    infoTd = common.parseDOM(allEntries, "td", attrs={"class": "info"})
    moviesURLs = common.parseDOM(infoTd, "a", ret="href")
    moviesThumbnailURLsList = common.parseDOM(allEntries, "td", ret="style")
    if len(moviesThumbnailURLsList) == 0:
        moviesThumbnailURLsList = common.parseDOM(allEntries,
                                                  "img",
                                                  attrs={
                                                      "width": "80",
                                                      "height": "100"
                                                  },
                                                  ret="src")
    moviesTitleList = common.parseDOM(infoTd,
                                      "button",
                                      attrs={"class": "entry_button"})
    # moviesYearList = common.parseDOM(infoTd, "div", attrs = {"style": "width: 100px; height: 18px; background: url(http://www.fom.ucoz.lv/jauns_img/entry_year.png) no-repeat; margin: 0px auto; padding-top: 2px;"} )
    print allEntries, infoTd, moviesURLs, moviesThumbnailURLsList, moviesTitleList
    # moviesTitleList = common.parseDOM(moviesList, "h2")
    # moviesThumbnailURLsList = common.parseDOM(moviesList, "img", attrs = { "class": "img-thumbnail" }, ret = "src")
    # moviesURLs = common.parseDOM(moviesList, "a", ret = "href")
    # print moviesThumbnailURLsList

    for i in range(0, len(moviesURLs)):
        thumb = moviesThumbnailURLsList[i].replace(
            "); width: 80px; height: 100px;",
            "").replace("background:url(", "").replace("/s", "/")
        if network.exists(mainURL + thumb) == False:
            thumb = thumb.replace(".jpg", ".png")
        # title = re.sub(r'<br>[\w <>="-:\d;#&\\\\]*', '', moviesTitleList[i])
        title = moviesTitleList[i].partition("<br>")[0].replace("<b>",
                                                                "").replace(
                                                                    "</b>", "")
        if not moviesURLs[i].startswith("http://"):
            movieURL = mainURL + moviesURLs[i]
        else:
            movieURL = moviesURLs[i]
        result.append({
            'title': title.encode('utf-8'),
            'url': movieURL,
            'thumb': mainURL + thumb,
            'source_id': mySourceId
        })

    return result
예제 #9
0
def Movies(url, page=1):
    html = network.getHTML(
        url.replace("#all-movies", "") + "/page/" + str(page) + "/")

    print "PAGE: " + url + "/page/" + str(page) + "/"
    # print "html " + html
    content = common.parseDOM(html, "div", attrs={"id": "content"})
    moviesList = common.parseDOM(content,
                                 "ul",
                                 attrs={"class": "movies clearfix"})
    moviesOriginalDiv = common.parseDOM(moviesList,
                                        "div",
                                        attrs={"class": "original"})
    moviesFigures = common.parseDOM(moviesOriginalDiv, "figure")
    moviesTitleList = common.parseDOM(moviesFigures, "img", ret="alt")
    moviesThumbnailURLsList = common.parseDOM(moviesFigures, "img", ret="src")
    moviesURLs = common.parseDOM(moviesList,
                                 "a",
                                 attrs={"class": "button primary-button"},
                                 ret="href")

    published = []

    for i in range(0, len(moviesOriginalDiv)):
        div = moviesOriginalDiv[i]
        pub = common.parseDOM(div, "p", attrs={"class": "published"})
        if len(pub) == 0:
            published.append("")
        else:
            if "<span" in pub[0]:
                pub = common.parseDOM(pub, "span")

            published.append(" (" + pub[0] + ")")

    print moviesList, moviesTitleList, moviesThumbnailURLsList, moviesURLs, moviesFigures, published
    print str(len(moviesTitleList)) + " " + str(
        len(moviesThumbnailURLsList)) + " " + str(len(moviesURLs)) + " " + str(
            len(published))

    for i in range(0, len(moviesURLs)):
        kodi_func.addDir(moviesTitleList[i].encode('utf-8') +
                         published[i].encode('utf-8'),
                         mainURL + moviesURLs[i],
                         'state_play',
                         moviesThumbnailURLsList[i],
                         source_id=mySourceId)

    if len(moviesURLs) >= 21:
        kodi_func.addDir("Nākamā Lapa >>",
                         url,
                         'state_movies',
                         '%s/next.png' % kodi_func.iconpath,
                         str(int(page) + 1),
                         source_id=mySourceId)
예제 #10
0
def Movies(url, page=1):
	if url == "http://movieplace.lv/index/top_50_filmas/0-4":
		html = network.getHTML(url)
	else:
		html = network.getHTML(url+"?page"+str(page))
		
	# print "html " + html
	moviesList = common.parseDOM(html, "div", attrs = { "class": "pooular-movie-poster features-img movie-img" })
	moviesTitleList = common.parseDOM(moviesList, "img", ret = "title")
	moviesThumbnailURLsList = common.parseDOM(moviesList, "img", ret = "src")
	movieURLsContainer = common.parseDOM(moviesList, "div", attrs = { "class": "post-title" })
	moviesURLs = common.parseDOM(movieURLsContainer, "a", ret = "href")
	print moviesList, moviesTitleList, moviesThumbnailURLsList, moviesURLs
	
	
	for i in range(0, len(moviesURLs)):
		kodi_func.addDir(moviesTitleList[i].encode('utf-8'), mainURL + moviesURLs[i], 'state_play', mainURL+moviesThumbnailURLsList[i], source_id=mySourceId)
		
	if len(moviesURLs) >= 15:
		kodi_func.addDir("Nākamā Lapa >>", url , 'state_movies', '%s/next.png'% kodi_func.iconpath, str(int(page) + 1), source_id=mySourceId)
예제 #11
0
def parse_seetv_guide(url):
	pDialog = xbmcgui.DialogProgress()
	pDialog.create('Lejupielādēju tv programmu', 'Lūdzu uzgaidi...', random.choice(loadingMessages))
	
	html = network.getHTML( url )
	
	teleprogrammaDiv = common.parseDOM(html, "div", attrs = { "class": "teleprograma " })
	print "Teleprogramma div", teleprogrammaDiv
	
	program_entry_now = common.parseDOM(teleprogrammaDiv, "div", attrs = {"class": "row hover_teleprograma bold_tv"} )
	playing_now = ''
	if len(program_entry_now) == 0:
		program_entry_now = common.parseDOM(program_list_ul, "li", attrs = { "class": "entry current expandable without-description"} )
		
	if len(program_entry_now) > 0:
		spanEntry = common.parseDOM( program_entry_now[0], "span" )
		time = common.parseDOM( spanEntry, "span" )[0]
		title = network.cleanHTML( spanEntry[0] ).strip().replace("\n","").replace("\r", "").replace(time+" ", "")		
		playing_now = time + " - " + title	
		playing_now = playing_now.encode('utf-8')
	print "now playing: ", playing_now
	
	def parseDay(teleprogrammaDiv, day):		
		
		print "Downloading day: ", day
		
		program_list_div = common.parseDOM(teleprogrammaDiv, "div", attrs = { "rel": str(day) })
		
		# program_entry = common.parseDOM(program_list_div, "div", attrs = {"class": "row hover_teleprograma "} )
		program_entry_cols = common.parseDOM(program_list_div, "div", attrs = {"class": "col-lg-6 col-md-6 col-sm-12 col-xs-12 col-uxs-12 col-u2xs-12"} )
		program_entry = common.parseDOM(program_entry_cols, "div")
		program_items = []
		for pEntry in program_entry:
			spanEntry = common.parseDOM( pEntry, "span" )
			# print "spanEntrie: ", len(spanEntry), common.parseDOM( spanEntry, "span" )
			time = common.parseDOM( spanEntry, "span" )[0]
			title = network.cleanHTML( spanEntry[0] ).strip().replace("\n","").replace("\r", "").replace(time+" ", "")			
			program_items.append( time + " - " + title )
		return program_items
	
	today = date.today()	
	pDialog.update( 25 )
	program_today = parseDay(teleprogrammaDiv, today.weekday()+1 )
	pDialog.update( 50 )
	# print (today + datetime.timedelta(days=1)).weekday()+1
	program_tomorrow = parseDay(teleprogrammaDiv, (today + datetime.timedelta(days=1)).weekday()+1 )
	pDialog.update( 75 )
	program_aftertomorrow = parseDay(teleprogrammaDiv, (today + datetime.timedelta(days=2)).weekday()+1 )
	pDialog.update( 100 )
	program_afteraftertomorrow = parseDay(teleprogrammaDiv, (today + datetime.timedelta(days=3)).weekday()+1 )
	
	return GuideData(playing_now, program_today, program_tomorrow, program_aftertomorrow, program_afteraftertomorrow)
예제 #12
0
	def parseDay(url):
		print "GUIDE URL: ", url
		html = network.getHTML( url )		
		
		program_list_ul = common.parseDOM(html, "ul", attrs = { "id": "program-list-view" })
		
		program_entry = common.parseDOM(program_list_ul, "li")
		program_items = []
		for pEntry in program_entry:
			time = common.parseDOM(pEntry, "b")[0]
			title = common.parseDOM(pEntry, "a")[0]
			program_items.append( time + " - " + title )
		return program_items
예제 #13
0
def HomeNavigation():

    if not os.path.isfile(kodi_func.home +
                          "/resources/fof_lv_movieIndexes.txt"):
        IndexMovies('http://www.fof.lv/?page', 'fof_lv_movieIndexes.txt')

    print "Opening fof.lv"
    url = mainURL
    html = network.getHTML(url)
    # print 'html: ' + html
    nav_links_list = common.parseDOM(html,
                                     "div",
                                     attrs={"class": "categories"})
    nav_links = common.parseDOM(nav_links_list, "a", ret="href")
    nav_links_name = common.parseDOM(nav_links_list, "a")
    kodi_func.addDir('Meklēt',
                     '',
                     'state_search',
                     '%s/meklet2.png' % kodi_func.iconpath,
                     source_id=mySourceId)
    kodi_func.addDir('Jaunākās Filmas',
                     'http://www.fof.lv/?page1',
                     'state_movies',
                     kodi_func.GetCategoryImage('jaunakas'),
                     source_id=mySourceId)
    kodi_func.addDir('Populārākās',
                     'http://www.fof.lv/index/popularakas_filmas/0-13',
                     'state_movies',
                     kodi_func.GetCategoryImage('skatitakas'),
                     source_id=mySourceId)
    kodi_func.addDir('Vērtētākās',
                     'http://www.fof.lv/index/vertetakas_filmas/0-16',
                     'state_movies',
                     kodi_func.GetCategoryImage('vertetakas'),
                     source_id=mySourceId)

    # pagirasList = u'https://openload.co/embed/dLuET3ML86E/Deadpool.%28Dedpuls%29.2016.720p.LAT.THEVIDEO.LV.mkv.mp4'
    # link = urlresolver.resolve(pagirasList)
    # addDir('Dedpūls', pagirasList, 'state_play', None)
    # addLink("Dedpūls", link.encode('utf-8'), None)
    # print nav_links
    # print nav_links_name
    for i in range(0, len(nav_links)):
        if kodi_func.isLinkUseful(nav_links[i]):
            # print mainURL + nav_links[i]
            kodi_func.addDir(nav_links_name[i].encode('utf-8'),
                             nav_links[i],
                             'state_movies',
                             kodi_func.GetCategoryImage(nav_links_name[i]),
                             source_id=mySourceId)
예제 #14
0
def parse_lattelecom_guide(url):
	pDialog = xbmcgui.DialogProgress()
	pDialog.create('Lejupielādēju tv programmu', 'Lūdzu uzgaidi...', random.choice(loadingMessages))
	
	def parseDay(url):
		print "GUIDE URL: ", url
		html = network.getHTML( url )		
		
		program_list_ul = common.parseDOM(html, "ul", attrs = { "id": "program-list-view" })
		
		program_entry = common.parseDOM(program_list_ul, "li")
		program_items = []
		for pEntry in program_entry:
			time = common.parseDOM(pEntry, "b")[0]
			title = common.parseDOM(pEntry, "a")[0]
			program_items.append( time + " - " + title )
		return program_items
			
			
	html = network.getHTML( url )
	# print "GUIDE HTML: ", html
	
	program_list_ul = common.parseDOM(html, "ul", attrs = { "id": "program-list-view" })
	program_entry_now = common.parseDOM(program_list_ul, "li", attrs = { "class": "entry current expandable with-description"} )
	playing_now = ''
	if len(program_entry_now) == 0:
		program_entry_now = common.parseDOM(program_list_ul, "li", attrs = { "class": "entry current expandable without-description"} )
	
	if len(program_entry_now) > 0:
		time = common.parseDOM(program_entry_now, "b")[0].encode('utf-8')
		title = common.parseDOM(program_entry_now, "a")[0].encode('utf-8')
		playing_now = time + " - " + title		
	print "now playing: ", playing_now
	
	today = date.today()	
	pDialog.update( 25 )
	program_today = parseDay(url+today.strftime('%d.%m.%Y'))
	pDialog.update( 50 )
	program_tomorrow = parseDay(url+ (today + datetime.timedelta(days=1)).strftime('%d.%m.%Y')) 
	pDialog.update( 75 )
	program_aftertomorrow = parseDay(url+ (today + datetime.timedelta(days=2)).strftime('%d.%m.%Y')) 
	pDialog.update( 100 )
	program_afteraftertomorrow = parseDay(url+ (today + datetime.timedelta(days=3)).strftime('%d.%m.%Y')) 
	
	
	return GuideData(playing_now, program_today, program_tomorrow, program_aftertomorrow, program_afteraftertomorrow)
예제 #15
0
def HomeNavigation():
	print "Opening movieplace.lv"
	url = mainURL + '/load/'
	html = network.getHTML(url)
	# print 'html: ' + html
	# nav_links_list = common.parseDOM(html, "div", attrs = { "id": "genre-nav" })
	nav_links = common.parseDOM(html, "a", attrs = { "class": "catName" }, ret = "href")
	nav_links_name = common.parseDOM(html, "a", attrs = { "class": "catName" })
	kodi_func.addDir('Meklēt', '', 'state_search', '%s/meklet2.png'% kodi_func.iconpath, source_id=mySourceId)
	kodi_func.addDir('Jaunākās Filmas | Visas Filmas', mainURL + '/load/', 'state_movies', '%s/new.png'% kodi_func.iconpath, source_id=mySourceId)
	# kodi_func.addDir('TOP 50 Filmas', mainURL + '/index/top_50_filmas/0-4', 'state_movies', '%s/star.png'% kodi_func.iconpath, source_id=mySourceId)
		
	print nav_links
	print nav_links_name
	for i in range(0, len(nav_links)):
		if kodi_func.isLinkUseful(nav_links[i]):
			# print mainURL + nav_links[i]
			kodi_func.addDir(nav_links_name[i].encode('utf-8'), mainURL + nav_links[i], 'state_movies', kodi_func.GetCategoryImage(nav_links_name[i]), source_id=mySourceId)
예제 #16
0
def PlayMovie(url, title, picture):
    print "url: " + url
    html = network.getHTML(url)
    print "html: " + html

    mainMovieCol = common.parseDOM(html, "div", attrs={"class": "playex"})
    print mainMovieCol
    videoContainers = common.parseDOM(mainMovieCol[0], "source", ret="src")
    videoContainers = videoContainers + common.parseDOM(
        mainMovieCol[0], "iframe", ret="src")
    print "ATRASTIE VIDEO: "
    print videoContainers
    print title.decode('latin-1').encode('utf-8')

    if len(videoContainers) > 0:
        link = url_resolver_plus.resolve(videoContainers[0])
        if link != False:
            kodi_func.addLink(
                title.decode('utf-8').encode('utf-8') + " - Latviski",
                link.encode('utf-8'), picture)
        elif '.' in videoContainers[0] and kodi_func.isVideoFormat(
                videoContainers[0].split(".")[-1]):
            kodi_func.addLink(
                title.decode('utf-8').encode('utf-8') + " - Latviski",
                videoContainers[0], picture)
        print link
    if len(videoContainers) > 1:
        link = url_resolver_plus.resolve(videoContainers[1])
        if link != False:
            kodi_func.addLink(
                title.decode('utf-8').encode('utf-8') + " - Angliski",
                link.encode('utf-8'), picture)
        elif '.' in videoContainers[1] and kodi_func.isVideoFormat(
                videoContainers[1].split(".")[-1]):
            kodi_func.addLink(
                title.decode('utf-8').encode('utf-8') + " - Latviski",
                videoContainers[1], picture)

        print link
    # link = re.compile('file:[\s\t]*"(.+?)"').findall(html.decode('windows-1251').encode('utf-8'))[0]
예제 #17
0
def HomeNavigation():
    print "Opening skaties.lv"
    url = mainURL + '/filmas'
    html = network.getHTML(url)
    # print 'html: ' + html
    nav_links_list = common.parseDOM(
        html,
        "nav",
        attrs={"class": "horizontal-submenu movies-categories clearfix"})
    nav_links = common.parseDOM(nav_links_list, "a", ret="href")
    nav_links_name = common.parseDOM(nav_links_list, "a")
    kodi_func.addDir('Meklēt',
                     '',
                     'state_search',
                     '%s/meklet2.png' % kodi_func.iconpath,
                     source_id=mySourceId)
    kodi_func.addDir('Jaunākās Filmas',
                     mainURL + '/filmas/',
                     'state_movies',
                     '%s/new.png' % kodi_func.iconpath,
                     source_id=mySourceId)
    kodi_func.addDir('Populārākās Filmas',
                     mainURL + '/filmas/popularakas/',
                     'state_movies',
                     '%s/star.png' % kodi_func.iconpath,
                     source_id=mySourceId)
    # kodi_func.addDir('TOP 50 Filmas', mainURL + '/index/top_50_filmas/0-4', 'state_movies', '%s/star.png'% kodi_func.iconpath, source_id=mySourceId)

    print "ELEMENTS: ", nav_links_list
    print nav_links
    print nav_links_name
    for i in range(0, len(nav_links)):
        if kodi_func.isLinkUseful(nav_links[i]):
            # print mainURL + nav_links[i]
            link_name = re.sub("<i.+></i>", '', nav_links_name[i]).strip()
            kodi_func.addDir(link_name.encode('utf-8'),
                             mainURL + nav_links[i],
                             'state_movies',
                             kodi_func.GetCategoryImage(link_name),
                             source_id=mySourceId)
예제 #18
0
def SearchRaw(searchStr):

    result = []

    if searchStr == False or len(searchStr) == 0: return result

    html = network.getHTML("http://skaties.lv/filmas/?q=" + searchStr)

    content = common.parseDOM(html, "div", attrs={"id": "content"})
    moviesList = common.parseDOM(content,
                                 "ul",
                                 attrs={"class": "movies clearfix"})
    moviesOriginalDiv = common.parseDOM(moviesList,
                                        "div",
                                        attrs={"class": "original"})
    moviesFigures = common.parseDOM(moviesOriginalDiv, "figure")
    moviesTitleList = common.parseDOM(moviesFigures, "img", ret="alt")
    moviesThumbnailURLsList = common.parseDOM(moviesFigures, "img", ret="src")
    moviesURLs = common.parseDOM(moviesList,
                                 "a",
                                 attrs={"class": "button primary-button"},
                                 ret="href")
    print moviesList, moviesTitleList, moviesThumbnailURLsList, moviesURLs
    print str(len(moviesTitleList)) + " " + str(
        len(moviesThumbnailURLsList)) + " " + str(len(moviesURLs))

    # for i in range(0, len(moviesURLs)):
    # kodi_func.addDir(moviesTitleList[i].encode('utf-8'), mainURL + moviesURLs[i], 'state_play', moviesThumbnailURLsList[i], source_id=mySourceId)

    for i in range(0, len(moviesURLs)):
        result.append({
            'title': moviesTitleList[i].encode('utf-8'),
            'url': mainURL + moviesURLs[i],
            'thumb': moviesThumbnailURLsList[i],
            'state': 'state_play',
            'source_id': mySourceId
        })

    return result
예제 #19
0
def Movies(url, page=1):

    print "Original URL: ", url
    generatedUrl = url
    if mainURL not in generatedUrl:
        generatedUrl = mainURL + generatedUrl

    if "?get=" in generatedUrl:
        index = generatedUrl.index("?")
        generatedUrl = generatedUrl[:index] + "/page/" + str(
            page) + "/" + generatedUrl[index:]
    else:
        generatedUrl = generatedUrl + "/page/" + str(page)

    print "generated url", generatedUrl
    html = network.getHTML(generatedUrl)
    # print "html" + url
    moviesList = common.parseDOM(html, "div", attrs={"class": "poster"})
    moviesThumbnailURLsList = common.parseDOM(moviesList, "img", ret="src")
    moviesListData = common.parseDOM(html, "div", attrs={"class": "data"})
    moviesTitleList = common.parseDOM(moviesListData, "a")
    moviesURLs = common.parseDOM(moviesListData, "a", ret="href")
    # print moviesThumbnailURLsList

    for i in range(0, len(moviesURLs)):
        kodi_func.addDir(moviesTitleList[i].encode('utf-8'),
                         moviesURLs[i],
                         'state_play',
                         moviesThumbnailURLsList[i],
                         source_id=mySourceId)

    if len(moviesURLs) >= 40:
        kodi_func.addDir("Nākamā Lapa >>",
                         url,
                         'state_movies',
                         '%s/next.png' % kodi_func.iconpath,
                         str(int(page) + 1),
                         source_id=mySourceId)
예제 #20
0
def PlayMovie(url, title, picture):
    print "url: " + url
    html = network.getHTML(url)
    # print "html: " + html

    mainMovieCol = common.parseDOM(html, "div", attrs={"id": "movie"})
    print mainMovieCol
    video = common.parseDOM(mainMovieCol, "iframe", ret="src")[0]

    try:
        link = urlresolver.resolve(video)
        if link != False:
            kodi_func.addLink(
                title.decode('utf-8').encode('utf-8') + " - Latviski",
                link.encode('utf-8'), picture)
        elif kodi_func.isVideoFormat(video.split(".")[-1]):
            kodi_func.addLink(
                title.decode('utf-8').encode('utf-8') + " - Latviski", video,
                picture)
        print link
    except:
        xbmcgui.Dialog().ok("Opā!", "Nevarēju dekodēt strīmu",
                            "Iespējams ka fails vairs neeksistē",
                            "Tāda dzīve, mēģini citi avotu")
예제 #21
0
def PlayMovie(url, title, picture):
	print "url: " + url
	html = network.getHTML(url)
	# print "html: " + html
	
	streamLangNames = []
	
	mainMovieCol = common.parseDOM(html, "div", attrs = { "class": "videooPlayer"} )
	mainMovieCol = mainMovieCol[0].replace("\n", "").replace("<br>", "").replace("<br />", "")
	
	streamLangNames = re.findall('[(A-Z A-Z)|(A-Z)]+<iframe', mainMovieCol)
	movieStreamSrc = common.parseDOM(mainMovieCol, "iframe", ret = "src" )
	
	# For f***s sake, not only this website has hqq links but sometimes it hides them in ;eval obfuscators. Come on gentelmen make my life a bit easier
	if ";eval" in mainMovieCol:
		js = mainMovieCol.split('<script language="javascript" type="text/javascript">',1)[1].replace("</script>", "")
		print js
		jsDecoded = getURLFromObfJs(js)
		if re.search(r'<form(.+?)action="[^"]*(hqq|netu)\.tv/player/embed_player\.php"[^>]*>', jsDecoded):
			movieStreamSrc.append( jsDecoded )
		else:
			movieStreamSrc = common.parseDOM(jsDecoded, "iframe", ret = "src" )
	elif "/player/hash.php" in mainMovieCol:
		searchObj = re.search(r'(https:|http:)\/\/(hqq|netu)\.tv/player/hash\.php\?hash=\d+', html)
		if searchObj:
			resolvedHashUrl = searchObj.group(0)
			print "RESOLVED HASH URL: " + resolvedHashUrl	
			movieStreamSrc.append(resolvedHashUrl)
		else:
			print "WTF, couldn't find the hash url"
			return False
	elif "data:text/javascript;charset=utf-8;base64" in mainMovieCol:
		movieStreamSrc.append(mainMovieCol)
	
	
	   
	print "Important HTML elements:"
	print mainMovieCol, streamLangNames, movieStreamSrc
	for i in range(0, len(movieStreamSrc)):
		# sometimes the links are hidden in goo.gl shortener, if so, we first need to unshorten
		if "goo.gl" in movieStreamSrc[i]:
			movieStreamSrc[i] = network.unshorten_url( movieStreamSrc[i] )
	
		# If it is the normal stream utilise the hqqresolver
		if "hqq.tv" in movieStreamSrc[i] or "netu.tv" in movieStreamSrc[i] or "data:text/javascript;charset=utf-8;base64" in movieStreamSrc[i] or "<form" in movieStreamSrc[i]:
			link = hqqresolver.resolve(movieStreamSrc[i])
			print "resolved link: ",link
			
			if not link:
				print "Well hqqresolver script failed... let's try my one"
				parsed = urlparse.urlparse( movieStreamSrc[i] )
				vid = urlparse.parse_qs(parsed.query)['vid'][0]
				print ("VID: " + vid)
				hqqvidresolver = hqqresolver2.hqqResolver()
                                    
				# Parse the final URL
				link = hqqvidresolver.resolve(vid)
				print ("Final URL: " + link)

				# resolveHQQ(movieStreamSrc[i], url)
			else:
				link = link[0]['url']
		else: # or sometimes we get openload.co stream
			link = urlresolver.resolve(movieStreamSrc[i])
		
		if i < len(streamLangNames):
			streamLang = " - " + streamLangNames[i][:-7]
		else:
			streamLang = ""
		print streamLang
		
		if link != False:
			print link
		
		if link != False:
			kodi_func.addLink(title.decode('utf-8').encode('utf-8') + streamLang.encode('utf-8'), link.encode('utf-8'), picture)	
		elif kodi_func.isVideoFormat(movieStreamSrc[i].split(".")[-1]):
			kodi_func.addLink(title.decode('utf-8').encode('utf-8') + streamLang.encode('utf-8'), movieStreamSrc[i], picture)
예제 #22
0
def Movies(url, page=1):

    print "url: " + url
    if '?page1' in url:
        html = network.getHTML(mainURL + "/?page" + str(page))
    else:
        html = network.getHTML(url + "-" + str(page))
        # html = network.getHTML(url)

    # print "html " + html
    allEntries = common.parseDOM(html, "div", attrs={"id": "allEntries"})
    if len(allEntries) == 0:
        allEntries = common.parseDOM(html,
                                     "table",
                                     attrs={"id": "entry_table"})
    # print allEntries
    infoTd = common.parseDOM(allEntries, "td", attrs={"class": "info"})
    moviesURLs = common.parseDOM(infoTd, "a", ret="href")
    moviesThumbnailURLsList = common.parseDOM(allEntries, "td", ret="style")
    if len(moviesThumbnailURLsList) == 0:
        moviesThumbnailURLsList = common.parseDOM(allEntries,
                                                  "img",
                                                  attrs={
                                                      "width": "80",
                                                      "height": "100"
                                                  },
                                                  ret="src")
    moviesTitleList = common.parseDOM(infoTd,
                                      "button",
                                      attrs={"class": "entry_button"})
    # moviesYearList = common.parseDOM(infoTd, "div", attrs = {"style": "width: 100px; height: 18px; background: url(http://www.fom.ucoz.lv/jauns_img/entry_year.png) no-repeat; margin: 0px auto; padding-top: 2px;"} )
    print allEntries, infoTd, moviesURLs, moviesThumbnailURLsList, moviesTitleList
    # moviesTitleList = common.parseDOM(moviesList, "h2")
    # moviesThumbnailURLsList = common.parseDOM(moviesList, "img", attrs = { "class": "img-thumbnail" }, ret = "src")
    # moviesURLs = common.parseDOM(moviesList, "a", ret = "href")
    # print moviesThumbnailURLsList

    for i in range(0, len(moviesURLs)):
        thumb = moviesThumbnailURLsList[i].replace(
            "); width: 80px; height: 100px;",
            "").replace("background:url(", "").replace("/s", "/")
        if network.exists(mainURL + thumb) == False:
            thumb = thumb.replace(".jpg", ".png")
        # title = re.sub(r'<br>[\w <>="-:\d;#&\\\\]*', '', moviesTitleList[i])
        title = moviesTitleList[i].partition("<br>")[0].replace(
            '<img src="http://fof.lv/lat-sub-icon.png" style="position: relative; left: 10px; top: 2px;">',
            '')
        if not moviesURLs[i].startswith("http://"):
            movieURL = mainURL + moviesURLs[i]
        else:
            movieURL = moviesURLs[i]
        kodi_func.addDir(title.encode('utf-8'),
                         movieURL,
                         'state_play',
                         mainURL + thumb,
                         source_id=mySourceId)

    if len(
            moviesURLs
    ) >= 10 and url != 'http://www.fof.lv/index/popularakas_filmas/0-13' and url != 'http://www.fof.lv/index/vertetakas_filmas/0-16':
        kodi_func.addDir("Nākamā Lapa >>",
                         url,
                         'state_movies',
                         '%s/next.png' % kodi_func.iconpath,
                         str(int(page) + 1),
                         source_id=mySourceId)
예제 #23
0
def IndexMovies(baseUrl, fileName):
    progress_dialog = xbmcgui.DialogProgress()
    progress_dialog.create("Indeksējam fof.lv")

    currentPage = 1

    url = baseUrl + str(currentPage)
    html = network.getHTML(url)

    allEntries = common.parseDOM(html, "div", attrs={"id": "allEntries"})
    if len(allEntries) == 0:
        allEntries = common.parseDOM(html,
                                     "table",
                                     attrs={"id": "entry_table"})
    # print allEntries
    infoTd = common.parseDOM(allEntries, "td", attrs={"class": "info"})
    moviesURLs = common.parseDOM(infoTd, "a", ret="href")
    moviesThumbnailURLsList = common.parseDOM(allEntries, "td", ret="style")
    if len(moviesThumbnailURLsList) == 0:
        moviesThumbnailURLsList = common.parseDOM(allEntries,
                                                  "img",
                                                  attrs={
                                                      "width": "80",
                                                      "height": "100"
                                                  },
                                                  ret="src")
    moviesTitleList = common.parseDOM(infoTd,
                                      "button",
                                      attrs={"class": "entry_button"})
    # moviesYearList = common.parseDOM(infoTd, "div", attrs = {"style": "width: 100px; height: 18px; background: url(http://www.fom.ucoz.lv/jauns_img/entry_year.png) no-repeat; margin: 0px auto; padding-top: 2px;"} )
    print allEntries, infoTd, moviesURLs, moviesThumbnailURLsList, moviesTitleList

    indexed = 0

    # movieEntriesList = common.parseDOM( html, "ul", attrs = { "id": "uEntriesList" })
    # screenList = common.parseDOM( movieEntriesList, "div", attrs = {"class": "ve-screen"})
    # movieUrls = common.parseDOM(screenList, "a", ret = "href")
    # print movieUrls, len(movieUrls)
    movieURLIndex = 0

    localFile = kodi_func.home + "/resources/" + fileName  # xbmc.translatePath('special://temp/'+fileName )
    temp = codecs.open(localFile, 'w', "utf-8")

    movieIndexes = []
    movieEntries = 370
    for indexed in range(0, int(movieEntries)):
        if movieURLIndex == len(moviesURLs): break

        progress = int(float((float(indexed) / int(movieEntries)) * 100))
        # print "Progress: " + str(progress)
        progress_dialog.update(progress, "Lūdzu uzgaidi...",
                               "Indeksējam fof.lv Filmas ",
                               "Atlicis: " + str(int(movieEntries) - indexed))
        if (progress_dialog.iscanceled()): return

        thumb = moviesThumbnailURLsList[movieURLIndex].replace(
            "); width: 80px; height: 100px;",
            "").replace("background:url(", "").replace("/s", "/")
        print "thumb: " + thumb
        if network.exists(mainURL + thumb) == False:
            thumb = thumb.replace(".jpg", ".png")
        # title = re.sub(r'<br>[\w <>="-:\d;#&\\\\]*', '', moviesTitleList[i])
        title = moviesTitleList[movieURLIndex].partition("<br>")[0]
        if not moviesURLs[movieURLIndex].startswith("http://"):
            movieURL = mainURL + moviesURLs[movieURLIndex]
        else:
            movieURL = moviesURLs[i]

        print title.encode('utf-8')
        temp.write(title + "|" + movieURL + "|" + mainURL + thumb + "\n")
        movieIndexes.append({
            'title': title,
            'url': movieURL,
            'thumb': mainURL + thumb
        })

        movieURLIndex += 1

        if len(moviesURLs) == movieURLIndex:
            currentPage += 1
            html = network.getHTML(baseUrl + str(currentPage))
            allEntries = common.parseDOM(html,
                                         "div",
                                         attrs={"id": "allEntries"})
            if len(allEntries) == 0:
                allEntries = common.parseDOM(html,
                                             "table",
                                             attrs={"id": "entry_table"})
            # print allEntries
            infoTd = common.parseDOM(allEntries, "td", attrs={"class": "info"})
            moviesURLs = common.parseDOM(infoTd, "a", ret="href")
            moviesThumbnailURLsList = common.parseDOM(allEntries,
                                                      "td",
                                                      ret="style")
            if len(moviesThumbnailURLsList) == 0:
                moviesThumbnailURLsList = common.parseDOM(allEntries,
                                                          "img",
                                                          attrs={
                                                              "width": "80",
                                                              "height": "100"
                                                          },
                                                          ret="src")
            moviesTitleList = common.parseDOM(infoTd,
                                              "button",
                                              attrs={"class": "entry_button"})
            # print movieUrls, len(movieUrls)
            movieURLIndex = 0

    temp.close()
    return movieIndexes
예제 #24
0
def parse_tivix_guide(url):
	pDialog = xbmcgui.DialogProgress()
	pDialog.create('Lejupielādēju tv programmu', 'Lūdzu uzgaidi...', random.choice(loadingMessages))
	
	html = network.getHTML( url )
	html = html.replace("tabs__content active", "tabs__content")
	
	
	tabsContent = common.parseDOM(html, "div", attrs = { "class": "tabs__content" })
	print "tabsContent div", tabsContent, len(tabsContent)
	
	# program_entry_now = common.parseDOM(html, "div", attrs = {"class": "tabs__content active"} )	
	# playing_now = ''
	# if len(program_entry_now) > 0:
		# spanEntry = common.parseDOM( program_entry_now[0], "span" )
		# time = common.parseDOM( spanEntry, "span" )[0]
		# title = network.cleanHTML( spanEntry[0] ).strip().replace("\n","").replace("\r", "").replace(time+" ", "")		
		# playing_now = time + " - " + title	
		# playing_now = playing_now.encode('utf-8')
	# print "now playing: ", playing_now
	
	def parseDay(tabsContent, day):		
		
		print "Parsing day: ", day
		
		program_list_div = common.parseDOM(tabsContent[day], "div")
		print "program_list_div", program_list_div
		# program_entry = common.parseDOM(program_list_div, "div", attrs = {"class": "row hover_teleprograma "} )
		program_items = []
		time = None
		title = None
		for pEntry in program_list_div:
			if len(pEntry) == 0:
				continue
				
			if time == None:				
				time = pEntry
				continue
			elif title == None:				
				title = network.html_decode( network.cleanHTML( pEntry ) )
				program_items.append( time + " - " + title )
				time = None
				title = None
		return program_items
	
	today = date.today()	
	pDialog.update( 25 )
	program_today = parseDay(tabsContent, today.weekday() )
	playing_now = ''
	# currTime =  time.strftime('%H:%M')
	currTime = network.getHTML( "http://dev.morf.lv/timezone.php" ) #shitty python doesn't have timezone library by default
	for row in program_today:
		pTime = row[:5]
		print pTime + " <= " + currTime
		if pTime <= currTime:			
			playing_now = row.encode('utf-8')
		else:
			break		
	
	pDialog.update( 50 )
	program_tomorrow = parseDay(tabsContent, (today + datetime.timedelta(days=1)).weekday() )
	pDialog.update( 75 )
	program_aftertomorrow = parseDay(tabsContent, (today + datetime.timedelta(days=2)).weekday() )
	pDialog.update( 100 )
	program_afteraftertomorrow = parseDay(tabsContent, (today + datetime.timedelta(days=3)).weekday() )
	
	return GuideData(playing_now, program_today, program_tomorrow, program_aftertomorrow, program_afteraftertomorrow)