def getFilmInfo(self, url): print "*** getFilmInfo for url %s " % url response = common.fetchPage({"link": url}) container = common.parseDOM(response["content"], "div", attrs={"id": "container"}) source = common.parseDOM(response["content"], "div", attrs={"id": "players"})[0] title = self.encode(common.parseDOM(container, "h1")[0]) image = common.parseDOM(container, "img", attrs={"id": "imgbigp"}, ret="src")[0] quality = common.parseDOM(container, "div", attrs={"class": "full-quality"}) manifest_links, subtitles, season, episode = host_manager.get_playlist(response["content"]) if manifest_links: list = sorted(manifest_links.iteritems(), key=itemgetter(0)) if season: title += " - s%se%s" % (season.zfill(2), episode.zfill(2)) for quality, link in list: film_title = "[COLOR=lightgreen][%s][/COLOR] %s" % (str(quality), title) uri = sys.argv[0] + '?mode=play&url=%s&title=%s' % (urllib.quote_plus(link), title) item = xbmcgui.ListItem(film_title, iconImage=image, thumbnailImage=image) item.setInfo(type='Video', infoLabels={'title': film_title, 'label': film_title, 'plot': film_title, 'overlay': xbmcgui.ICON_OVERLAY_WATCHED, 'playCount': 0}) item.setProperty('IsPlayable', 'true') if subtitles: item.setSubtitles([subtitles]) xbmcplugin.addDirectoryItem(self.handle, uri, item, False) else: self.showErrorMessage("Unknown host") return xbmcplugin.setContent(self.handle, 'movies') xbmcplugin.endOfDirectory(self.handle, True)
def getFilmInfo(self, url): print "*** getFilmInfo" response = common.fetchPage({"link": url}) response_ = response url2 = url if response["status"] == 200: movie = common.parseDOM(response["content"], "div", attrs={"class": "full_movie"}) values = common.parseDOM(movie, "param", ret="value") values = None links = [] scripts = common.parseDOM(response['content'], 'script') for script in scripts: if ('.mp4' in script): link2 = script.split('file:"')[-1].split('",')[0] content2 = common.fetchPage({"link": link2}) links = links.append(content2["content"].split('"file":"') [-1].split('"}')[0]) if ('"pl":"' in script): link2 = script.split('"pl":"')[-1].split('",')[0] values = common.fetchPage({"link": link2}) if not values and not links: vp = common.parseDOM(response['content'], 'object', attrs={"id": "videoplayer1257"}) if vp: link2 = vp[0].split(';pl=')[-1].split('&')[0] values = common.fetchPage({"link": link2}) if not values and not links: iframe = None try: iframe = common.parseDOM(movie, "iframe", ret="src")[0] except: try: iframe = common.parseDOM(movie, "script", ret="src")[0] response = common.fetchPage({"link": iframe}) iframe = response['content'].split( '"src", "')[-1].split('");')[0] except: pass if iframe: manifest_links, subtitles, season, episode = host_manager.get_playlist( movie) if manifest_links: list = sorted(manifest_links.iteritems(), key=itemgetter(0)) for quality, link in list: links.append(link) else: link = iframe #import urlparse #linkparse = urlparse.urlsplit(iframe) host = "km396z9t3.xyz" #iframe = urlparse.urlunsplit((linkparse.scheme, host, linkparse.path, '', '')) #link = iframe + '?ref=' + self.domain url2 = urllib.quote_plus(link) headers = { 'Host': host, 'Referer': iframe, 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36' } #try: request = urllib2.Request(link, "", headers) request.get_method = lambda: 'GET' response = urllib2.urlopen(request) data = response.read() #iframe = common.parseDOM(data, "iframe", ret="src")[0] #request = urllib2.Request(iframe, "", headers) #request.get_method = lambda: 'GET' #data = urllib2.urlopen(request).read() #tvshow tvshow = common.parseDOM(data, "select", attrs={"name": "season"}) if tvshow: data = self.select_episode(data, iframe, headers) if (data == ""): return False data = data.split('media: [')[-1].split('],')[0] data = data.split('},{') for item in data: url_ = "http:" + item.split("url: '")[-1].split( "'")[0] links.append(url_) #except: # self.showErrorMessage('No media source (YouTube, ...)') # return False poster = common.parseDOM(movie, "div", attrs={"class": "full_movie_poster"}) description = common.parseDOM(movie, "div", attrs={"class": "full_movie_desc"}) details = common.parseDOM( movie, "ul", attrs={"class": "full_movie_details_data"}) infos = common.parseDOM(details, "li") image = common.parseDOM(poster, "img", ret="src")[0] image = self.url + image year = infos[2].split('</span>')[-1].split("(")[0].strip() title = "%s (%s)" % (self.encode( common.parseDOM(infos[0], "h1")[0]), year) genres = self.encode((', ').join(common.parseDOM(infos[4], "a"))) desc = common.stripTags( self.encode(description[0].split('<br>')[-1])) if links: self.log("This is a film") for i, link in enumerate(links): uri = sys.argv[0] + '?mode=play&url=%s&url2=%s' % (link, url2) item = xbmcgui.ListItem("#%d. " % (i + 1) + title, iconImage=image) item.setInfo(type='Video', infoLabels={ 'title': title, 'genre': genres, 'plot': desc, 'overlay': xbmcgui.ICON_OVERLAY_WATCHED, 'playCount': 0 }) item.setProperty('IsPlayable', 'true') xbmcplugin.addDirectoryItem(self.handle, uri, item, False) xbmcplugin.setContent(self.handle, 'movies') else: print "This is a season" response = response_ if response["status"] == 200: player = "" try: player = common.parseDOM( response["content"], "object", attrs={"type": "application/x-shockwave-flash"})[0] except: pass pl_url = player.split("pl=")[-1].split("&")[0] response = common.fetchPage({"link": pl_url}) response = eval(response["content"]) if 'playlist' in response['playlist'][0]: print "This is a season multiple seasons" for season in response['playlist']: episods = season['playlist'] for episode in episods: etitle = "%s (%s)" % (episode['comment'], common.stripTags( season['comment'])) uri = sys.argv[ 0] + '?mode=play&url=%s&url2=%s' % ( episode['file'], url2) item = xbmcgui.ListItem(etitle, iconImage=image) info = { 'title': title, 'genre': genres, 'plot': desc, 'overlay': xbmcgui.ICON_OVERLAY_WATCHED, 'playCount': 0 } item.setInfo(type='Video', infoLabels=info) item.setProperty('IsPlayable', 'true') xbmcplugin.addDirectoryItem( self.handle, uri, item, False) else: print "This is one season" for episode in response['playlist']: etitle = episode['comment'] url_ = episode['file'] uri = sys.argv[0] + '?mode=play&url=%s&url2=%s' % ( url_, url2) item = xbmcgui.ListItem(etitle, iconImage=image) info = { 'title': title, 'genre': genres, 'plot': desc, 'overlay': xbmcgui.ICON_OVERLAY_WATCHED, 'playCount': 0 } item.setInfo(type='Video', infoLabels=info) item.setProperty('IsPlayable', 'true') xbmcplugin.addDirectoryItem( self.handle, uri, item, False) else: self.showErrorMessage( "getFilmInfo(): Bad response status%s" % response["status"]) xbmcplugin.setContent(self.handle, 'episodes') else: self.showErrorMessage("getFilmInfo(): Bad response status%s" % response["status"]) xbmcplugin.endOfDirectory(self.handle, True)