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 displayChannels(request_obj, response_obj): content = BeautifulSoup.SoupStrainer('div', {'class':re.compile(r'\bchannels\b')}) soup = HttpClient().getBeautifulSoup(url='http://www.watchsuntv.com/play', parseOnlyThese=content) channels = soup.findAll('li', {'class':'channel-info'}) list_items = XBMCInterfaceUtils.callBackDialogProgressBar(getattr(sys.modules[__name__], '__displayChannels__'), channels, 'Preparing channel items', 'Failed to retrieve channel information, please try again later') response_obj.extendItemList(list_items) response_obj.set_xbmc_sort_method(xbmcplugin.SORT_METHOD_LABEL)
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 displayTVShowEpisodes(request_obj, response_obj): url = request_obj.get_data()['tvChannelUrl'] contentDiv = GetContent(url) newcontent = ''.join(contentDiv.encode("utf-8").splitlines()).replace('\t','') contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'content'}) soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv) videoBoxes =re.compile("<div id='videobox'>(.+?)</h3><div style='clear: both;'>").findall(newcontent) for videoBox in videoBoxes: #imgTag = videoBox.findChild('img') imageUrl = re.compile('<img [^>]*src=["\']?([^>^"^\']+)["\']?[^>]*>').findall(str(videoBox))[0] match=re.compile('createSummaryThumb\("(.+?)","(.+?)","(.+?)",').findall(str(videoBox)) if(len(match)>0): episodeName = match[0][1] episodeUrl = str(match[0][2]) 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'}) if(pageTag !=None): olderPageTag = pageTag.findChild('a', {'class':'blog-pager-older-link'}) else: olderPageTag = None 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 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 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 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 login(request_obj, response_obj): username = AddonContext().addon.getSetting('mnt_username') password = AddonContext().addon.getSetting('mnt_password') if username == '' or password == '': raise Exception(ExceptionHandler.USER_PWD_NOT_PROVIDED, 'User and password is not provided to access desitvstreams.com') millis = str(int(round(time.time()))) params = {'amember_login': username, 'amember_pass': password, 'login_attempt_id': millis} #Enable HTML cookies HttpClient().enableCookies() htmlContent = HttpClient().getHtmlContent(request_obj.get_data()['url'], params) if re.search('Username or password incorrect', htmlContent): raise Exception(ExceptionHandler.USER_PWD_INCORRECT, 'User and password provided is not authorized to access desitvstreams.com') htmlContent = ''.join(htmlContent.splitlines()).replace('\t', '').replace('\'', '"').replace(' ', '').replace(' ', '') request_obj.get_data()['htmlContent'] = htmlContent
def __addEmbeddedVideoInfo_in_item__(item): video_url = item.get_moving_data()['videoUrl'] if findVideoHostingInfo(video_url) == None: html = HttpClient().getHtmlContent(video_url) __processAndAddVideoInfo__(item, html) else: __processAndAddVideoInfo__(item, video_url)
def __retrieveTVShows__(tvShowsUrl): tvShows = [] if tvShowsUrl is None: return tvShows tvShowsUrl = BASE_WSITE_URL + tvShowsUrl contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'forumbits', 'class':'forumbits'}) soup = HttpClient().getBeautifulSoup(url=tvShowsUrl, parseOnlyThese=contentDiv) for tvShowTitleTag in soup.findAll('h2', {'class':'forumtitle'}): aTag = tvShowTitleTag.find('a') tvshowUrl = str(aTag['href']) if tvshowUrl[0:4] != "http": tvshowUrl = BASE_WSITE_URL + '/' + tvshowUrl tvshowName = aTag.getText() if not re.search('Past Shows', tvshowName, re.IGNORECASE): tvShows.append({"name":HttpUtils.unescape(tvshowName), "url":tvshowUrl}) return tvShows
def retrieveTVShowEpisodes(request_obj, response_obj): contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'content'}) url = request_obj.get_data()['tvShowUrl'] channelType = request_obj.get_data()['channelType'] if request_obj.get_data().has_key('page'): url = url + 'page/' + request_obj.get_data()['page'] soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv) for aTag in soup.findAll('a', {'rel':'bookmark'}): episodeName = aTag.getText() try: time.strptime(episodeName, '%B %d, %Y') continue except: if re.search('Written Episode', episodeName): pass else: item = ListItem() item.add_request_data('episodeName', episodeName) item.add_request_data('episodeUrl', str(aTag['href'])) item.set_next_action_name(channelType + '_Episode_VLinks') xbmcListItem = xbmcgui.ListItem(label=episodeName) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item) pagesDiv = soup.find('div', {'class':'wp-pagenavi'}) if pagesDiv is not None: pagesInfoTag = pagesDiv.find('span', {'class':'pages'}, recursive=False) if pagesInfoTag is not None: pageInfo = re.compile('Page (.+?) of (.+?) ').findall(pagesInfoTag.getText() + ' ') currentPage = int(pageInfo[0][0].replace(',','')) totalPages = int(pageInfo[0][1].replace(',','')) for page in range(1, totalPages + 1): if page == 1 or page == totalPages or page == currentPage - 1 or page == currentPage + 1: if page != currentPage: item = ListItem() item.add_request_data('channelType', channelType) item.add_request_data('tvShowName', request_obj.get_data()['tvShowName']) item.add_request_data('tvShowUrl', request_obj.get_data()['tvShowUrl']) if page != 1: item.add_request_data('page', str(page)) pageName = AddonUtils.getBoldString(' -> Page #' + str(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 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 retrievePakVideoLinks(request_obj, response_obj): video_source_id = 0 video_source_img = None video_part_index = 0 video_playlist_items = [] contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'restricted-content', 'class':'post-content'}) soup = HttpClient().getBeautifulSoup(url=request_obj.get_data()['episodeUrl'], parseOnlyThese=contentDiv) videoFrameTags = soup.findAll('iframe', {'class':re.compile('(youtube|dailymotion)-player')}) for frameTag in videoFrameTags: videoLink = str(frameTag['src']) source_img = None if re.search('youtube', videoLink): source_img = 'http://www.automotivefinancingsystems.com/images/icons/socialmedia_youtube_256x256.png' elif re.search('dailymotion', videoLink): source_img = 'http://aux.iconpedia.net/uploads/1687271053.png' if video_source_img is None or video_source_img != source_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 = source_img video_part_index = 0 video_playlist_items = [] 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'] = videoLink 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 retrieveTVShowEpisodes(request_obj, response_obj): Container().ga_client.reportContentUsage('dr_tvshow', request_obj.get_data()['tvShowName']) url = request_obj.get_data()['tvShowUrl'] if request_obj.get_data().has_key('page'): url = url + '&page=' + request_obj.get_data()['page'] contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'contentBody'}) soup = HttpClient().getBeautifulSoup(url=url, parseOnlyThese=contentDiv) if not request_obj.get_data().has_key('page'): threads = soup.find('ol', {'class':'stickies', 'id':'stickies'}) __retrieveTVShowEpisodes__(threads, response_obj) threads = soup.find('ol', {'class':'threads', 'id':'threads'}) __retrieveTVShowEpisodes__(threads, response_obj) pagesDiv = soup.find('div', {'class':'threadpagenav'}) if pagesDiv is not None: pagesInfoTag = pagesDiv.find('a', {'class':re.compile(r'\bpopupctrl\b')}) if pagesInfoTag is not None: pageInfo = re.compile('Page (.+?) of (.+?) ').findall(pagesInfoTag.getText() + ' ') currentPage = int(pageInfo[0][0]) totalPages = int(pageInfo[0][1]) for page in range(1, totalPages + 1): if page != currentPage: item = ListItem() item.add_request_data('tvShowName', request_obj.get_data()['tvShowName']) item.add_request_data('tvShowUrl', request_obj.get_data()['tvShowUrl']) if page != 1: item.add_request_data('page', str(page)) pageName = '' if page < currentPage: pageName = AddonUtils.getBoldString(' <- Page #' + str(page)) else: pageName = AddonUtils.getBoldString(' -> Page #' + str(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 __retrieveChannels__(tvChannels, dtUrl, channelType): contentDiv = BeautifulSoup.SoupStrainer('div', {'class':'copy fix'}) soup = HttpClient().getBeautifulSoup(url=dtUrl, parseOnlyThese=contentDiv) for tvChannelTag in soup.findAll('tbody'): try: tvChannel = {} running_tvshows = [] finished_tvshows = [] tmp_tvshows_list = None firstRow = False for trTag in tvChannelTag.findAll('tr', recursive=False): if not firstRow: channelImg = str(trTag.find('img')['src']) channelName = re.compile(BASE_WSITE_URL + '/category/(tv-serials|pakistan-tvs)/(.+?)/').findall(str(trTag.find('a')['href']))[0][1] channelName = string.upper(channelName.replace('-', ' ')) tvChannels[channelName] = tvChannel tvChannel['iconimage'] = channelImg tvChannel['channelType'] = channelType firstRow = True else: divTag = trTag.find('div') if divTag != None: txt = divTag.getText() if re.search('running', txt, flags=re.IGNORECASE): tmp_tvshows_list = running_tvshows tvChannel['running_tvshows'] = running_tvshows elif re.search('finished', txt, flags=re.IGNORECASE): tmp_tvshows_list = finished_tvshows tvChannel['finished_tvshows'] = finished_tvshows else: print 'UNKNOWN TV SHOW CATEGORY' else: for aTag in trTag.findAll('a'): tvshowUrl = str(aTag['href']) tvshowName = aTag.getText() tmp_tvshows_list.append({'name':HttpUtils.unescape(tvshowName), 'url':tvshowUrl}) except: print 'Failed to load a tv channel links.'
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 __retrieveRecentMovies__(movieLinkTag): movieLink = movieLinkTag['href'] contentDiv = BeautifulSoup.SoupStrainer('div', {'id':'content'}) soup = HttpClient().getBeautifulSoup(url=movieLink, parseOnlyThese=contentDiv) movieTag = soup.findChild('div', {'class':'post'}) return __retrieveAndCreateMovieItem__(movieTag)
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 = []
def __retrieveRecentMovies__(movieLinkTag): movieLink = movieLinkTag["href"] contentDiv = BeautifulSoup.SoupStrainer("div", {"id": "content"}) soup = HttpClient().getBeautifulSoup(url=movieLink, parseOnlyThese=contentDiv) movieTag = soup.findChild("div", {"class": "post"}) return __retrieveAndCreateMovieItem__(movieTag)
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))