def SortMenuYears(lang, cat, **kwargs): oc = ObjectContainer(title2=cat.title()) page_elems = common.GetPageElements(BASE_URL + "/movie/browse/?lang=" + lang) tabs = page_elems.xpath( ".//section[@id='UIMovieFinder']//div[@class='tabview'][2]//div[@class='innertab simpletext'][position()>1]//a" ) for block in tabs: url = BASE_URL + block.xpath(".//@href")[0] title = block.xpath(".//text()")[0] oc.add( DirectoryObject(key=Callback(PageDetail, lang=lang, cat=cat, key=title), title=title)) oc.add( InputDirectoryObject(key=Callback(Search, lang=lang), title='Search', summary='Search Movies', prompt='Search for...', thumb=R(ICON_SEARCH))) return oc
def SortMenuHotPicks(lang, cat, **kwargs): oc = ObjectContainer(title2=cat.title()) page_elems = common.GetPageElements(BASE_URL + "/movie/browse/?lang=" + lang) tabs = page_elems.xpath( ".//section[@id='UIFeaturedFilms']//div[@class='tabview']") for block in tabs: loc = BASE_URL + block.xpath(".//div[@class='block1']//@href")[0] try: thumb = "http:" + block.xpath(".//div[@class='block1']//@src")[0] except: thumb = "http:" + block.xpath( ".//div[@class='block1']//@data-src")[0] title = block.xpath( ".//div[@class='block2']//a[@class='title']//text()")[0] summary = "Synopsis currently unavailable." oc.add( DirectoryObject(key=Callback(EpisodeDetail, title=title, url=loc), title=title, summary=summary, thumb=Resource.ContentsOfURLWithFallback( url=thumb, fallback='MoviePosterUnavailable.jpg'))) oc.add( InputDirectoryObject(key=Callback(Search, lang=lang), title='Search', summary='Search Movies', prompt='Search for...', thumb=R(ICON_SEARCH))) return oc
def Search(query, lang, page_count='1', **kwargs): title = query Dict[TITLE.lower() + 'MyCustomSearch' + query] = query Dict[TITLE.lower() + 'MyCustomSLang' + query] = lang Dict.Save() oc = ObjectContainer(title2='Search Results') url = (BASE_URL + '/movie/results/' + '?lang=' + lang + '&page=' + page_count + '&query=%s' % String.Quote(query, usePlus=True)) page_elems = common.GetPageElements(url) movies = page_elems.xpath(".//section[@id='UIMovieSummary']/ul/li") for block in movies: loc = BASE_URL + block.xpath(".//div[@class='block1']//@href")[0] thumb = "http:" + block.xpath(".//div[@class='block1']//img/@src")[0] title = block.xpath( ".//div[@class='block2']//a[@class='title']//text()")[0] try: summary = block.xpath(".//p[@class='synopsis']//text()")[0] if summary == None or summary == "": summary = "Synopsis currently unavailable." except: summary = "Synopsis currently unavailable." try: profs = block.xpath( ".//div[@class='professionals']//div[@class='prof']") for prof in profs: summary += "\n " summary += prof.xpath(".//label//text()")[ 0] + " : " + prof.xpath(".//p//text()")[0] except: pass oc.add( DirectoryObject(key=Callback(EpisodeDetail, title=title, url=loc), title=title, summary=summary, thumb=Resource.ContentsOfURLWithFallback( url=thumb, fallback='MoviePosterUnavailable.jpg'))) curr_page = int( page_elems.xpath( ".//div[@class='pagination']//span[@class='active']//text()")[0]) last_page = int( page_elems.xpath("(.//div[@class='pagination']//span//text())[last()]") [0]) if last_page > curr_page: oc.add( DirectoryObject(key=Callback(Search, lang=lang, query=query, page_count=int(page_count) + 1), title="Next Page >>", thumb=R(ICON_NEXT))) if len(oc) == 0: return ObjectContainer(header=title, message='No Videos Available') return oc
def SortMenuCast(lang, cat, **kwargs): oc = ObjectContainer(title2=cat.title()) page_elems = common.GetPageElements(BASE_URL + "/movie/browse/?lang=" + lang) tabs = page_elems.xpath( ".//section[@id='UIMovieFinder']//div[@class='tabview'][3]//div[@class='innertab'][position()<3]//a" ) for block in tabs: url = BASE_URL + block.xpath(".//@href")[0] title = block.xpath(".//label//text()")[0] try: thumb = "http:" + block.xpath(".//@src")[0] except: thumb = "http:" + block.xpath(".//@data-src")[0] id = re.findall(r'id=(.*?)&', url)[0] oc.add( DirectoryObject(key=Callback(PageDetail, lang=lang, cat=cat, key=id), title=title, thumb=Resource.ContentsOfURLWithFallback( url=thumb, fallback='MoviePosterUnavailable.jpg'))) if len(oc) > 0: oc.objects.sort(key=lambda obj: obj.title, reverse=False) oc.add( InputDirectoryObject(key=Callback(Search, lang=lang), title='Search', summary='Search Movies', prompt='Search for...', thumb=R(ICON_SEARCH))) return oc
def SetLanguage(**kwargs): oc = ObjectContainer(title2='Select Language') page_elems = common.GetPageElements(BASE_URL + "/intro/") if page_elems == None and Prefs["use_https_alt"]: return ObjectContainer( header=title, message= 'Page was not retrieved. SSL Alternate method not compatible. Try using Proxy method.' ) if page_elems == None and Prefs["use_proxy"]: return ObjectContainer( header=title, message='Page was not retrieved. Proxy did not work.') if page_elems == None: return ObjectContainer( header=title, message='Page was not retrieved. Try enabling SSL Alternate method.' ) blocks = page_elems.xpath(".//div[@class='block1']//ul") for block in blocks: langblock = block.xpath(".//li") for langsq in langblock: lang = langsq.xpath(".//p//text()")[0] try: lang_img = "http:" + langsq.xpath(".//img//@src")[0] except: lang_img = "http:" + langsq.xpath(".//img//@data-src")[0] oc.add( DirectoryObject(key=Callback(SortMenu, lang=lang.lower()), title=lang, thumb=Resource.ContentsOfURLWithFallback( url=lang_img, fallback='MoviePosterUnavailable.jpg'))) return oc
def EpisodeDetail(title, url, **kwargs): Thread.Create(GetVideoUrl, {}, url) page_elems = common.GetPageElements(url) try: try: thumb = "http:" + page_elems.xpath( ".//section[@id='UIMovieSummary']//div[@class='block1']//@src" )[0] except: thumb = "http:" + page_elems.xpath( ".//section[@id='UIMovieSummary']//div[@class='block1']//@data-src" )[0] except: thumb = None try: summary = page_elems.xpath( ".//section[@id='UIMovieSummary']//p[@class='synopsis']//text()" )[0] except: summary = "Synopsis currently unavailable." try: year = str( page_elems.xpath( ".//section[@id='UIMovieSummary']//div[@class='info']//p[1]//text()" )[0]) except: year = 0000 try: ratings = page_elems.xpath( ".//section[@id='UIMovieSummary']//ul[@class='average-rating']//p//text()" ) rating = float(0.0) for rate in ratings: rating += float(rate) rating = rating * 10 / 25 except: rating = float(0.0) try: profs = page_elems.xpath( ".//section[@id='UIMovieSummary']//div[@class='professionals']//div[@class='prof']" ) for prof in profs: summary += "\n " summary += prof.xpath(".//label//text()")[0] + " : " + prof.xpath( ".//p//text()")[0] except: pass trailer_urls = page_elems.xpath( ".//section[@id='UIMovieSummary']//div[@class='extras']//@href") for trailer_u in trailer_urls: if 'youtube' in trailer_u: trailer = trailer_u.replace("/myaddrproxy.php/https/", "http://") title = title oc = ObjectContainer(title1=unicode(title), art=thumb) art = thumb timer = 0 while VideoURL['GetVideoUrlComplete'] == 'False': time.sleep(1) timer += 1 if timer > 20: # using 20 sec. timeout return ObjectContainer(header=title, message=title + ' : Timeout error occurred !') furl = VideoURL['GetVideoUrlComplete'] datacenter = VideoURL['GetVideoUrlDatacenter'] # fix San Jose datacenter label if datacenter == 'San': datacenter = 'San Jose' if 'error-fail' in furl: return ObjectContainer(header=title, message=title + ' could not be fetched !') try: oc.add( VideoClipObject(url=trailer, art=art, title=title + " (Trailer)", thumb=Resource.ContentsOfURLWithFallback( url=thumb, fallback='MoviePosterUnavailable.jpg'), summary=summary)) except: trailer = "" server_n = DetermineCurrentServer(furl, datacenter) try: oc.add( VideoClipObject(url="einthusan://" + E( JSON.StringFromObject({ "url": furl, "title": title, "summary": summary, "thumb": thumb, "year": year, "rating": rating })), art=art, title=title + " (via " + datacenter + " Server ID:" + server_n + ")", thumb=thumb, summary=summary)) except: url = "" furl2, server_n2, ret_code = AvailableSourceFrom(furl, Prefs["locationPref"]) if ret_code == "200": #server_n2 = DetermineCurrentServer(furl2, Prefs["locationPref"]) try: oc.add( VideoClipObject(url="einthusan://" + E( JSON.StringFromObject({ "url": furl2, "title": title, "summary": summary, "thumb": thumb, "year": year, "rating": rating })), art=art, title=title + " (via " + Prefs["locationPref"] + " Server ID:" + server_n2 + ")", thumb=thumb, summary=summary)) except: url = "" oc.add( DirectoryObject(key=Callback(AllAvailableSources, furl=furl, title=title, summary=summary, thumb=thumb, year=year, rating=rating, art=art), title="Other Servers Available", art=art, summary="Play using a different server", thumb=R(ICON_SOURCES))) if Check(title=title, url=url): oc.add( DirectoryObject( key=Callback(RemoveBookmark, title=title, url=url), title="Remove Bookmark", art=art, summary='Removes the current movie from the Boomark que', thumb=R(ICON_QUEUE))) else: oc.add( DirectoryObject( key=Callback(AddBookmark, title=title, url=url), title="Bookmark Video", summary='Adds the current movie to the Boomark que', art=art, thumb=R(ICON_QUEUE))) return oc
def PageDetail(cat, lang, key="none", filter="", page_count="1", **kwargs): cat2title = filter if cat == 'Staff Picks': url = BASE_URL + "/movie/results/?find=StaffPick&lang=" + lang + "&page=" + page_count elif cat == 'Recently Added': url = BASE_URL + "/movie/results/?find=Recent&lang=" + lang + "&page=" + page_count elif cat == 'Regional Hits': url = BASE_URL + "/movie/results/?find=RegionalHit&lang=" + lang + "&page=" + page_count elif cat == 'Coming Soon': url = BASE_URL + "/movie/results/?find=ComingSoon&lang=" + lang + "&page=" + page_count elif cat == 'Number or Alphabet': if key == 'Number': url = BASE_URL + "/movie/results/?find=Numbers&lang=" + lang + "&page=" + page_count else: url = BASE_URL + "/movie/results/?find=Alphabets&lang=" + lang + "&alpha=" + key + "&page=" + page_count elif cat == 'Year': url = BASE_URL + "/movie/results/?find=Year&lang=" + lang + "&year=" + key + "&page=" + page_count elif cat == 'Cast': url = BASE_URL + "/movie/results/?find=Cast&lang=" + lang + "&id=" + key + "&page=" + page_count + "&role=" elif cat == 'Genre': if filter == 'action': find_filter = "&find=Rating&action=4&comedy=1&romance=1&storyline=1&performance=1&ratecount=5" elif filter == 'comedy': find_filter = "&find=Rating&action=1&comedy=4&romance=1&storyline=1&performance=1&ratecount=5" elif filter == 'romance': find_filter = "&find=Rating&action=1&comedy=1&romance=4&storyline=1&performance=1&ratecount=5" elif filter == 'storyline': find_filter = "&find=Rating&action=1&comedy=1&romance=1&storyline=4&performance=1&ratecount=5" elif filter == 'performance': find_filter = "&find=Rating&action=1&comedy=1&romance=1&storyline=1&performance=4&ratecount=5" cat2title = "-%s" % filter.title() url = BASE_URL + "/movie/results/?lang=" + lang + find_filter + "&page=" + page_count oc = ObjectContainer(title2="%s%s" % (cat.title(), cat2title) + " (Page" + page_count + ")") page_elems = common.GetPageElements(url) movies = page_elems.xpath(".//section[@id='UIMovieSummary']/ul/li") for block in movies: loc = BASE_URL + block.xpath(".//div[@class='block1']//@href")[0] try: thumb = "http:" + block.xpath(".//div[@class='block1']//@src")[0] except: thumb = "http:" + block.xpath( ".//div[@class='block1']//@data-src")[0] title = block.xpath( ".//div[@class='block2']//a[@class='title']//text()")[0] try: summary = block.xpath(".//p[@class='synopsis']//text()")[0] if summary == None or summary == "": summary = "Synopsis currently unavailable." except: summary = "Synopsis currently unavailable." try: profs = block.xpath( ".//div[@class='professionals']//div[@class='prof']") for prof in profs: summary += "\n " summary += prof.xpath(".//label//text()")[ 0] + " : " + prof.xpath(".//p//text()")[0] except: pass if cat == 'Coming Soon': oc.add( DirectoryObject(key=Callback(ComingSoon, title=title), title=title, summary=summary, thumb=Resource.ContentsOfURLWithFallback( url=thumb, fallback='MoviePosterUnavailable.jpg'))) else: oc.add( DirectoryObject(key=Callback(EpisodeDetail, title=title, url=loc), title=title, summary=summary, thumb=Resource.ContentsOfURLWithFallback( url=thumb, fallback='MoviePosterUnavailable.jpg'))) curr_page = int( page_elems.xpath( ".//div[@class='pagination']//span[@class='active']//text()")[0]) last_page = int( page_elems.xpath("(.//div[@class='pagination']//span//text())[last()]") [0]) if last_page > curr_page: oc.add( DirectoryObject(key=Callback(PageDetail, lang=lang, cat=cat, key=key, filter=filter, page_count=int(page_count) + 1), title="Next Page >>", thumb=R(ICON_NEXT))) oc.add( InputDirectoryObject(key=Callback(Search, lang=lang), title='Search', summary='Search Movies', prompt='Search for...', thumb=R(ICON_SEARCH))) return oc
def SortMenu(lang, **kwargs): page_elems = common.GetPageElements(BASE_URL + "/intro/") if page_elems == None and Prefs["use_https_alt"]: return ObjectContainer( header='SortMenu', message= 'Page was not retrieved. SSL Alternate method not compatible. Try using Proxy method.' ) if page_elems == None and Prefs["use_proxy"]: return ObjectContainer( header='SortMenu', message='Page was not retrieved. Proxy did not work.') if page_elems == None: return ObjectContainer( header='SortMenu', message='Page was not retrieved. Try enabling SSL Alternate method.' ) cats1 = ['Hot Picks'] cats2 = ['Staff Picks', 'Recently Added'] cats2b = ['Genre'] cats3 = ['Number or Alphabet'] cats4 = ['Year'] cats4b = ['Cast'] cats5 = ['Coming Soon', 'Regional Hits'] oc = ObjectContainer(title2='Sort ' + lang.title() + ' Movies By') for cat in cats1: oc.add( DirectoryObject(key=Callback(SortMenuHotPicks, lang=lang, cat=cat), title=cat, thumb=R(ICON_LIST))) for cat in cats2: oc.add( DirectoryObject(key=Callback(PageDetail, lang=lang, cat=cat), title=cat, thumb=R(ICON_LIST))) for cat in cats2b: oc.add( DirectoryObject(key=Callback(GenreMenu, lang=lang, cat=cat), title=cat, thumb=R(ICON_LIST))) for cat in cats3: oc.add( DirectoryObject(key=Callback(SortMenuAlphabets, lang=lang, cat=cat), title=cat, thumb=R(ICON_LIST))) for cat in cats4: oc.add( DirectoryObject(key=Callback(SortMenuYears, lang=lang, cat=cat), title=cat, thumb=R(ICON_LIST))) for cat in cats4b: oc.add( DirectoryObject(key=Callback(SortMenuCast, lang=lang, cat=cat), title=cat, thumb=R(ICON_LIST))) for cat in cats5: oc.add( DirectoryObject(key=Callback(PageDetail, lang=lang, cat=cat), title=cat, thumb=R(ICON_LIST))) oc.add( InputDirectoryObject(key=Callback(Search, lang=lang), title='Search', summary='Search Movies', prompt='Search for...', thumb=R(ICON_SEARCH))) return oc