def displayMovies(request_obj, response_obj): url = request_obj.get_data()['movieCategoryUrl'] print "indisplay" + url if request_obj.get_data().has_key('page'): url_parts = url.split('?') url_part_A = '' url_part_B = '' if len(url_parts) == 2: url_part_A = url_parts[0] url_part_B = '?' + url_parts[1] else: url_part_A = url if url_part_A[len(url_part_A) - 1] != '/': url_part_A = url_part_A + '/' url = url_part_A + 'page/' + request_obj.get_data()['page'] + url_part_B contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'content'}) soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv) movieTags = soup.findChildren('div', {'class':'post'}) print "intags" + str(movieTags) if len(movieTags) == 0: movieTags = soup.findChildren('div', {'class':'videopost'}) for movieTag in movieTags: item = __retrieveAndCreateMovieItem__(movieTag) response_obj.addListItem(item) response_obj.set_xbmc_content_type('movies') try: pagesInfoTag = soup.findChild('div', {'class':'navigation'}) current_page = int(pagesInfoTag.find('span', {'class':'page current'}).getText()) #print current_page pages = pagesInfoTag.findChildren('a', {'class':'page'}) #print pages last_page = int(pages[len(pages) - 1].getText()) if current_page < last_page: for page in range(current_page + 1, last_page + 1): createItem = False if page == last_page: pageName = AddonUtils.getBoldString(' -> Last Page #' + str(page)) createItem = True elif page <= current_page + 4: pageName = AddonUtils.getBoldString(' -> Page #' + str(page)) createItem = True if createItem: item = ListItem() item.add_request_data('movieCategoryUrl', request_obj.get_data()['movieCategoryUrl']) item.add_request_data('page', str(page)) item.set_next_action_name('Movies_List_Next_Page') xbmcListItem = xbmcgui.ListItem(label=pageName) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) except: pass
def retrieveIndVideoLinks(request_obj, response_obj): video_source_id = 0 video_source_img = None video_part_index = 0 video_playlist_items = [] contentDiv = BeautifulSoup.SoupStrainer('p', {'style':re.compile(r'\bcenter\b')}) soup = HttpClient().getBeautifulSoup(url=request_obj.get_data()['episodeUrl'], parseOnlyThese=contentDiv) for child in soup.findChildren(): if child.name == 'img': if len(video_playlist_items) > 0: response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_playlist_items)) video_source_id = video_source_id + 1 video_source_img = child['src'] video_part_index = 0 video_playlist_items = [] elif child.name == 'a': video_part_index = video_part_index + 1 video_link = {} video_link['videoTitle'] = 'Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) + ' | ' + child.getText() video_link['videoLink'] = str(child['href']) video_playlist_items.append(video_link) item = ListItem() item.add_request_data('videoLink', video_link['videoLink']) item.add_request_data('videoTitle', video_link['videoTitle']) item.set_next_action_name('SnapAndPlayVideo') xbmcListItem = xbmcgui.ListItem(label='Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) , iconImage=video_source_img, thumbnailImage=video_source_img) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) if len(video_playlist_items) > 0: response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_playlist_items))
def displayRecentMovies(request_obj, response_obj): contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'sub-sidebar'}) soup = HttpClient().getBeautifulSoup(url='http://www.pinoymovie.co/', parseOnlyThese=contentDiv) soup = soup.findChild('div', {'class':'right'}) movieLinkTags = soup.findChildren('a') recentMoviesItems = XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__retrieveRecentMovies__'), movieLinkTags, 'Retrieving recent movies and its information', 'Failed to retrieve video information, please try again later', line1='Takes about 5 minutes') response_obj.extendItemList(recentMoviesItems)
def displayTVShowEpisodes(request_obj, response_obj): url = request_obj.get_data()['tvChannelUrl'] contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'content'}) soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv) videoBoxes = soup.findChildren('div', {'id':'videobox'}) for videoBox in videoBoxes: imgTag = videoBox.findChild('img') imageUrl = str(imgTag['src']) metaTag = videoBox.findChild('div', {'class':'meta'}) aTag = metaTag.findChild('a') episodeName = aTag.getText() episodeUrl = str(aTag['href']) item = ListItem() item.add_request_data('episodeName', episodeName) item.add_request_data('episodeUrl', episodeUrl) item.set_next_action_name('Show_Episode_VLinks') xbmcListItem = xbmcgui.ListItem(label=episodeName, iconImage=imageUrl, thumbnailImage=imageUrl) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) pageTag = soup.findChild('div', {'class':'postnav'}) olderPageTag = pageTag.findChild('a', {'class':'blog-pager-older-link'}) if olderPageTag is not None: item = ListItem() item.add_request_data('tvChannelUrl', str(olderPageTag['href'])) pageName = AddonUtils.getBoldString(' -> Next Page') item.set_next_action_name('Show_Episodes_Next_Page') xbmcListItem = xbmcgui.ListItem(label=pageName) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item)
def retrieveVideoLinks(request_obj, response_obj): video_source_id = 1 video_source_img = None video_source_name = None video_part_index = 0 video_playlist_items = [] ignoreAllLinks = False content = BeautifulSoup.SoupStrainer('blockquote', {'class':re.compile(r'\bpostcontent\b')}) soup = HttpClient().getBeautifulSoup(url=request_obj.get_data()['episodeUrl'], parseOnlyThese=content) for e in soup.findAll('br'): e.extract() Logger.logDebug(soup) if soup.has_key('div'): soup = soup.findChild('div', recursive=False) prevChild = '' prevAFont = None for child in soup.findChildren(): if (child.name == 'img' or child.name == 'b' or (child.name == 'font' and not child.findChild('a'))): if (child.name == 'b' and prevChild == 'a') or (child.name == 'font' and child == prevAFont): continue else: if len(video_playlist_items) > 0: response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_source_name, video_playlist_items)) if video_source_img is not None: video_source_id = video_source_id + 1 video_source_img = None video_source_name = None video_part_index = 0 video_playlist_items = [] ignoreAllLinks = False elif not ignoreAllLinks and child.name == 'a' and not re.search('multi', str(child['href']), re.IGNORECASE): video_part_index = video_part_index + 1 video_link = {} video_link['videoTitle'] = 'Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) + ' | ' + child.getText() video_link['videoLink'] = str(child['href']) try: try: __prepareVideoLink__(video_link) except Exception, e: Logger.logFatal(e) video_hosting_info = SnapVideo.findVideoHostingInfo(video_link['videoLink']) if video_hosting_info is None or video_hosting_info.get_video_hosting_name() == 'UrlResolver by t0mm0': raise video_link['videoSourceImg'] = video_hosting_info.get_video_hosting_image() video_link['videoSourceName'] = video_hosting_info.get_video_hosting_name() video_playlist_items.append(video_link) video_source_img = video_link['videoSourceImg'] video_source_name = video_link['videoSourceName'] item = ListItem() item.add_request_data('videoLink', video_link['videoLink']) item.add_request_data('videoTitle', video_link['videoTitle']) item.set_next_action_name('SnapAndPlayVideo') xbmcListItem = xbmcgui.ListItem(label='Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) , iconImage=video_source_img, thumbnailImage=video_source_img) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) prevAFont = child.findChild('font') except:
def displayMoviesMenu(request_obj, response_obj): # ALL Movies movies_icon_filepath = AddonUtils.getCompleteFilePath( baseDirPath=AddonContext().addonPath, extraDirPath=AddonUtils.ADDON_ART_FOLDER, filename="movies.png" ) item = ListItem() item.set_next_action_name("Movies_List") item.add_request_data("movieCategoryUrl", "http://www.pinoymovie.co/") xbmcListItem = xbmcgui.ListItem( label="All Movies", iconImage=movies_icon_filepath, thumbnailImage=movies_icon_filepath ) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) # Recently Added item = ListItem() item.set_next_action_name("Recent_Movies_List") item.add_request_data("movieCategoryUrl", "http://www.pinoymovie.co/") xbmcListItem = xbmcgui.ListItem( label="Recently Added", iconImage=movies_icon_filepath, thumbnailImage=movies_icon_filepath ) item.set_xbmc_list_item_obj(xbmcListItem) # response_obj.addListItem(item) contentDiv = BeautifulSoup.SoupStrainer("div", {"id": "sidebar"}) soup = HttpClient().getBeautifulSoup(url="http://www.pinoymovie.co/", parseOnlyThese=contentDiv) soup = soup.findChild("div", {"class": "right"}) for liItemTag in soup.findChildren("li", {"class": re.compile(r"\bcat-item\b")}): aTag = liItemTag.findChild("a") categoryUrl = aTag["href"] categoryName = aTag.getText() item = ListItem() item.set_next_action_name("Movies_List") item.add_request_data("movieCategoryUrl", categoryUrl) xbmcListItem = xbmcgui.ListItem( label=categoryName, iconImage=movies_icon_filepath, thumbnailImage=movies_icon_filepath ) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) # Search TV search_icon_filepath = AddonUtils.getCompleteFilePath( baseDirPath=AddonContext().addonPath, extraDirPath=AddonUtils.ADDON_ART_FOLDER, filename="search.png" ) item = ListItem() item.set_next_action_name("Search_Movies_List") item.add_request_data("movieCategoryUrl", "http://www.pinoymovie.co/?s=") xbmcListItem = xbmcgui.ListItem( label="Search Movies", iconImage=search_icon_filepath, thumbnailImage=search_icon_filepath ) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item)
def retrieveVideoLinks(request_obj, response_obj): video_source_id = 1 video_source_img = None video_part_index = 0 video_playlist_items = [] ignoreAllLinks = False content = BeautifulSoup.SoupStrainer('blockquote', {'class':re.compile(r'\bpostcontent\b')}) soup = HttpClient().getBeautifulSoup(url=request_obj.get_data()['episodeUrl'], parseOnlyThese=content) if soup.has_key('div'): soup = soup.findChild('div', recursive=False) prevChild = '' for child in soup.findChildren(): if child.name == 'img' or child.name == 'font'or child.name == 'b' : if child.name == 'b' and prevChild == 'a': continue else: if len(video_playlist_items) > 0: response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_playlist_items)) if video_source_img is not None: video_source_id = video_source_id + 1 video_source_img = None video_part_index = 0 video_playlist_items = [] ignoreAllLinks = False elif not ignoreAllLinks and child.name == 'a' and not re.search('multi', str(child['href']), re.IGNORECASE): video_part_index = video_part_index + 1 video_link = {} video_link['videoTitle'] = 'Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) + ' | ' + child.getText() video_link['videoLink'] = str(child['href']) try: __prepareVideoLink__(video_link) video_playlist_items.append(video_link) video_source_img = video_link['videoSourceImg'] item = ListItem() item.add_request_data('videoLink', video_link['videoLink']) item.add_request_data('videoTitle', video_link['videoTitle']) item.set_next_action_name('SnapAndPlayVideo') xbmcListItem = xbmcgui.ListItem(label='Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) , iconImage=video_source_img, thumbnailImage=video_source_img) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) except: print 'Unable to recognize a source = ' + video_link['videoLink'] video_source_img = None video_part_index = 0 video_playlist_items = [] ignoreAllLinks = True prevChild = child.name if len(video_playlist_items) > 0: response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_playlist_items))
def displayRecentMovies(request_obj, response_obj): contentDiv = BeautifulSoup.SoupStrainer("div", {"id": "sub-sidebar"}) soup = HttpClient().getBeautifulSoup(url="http://www.pinoymovie.co/", parseOnlyThese=contentDiv) soup = soup.findChild("div", {"class": "right"}) movieLinkTags = soup.findChildren("a") recentMoviesItems = XBMCInterfaceUtils.callBackDialogProgressBar( getattr(sys.modules[__name__], "__retrieveRecentMovies__"), movieLinkTags, "Retrieving recent movies and its information", "Failed to retrieve video information, please try again later", line1="Takes about 5 minutes", ) response_obj.extendItemList(recentMoviesItems)
def displayMovies(request_obj, response_obj): url = request_obj.get_data()["movieCategoryUrl"] if request_obj.get_data().has_key("page"): url_parts = url.split("?") url_part_A = "" url_part_B = "" if len(url_parts) == 2: url_part_A = url_parts[0] url_part_B = "?" + url_parts[1] else: url_part_A = url if url_part_A[len(url_part_A) - 1] != "/": url_part_A = url_part_A + "/" url = url_part_A + "page/" + request_obj.get_data()["page"] + url_part_B contentDiv = BeautifulSoup.SoupStrainer("div", {"id": "content"}) soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv) movieTags = soup.findChildren("div", {"class": "post"}) for movieTag in movieTags: item = __retrieveAndCreateMovieItem__(movieTag) response_obj.addListItem(item) response_obj.set_xbmc_content_type("movies") pagesInfoTag = soup.findChild("div", {"class": "navigation"}) print pagesInfoTag current_page = int(pagesInfoTag.find("span", {"class": "page current"}).getText()) print current_page pages = pagesInfoTag.findChildren("a", {"class": "page"}) print pages last_page = int(pages[len(pages) - 1].getText()) if current_page < last_page: for page in range(current_page + 1, last_page + 1): createItem = False if page == last_page: pageName = AddonUtils.getBoldString(" -> Last Page #" + str(page)) createItem = True elif page <= current_page + 4: pageName = AddonUtils.getBoldString(" -> Page #" + str(page)) createItem = True if createItem: item = ListItem() item.add_request_data("movieCategoryUrl", request_obj.get_data()["movieCategoryUrl"]) item.add_request_data("page", str(page)) item.set_next_action_name("Movies_List_Next_Page") xbmcListItem = xbmcgui.ListItem(label=pageName) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item)
def displayAllTVShows(request_obj, response_obj): url = request_obj.get_data()['tvChannelUrl'] contentDiv = BeautifulSoup.SoupStrainer('div', {'class':'rightwidget'}) soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv) tvshows = soup.findChildren('a') for tvshow in tvshows: tvshowName = tvshow.getText() tvshowUrl = str(tvshow['href']) item = ListItem() item.add_request_data('tvshowName', tvshowName) item.add_request_data('tvshowUrl', tvshowUrl) item.add_request_data('tvChannelUrl', tvshowUrl) item.set_next_action_name('Show_Episodes') xbmcListItem = xbmcgui.ListItem(label=tvshowName) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item)
def displayMoviesMenu(request_obj, response_obj): # ALL Movies movies_icon_filepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonPath, extraDirPath=AddonUtils.ADDON_ART_FOLDER, filename='movies.png') item = ListItem() item.set_next_action_name('Movies_List') item.add_request_data('movieCategoryUrl', 'http://www.pinoymovie.co/video') xbmcListItem = xbmcgui.ListItem(label='All Movies', iconImage=movies_icon_filepath, thumbnailImage=movies_icon_filepath) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) # Recently Added item = ListItem() item.set_next_action_name('Recent_Movies_List') item.add_request_data('movieCategoryUrl', 'http://www.pinoymovie.co/video') xbmcListItem = xbmcgui.ListItem(label='Recently Added', iconImage=movies_icon_filepath, thumbnailImage=movies_icon_filepath) item.set_xbmc_list_item_obj(xbmcListItem) #response_obj.addListItem(item) contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'sub-sidebar'}) soup = HttpClient().getBeautifulSoup(url='http://www.pinoymovie.co/video', parseOnlyThese=contentDiv) soup = soup.findChild('div', {'class':'right'}) for liItemTag in soup.findChildren('li', {'class':re.compile(r'\bcat-item\b')}): aTag = liItemTag.findChild('a') categoryUrl = aTag['href'] categoryName = aTag.getText() item = ListItem() item.set_next_action_name('Movies_List') item.add_request_data('movieCategoryUrl', categoryUrl) xbmcListItem = xbmcgui.ListItem(label=categoryName, iconImage=movies_icon_filepath, thumbnailImage=movies_icon_filepath) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) # Search TV search_icon_filepath = AddonUtils.getCompleteFilePath(baseDirPath=AddonContext().addonPath, extraDirPath=AddonUtils.ADDON_ART_FOLDER, filename='search.png') item = ListItem() item.set_next_action_name('Search_Movies_List') item.add_request_data('movieCategoryUrl', 'http://www.pinoymovie.co/?s=') xbmcListItem = xbmcgui.ListItem(label='Search Movies', iconImage=search_icon_filepath, thumbnailImage=search_icon_filepath) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item)
def retrieveVideoLinks(request_obj, response_obj): video_source_id = 1 video_source_img = None video_part_index = 0 video_playlist_items = [] #ignoreAllLinks = False url = request_obj.get_data()['episodeUrl'] contentDiv = BeautifulSoup.SoupStrainer('div', {'class':'entry'}) soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv) soup = soup.findChild('div') for child in soup.findChildren(): if child.name == 'img' or child.name == 'param' or child.name == 'object' or child.name == 'b' or child.name == 'font' or child.name == 'br': pass elif child.name == 'span' and re.search('ALTERNATIVE VIDEO', child.getText(), re.IGNORECASE): if len(video_playlist_items) > 0: response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_playlist_items)) video_source_id = video_source_id + 1 video_source_img = None video_part_index = 0 video_playlist_items = [] #ignoreAllLinks = False elif child.name == 'embed' or child.name == 'iframe': if re.search('http://gdata.youtube.com/feeds/api/playlists/', str(child)) or re.search('http://www.youtubereloaded.com/playlists/', str(child)): playlistId = re.compile('/playlists/(.+?)(\&|\.xml)').findall(str(child))[0][0] videoUrls = YouTube.retrievePlaylistVideoItems(playlistId) for videoUrl in videoUrls: try: video_part_index = video_part_index + 1 video_link = {} video_link['videoTitle'] = 'Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) video_link['videoLink'] = videoUrl print "myvidlink"+videoUrl video_hosting_info = SnapVideo.findVideoHostingInfo(video_link['videoLink']) video_link['videoSourceImg'] = video_hosting_info.get_video_hosting_image() video_playlist_items.append(video_link) video_source_img = video_link['videoSourceImg'] item = ListItem() item.add_request_data('videoLink', video_link['videoLink']) item.add_request_data('videoTitle', video_link['videoTitle']) item.set_next_action_name('SnapAndPlayVideo') xbmcListItem = xbmcgui.ListItem(label='Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) , iconImage=video_source_img, thumbnailImage=video_source_img) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) except: print 'Unable to recognize a source = ' + video_link['videoLink'] video_source_img = None video_part_index = 0 video_playlist_items = [] #ignoreAllLinks = True else: videoUrl = str(child['src']) try: video_part_index = video_part_index + 1 video_link = {} video_link['videoTitle'] = 'Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) video_link['videoLink'] = videoUrl print "myvidlink"+videoUrl video_hosting_info = SnapVideo.findVideoHostingInfo(video_link['videoLink']) video_link['videoSourceImg'] = video_hosting_info.get_video_hosting_image() video_playlist_items.append(video_link) video_source_img = video_link['videoSourceImg'] item = ListItem() item.add_request_data('videoLink', video_link['videoLink']) item.add_request_data('videoTitle', video_link['videoTitle']) item.set_next_action_name('SnapAndPlayVideo') xbmcListItem = xbmcgui.ListItem(label='Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) , iconImage=video_source_img, thumbnailImage=video_source_img) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) except: print 'Unable to recognize a source = ' + video_link['videoLink'] video_source_img = None video_part_index = 0 video_playlist_items = [] #ignoreAllLinks = True else: print 'UNKNOWN child name' print child if len(video_playlist_items) > 0: response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_playlist_items))
def retrieveVideoLinks(request_obj, response_obj): url = request_obj.get_data()["movieUrl"] contentDiv = BeautifulSoup.SoupStrainer("div", {"class": "video"}) soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv) decodedSoup = urllib.unquote(str(soup)) videoFrameLinks = re.compile("http://www.pinoymovie.c(o|a)/ajaxtabs/(.+?).htm").findall(decodedSoup) if len(videoFrameLinks) > 0: video_source_id = 1 for ignoreIt, videoFrameLink in videoFrameLinks: # @UnusedVariable try: soup = HttpClient().getBeautifulSoup(url="http://www.pinoymovie.co/ajaxtabs/" + videoFrameLink + ".htm") video_url = str(soup.find("iframe")["src"]) video_hosting_info = SnapVideo.findVideoHostingInfo(video_url) if video_hosting_info is None: print "UNKNOWN streaming link found: " + video_url else: video_source_img = video_hosting_info.get_video_hosting_image() video_title = ( "Source #" + str(video_source_id) + " :: " + video_hosting_info.get_video_hosting_name() ) item = ListItem() item.add_request_data("videoLink", video_url) item.add_request_data("videoTitle", video_title) item.set_next_action_name("SnapAndPlayVideo") xbmcListItem = xbmcgui.ListItem( label=video_title, iconImage=video_source_img, thumbnailImage=video_source_img ) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) video_source_id = video_source_id + 1 except: print "UNKNOWN streaming link found" else: videoLinks = re.compile("flashvars=(.+?)file=(.+?)&").findall(decodedSoup) moreLinks = re.compile('<iframe(.+?)src="(.+?)"', flags=re.I).findall(decodedSoup) if len(moreLinks) > 0: videoLinks.extend(moreLinks) moreLinks = re.compile('<a(.+?)href="(.+?)"', flags=re.I).findall(decodedSoup) if len(moreLinks) > 0: videoLinks.extend(moreLinks) if len(videoLinks) > 0: video_source_id = 1 video_source_img = None video_part_index = 0 video_playlist_items = [] for ignoreIt, videoLink in videoLinks: # @UnusedVariable try: if re.search("http://media.pinoymovie.ca/playlist/(.+?).xml", videoLink, re.I): soupXml = HttpClient().getBeautifulSoup(url=videoLink) for media in soupXml.findChildren("track"): video_url = media.findChild("location").getText() video_hosting_info = SnapVideo.findVideoHostingInfo(video_url) if video_hosting_info is None: print "UNKNOWN streaming link found: " + video_url else: video_part_index = video_part_index + 1 video_link = {} video_link["videoTitle"] = ( "Source #" + str(video_source_id) + " | " + "Part #" + str(video_part_index) ) video_link["videoLink"] = video_url video_link["videoSourceImg"] = video_hosting_info.get_video_hosting_image() video_playlist_items.append(video_link) video_source_img = video_link["videoSourceImg"] item = ListItem() item.add_request_data("videoLink", video_link["videoLink"]) item.add_request_data("videoTitle", video_link["videoTitle"]) item.set_next_action_name("SnapAndPlayVideo") xbmcListItem = xbmcgui.ListItem( label=video_link["videoTitle"], iconImage=video_source_img, thumbnailImage=video_source_img, ) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) if len(video_playlist_items) > 0: response_obj.addListItem( __preparePlayListItem__(video_source_id, video_source_img, video_playlist_items) ) video_source_id = video_source_id + 1 video_source_img = None video_part_index = 0 video_playlist_items = [] else: if re.search("http://media.pinoymovie.ca/playlist/(.+?).htm", videoLink, re.I): html = HttpClient().getHtmlContent(url=videoLink).replace("'", '"') videoLink = re.compile('<iframe(.+?)src="(.+?)"', flags=re.I).findall(html)[0][0] video_hosting_info = SnapVideo.findVideoHostingInfo(videoLink) print videoLink if video_hosting_info is None: print "UNKNOWN streaming link found: " + videoLink else: item = ListItem() item.add_request_data("videoLink", videoLink) item.add_request_data("videoTitle", "Source #" + str(video_source_id)) item.set_next_action_name("SnapAndPlayVideo") xbmcListItem = xbmcgui.ListItem( label="Source #" + str(video_source_id), iconImage=video_hosting_info.get_video_hosting_image(), thumbnailImage=video_hosting_info.get_video_hosting_image(), ) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) video_source_id = video_source_id + 1 except: print "UNKNOWN streaming link found" video_source_img = None video_part_index = 0 video_playlist_items = []
def retrieveVideoLinks(request_obj, response_obj): url = request_obj.get_data()['movieUrl'] contentDiv = BeautifulSoup.SoupStrainer('div', {'class':'video'}) soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv) if len(str(soup)) ==0: contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'content'}) soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv) decodedSoup = urllib.unquote(str(soup)) videoFrameLinks = re.compile('http://www.pinoymovie.c(o|a)/ajaxtabs/(.+?).htm').findall(decodedSoup) if len(videoFrameLinks) > 0: video_source_id = 1 for ignoreIt, videoFrameLink in videoFrameLinks: #@UnusedVariable try: soup = HttpClient().getBeautifulSoup(url='http://www.pinoymovie.co/ajaxtabs/' + videoFrameLink + '.htm') video_url = str(soup.find('iframe')['src']) video_hosting_info = SnapVideo.findVideoHostingInfo(video_url) if video_hosting_info is None: print 'UNKNOWN streaming link found: ' + video_url else: video_source_img = video_hosting_info.get_video_hosting_image() video_title = 'Source #' + str(video_source_id) + ' :: ' + video_hosting_info.get_video_hosting_name() item = ListItem() item.add_request_data('videoLink', video_url) item.add_request_data('videoTitle', video_title) item.set_next_action_name('SnapAndPlayVideo') xbmcListItem = xbmcgui.ListItem(label=video_title, iconImage=video_source_img, thumbnailImage=video_source_img) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) video_source_id = video_source_id + 1 except: print 'UNKNOWN streaming link found' else: videoLinks = re.compile('flashvars=(.+?)file=(.+?)&').findall(decodedSoup) moreLinks = re.compile('<iframe(.+?)src="(.+?)"', flags=re.I).findall(decodedSoup) if len(moreLinks) > 0: videoLinks.extend(moreLinks) moreLinks = re.compile('<a(.+?)href="(.+?)"', flags=re.I).findall(decodedSoup) if len(moreLinks) > 0: videoLinks.extend(moreLinks) if len(videoLinks) > 0: video_source_id = 1 video_source_img = None video_part_index = 0 video_playlist_items = [] for ignoreIt, videoLink in videoLinks: #@UnusedVariable try: if re.search('http://media.pinoymovie.ca/playlist/(.+?).xml', videoLink, re.I): soupXml = HttpClient().getBeautifulSoup(url=videoLink) for media in soupXml.findChildren('track'): video_url = media.findChild('location').getText() video_hosting_info = SnapVideo.findVideoHostingInfo(video_url) if video_hosting_info is None: print 'UNKNOWN streaming link found: ' + video_url else: video_part_index = video_part_index + 1 video_link = {} video_link['videoTitle'] = 'Source #' + str(video_source_id) + ' | ' + 'Part #' + str(video_part_index) video_link['videoLink'] = video_url video_link['videoSourceImg'] = video_hosting_info.get_video_hosting_image() video_playlist_items.append(video_link) video_source_img = video_link['videoSourceImg'] item = ListItem() item.add_request_data('videoLink', video_link['videoLink']) item.add_request_data('videoTitle', video_link['videoTitle']) item.set_next_action_name('SnapAndPlayVideo') xbmcListItem = xbmcgui.ListItem(label=video_link['videoTitle'], iconImage=video_source_img, thumbnailImage=video_source_img) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) if len(video_playlist_items) > 0: response_obj.addListItem(__preparePlayListItem__(video_source_id, video_source_img, video_playlist_items)) video_source_id = video_source_id + 1 video_source_img = None video_part_index = 0 video_playlist_items = [] else: print "insecond" if re.search('http://media.pinoymovie.ca/playlist/(.+?).htm', videoLink, re.I): html = HttpClient().getHtmlContent(url=videoLink).replace('\'', '"') videoLink = re.compile('<iframe(.+?)src="(.+?)"', flags=re.I).findall(html)[0][0] video_hosting_info = SnapVideo.findVideoHostingInfo(videoLink) if video_hosting_info is None: print 'UNKNOWN streaming link found: ' + videoLink else: item = ListItem() item.add_request_data('videoLink', videoLink) print "source:" + videoLink item.add_request_data('videoTitle', 'Source #' + str(video_source_id)) item.set_next_action_name('SnapAndPlayVideo') xbmcListItem = xbmcgui.ListItem(label='Source #' + str(video_source_id), iconImage=video_hosting_info.get_video_hosting_image(), thumbnailImage=video_hosting_info.get_video_hosting_image()) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) video_source_id = video_source_id + 1 except: print 'UNKNOWN streaming link found' video_source_img = None video_part_index = 0 video_playlist_items = []