def __prepareVideoLink__(video_link): video_url = video_link['videoLink'] new_video_url = None video_id = re.compile('(id|url|v)=(.+?)/').findall(video_url + '/')[0][1] if re.search('dm(\d*).php', video_url, flags=re.I): new_video_url = 'http://www.dailymotion.com/video/' + video_id + '_' elif re.search('(flash.php|fp.php|wire.php)', video_url, flags=re.I): new_video_url = 'http://cdn.playwire.com/12376/embed/' + video_id + '.xml' elif re.search('(youtube|u|yt)(\d*).php', video_url, flags=re.I): new_video_url = 'http://www.youtube.com/watch?v=' + video_id + '&' elif re.search('megavideo', video_url, flags=re.I): new_video_url = 'http://www.megavideo.com/v/' + video_id + '&' elif re.search('put.php', video_url, flags=re.I): new_video_url = 'http://www.putlocker.com/file/' + video_id elif re.search('(weed.php|vw.php)', video_url, flags=re.I): new_video_url = 'http://www.videoweed.es/file/' + video_id elif re.search('(sockshare.com|sock.com)', video_url, flags=re.I): new_video_url = video_url elif re.search('divxstage.php', video_url, flags=re.I): new_video_url = 'divxstage.eu/video/' + video_id + '&' elif re.search('(hostingbulk|hb).php', video_url, flags=re.I): new_video_url = 'hostingbulk.com/' + video_id + '&' elif re.search('movshare.php', video_url, flags=re.I): new_video_url = 'movshare.net/video/' + video_id + '&' elif re.search('nm.php', video_url, flags=re.I): new_video_url = 'novamov.com/video/' + video_id + '&' elif re.search('tune.php', video_url, flags=re.I): new_video_url = 'tune.pk/play/' + video_id + '&' video_hosting_info = SnapVideo.findVideoHostingInfo(new_video_url) video_link['videoLink'] = new_video_url video_link['videoSourceImg'] = video_hosting_info.get_video_hosting_image() video_link['videoSourceName'] = video_hosting_info.get_video_hosting_name()
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 loadVideos(url,name,request_obj, response_obj): #YOUTUBE try: if re.search('youtube', url, re.IGNORECASE): videoUrl=ParseYoutube(url) playVideo("play",videoUrl) return "skip" except: pass #Resolveurl try: PreProcessor.prepareVideoItem(request_obj, response_obj) SnapVideo.addPlaylistVideosInfo(request_obj, response_obj) SnapVideo.addVideoInfo(request_obj, response_obj) except: pass
def PlaymyvideoList(request_obj, response_obj): myplaylist = request_obj.get_data()['videoPlayListItems'] try: if len(myplaylist) > 0 and re.search('youtube', myplaylist[0]['videoLink'], re.IGNORECASE): playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() for videoitem in myplaylist: liz = xbmcgui.ListItem('[B]PLAY VIDEO[/B]', thumbnailImage="") videoUrl = ParseYoutube(videoitem['videoLink']) playlist.add(url=videoUrl, listitem=liz) xbmcPlayer = xbmc.Player() xbmcPlayer.play(playlist) return "skip" except: pass #Resolveurl try: PreProcessor.preparePlayListItems(request_obj, response_obj) SnapVideo.addPlaylistVideosInfo(request_obj, response_obj) SnapVideo.addVideoInfo(request_obj, response_obj) except: pass
def __prepareVideoLink__(video_link): video_url = video_link['videoLink'] new_video_url = None video_id = re.compile('(id|url)=(.+?)/').findall(video_url + '/')[0][1] if re.search('dm(\d*).php', video_url, flags=re.I): new_video_url = 'http://www.dailymotion.com/video/' + video_id + '_' elif re.search('flash.php', video_url, flags=re.I): new_video_url = 'http://www.zshare.net/video/' + video_id + '&' elif re.search('(youtube|u)(\d*).php', video_url, flags=re.I): new_video_url = 'http://www.youtube.com/watch?v=' + video_id + '&' elif re.search('megavideo', video_url, flags=re.I): new_video_url = 'http://www.megavideo.com/v/' + video_id + '&' video_hosting_info = SnapVideo.findVideoHostingInfo(new_video_url) video_link['videoLink'] = new_video_url video_link['videoSourceImg'] = video_hosting_info.get_video_hosting_image()
def __prepareVideoLink__(videoSourceLink): new_items = [] url = videoSourceLink if re.search('wp.me', url, re.I): url = HttpUtils.getRedirectedUrl(url) if not url.startswith('http://'): url = 'http://' + url Logger.logDebug(url) # contentDiv = BeautifulSoup.SoupStrainer('div', {'class':'left_articles'}) # soup = BeautifulSoup.BeautifulSoup(html, contentDiv) html = HttpUtils.HttpClient().getHtmlContent(url) dek = EnkDekoder.dekode(html) Logger.logDebug(dek) if dek is not None: html = dek html = html.replace('\n\r', '').replace('\r', '').replace('\n', '').replace('\\', '') children = [] if re.search('http://videos.stvflicks.com/', html): docId = re.compile('http://videos.stvflicks.com/(.+?).mp4"').findall(html)[0] children.append('src="http://videos.stvflicks.com/' + docId + '.mp4"') elif re.search('http://playcineflix.com/', html): docId = re.compile('http://playcineflix.com/(.+?).mp4"').findall(html)[0] children.append('src="http://playcineflix.com/' + docId + '.mp4"') elif re.search('https://video.google.com/get_player', html): docId = re.compile('docid=(.+?)"').findall(html)[0] children.append('src="https://docs.google.com/file/d/' + docId + '/preview"') elif re.search('http://videos.videopress.com/', html): docId = re.compile('type="video/mp4" href="http://videos.videopress.com/(.+?).mp4"').findall(html)[0] children.append('src="http://videos.videopress.com/' + docId + '.mp4"') else: children = re.compile('<embed(.+?)>').findall(html) if children is None or len(children) == 0: children = re.compile('<iframe(.+?)>').findall(html) Logger.logDebug(children) for child in children: video_url = re.compile('src="(.+?)"').findall(child)[0] if(re.search('http://ads', video_url, re.I) or re.search('http://ax-d', video_url, re.I)): continue if video_url.startswith('http://goo.gl/'): Logger.logDebug('Found google short URL = ' + video_url) video_url = HttpUtils.getRedirectedUrl(video_url) Logger.logDebug('After finding out redirected URL = ' + video_url) if re.search('videos.desionlinetheater.com', video_url): XBMCInterfaceUtils.displayDialogMessage('Unable to parse', 'A new HTML Guardian is used to protect the page', 'Sounds technical!! hmm, it means cannot find video.', 'Fix: Find me JavaScript Interpreter online service') video_hosting_info = SnapVideo.findVideoHostingInfo(video_url) if video_hosting_info is None: Logger.logDebug('Unrecognized video_url = ' + video_url) continue video_source_img = video_hosting_info.get_video_hosting_image() new_item = ListItem() new_item.add_request_data('videoTitle', 'Part #') new_item.add_request_data('videoLink', video_url) new_item.add_moving_data('videoSourceImg', video_source_img) new_item.add_moving_data('videoSourceName', video_hosting_info.get_video_hosting_name()) new_item.set_next_action_name('Play_Stream') xbmcListItem = xbmcgui.ListItem(label='Part #', iconImage=video_source_img, thumbnailImage=video_source_img) new_item.set_xbmc_list_item_obj(xbmcListItem) new_items.append(new_item) return new_items
def __prepareVideoLink__(videoSourceLink): new_items = [] url = videoSourceLink if re.search('wp.me', url, re.I): url = HttpUtils.getRedirectedUrl(url) if not url.startswith('http://'): url = 'http://' + url Logger.logDebug(url) # contentDiv = BeautifulSoup.SoupStrainer('div', {'class':'left_articles'}) # soup = BeautifulSoup.BeautifulSoup(html, contentDiv) if re.search('', videoSourceLink): video_hosting_info = SnapVideo.findVideoHostingInfo(videoSourceLink) if video_hosting_info is None: Logger.logDebug('Unrecognized video_url = ' + videoSourceLink) else: video_source_img = video_hosting_info.get_video_hosting_image() new_item = ListItem() new_item.add_request_data('videoTitle', 'Part #') new_item.add_request_data('videoLink', videoSourceLink) new_item.add_moving_data('videoSourceImg', video_source_img) new_item.add_moving_data( 'videoSourceName', video_hosting_info.get_video_hosting_name()) new_item.set_next_action_name('Play_Stream') xbmcListItem = xbmcgui.ListItem(label='Part #', iconImage=video_source_img, thumbnailImage=video_source_img) new_item.set_xbmc_list_item_obj(xbmcListItem) new_items.append(new_item) return new_items html = HttpUtils.HttpClient().getHtmlContent(url) dek = EnkDekoder.dekode(html) Logger.logDebug(dek) if dek is not None: html = dek html = html.replace('\n\r', '').replace('\r', '').replace('\n', '').replace('\\', '') children = [] if re.search('http://videos.stvflicks.com/', html): docId = re.compile('http://videos.stvflicks.com/(.+?).mp4"').findall( html)[0] children.append('src="http://videos.stvflicks.com/' + docId + '.mp4"') elif re.search('http://playcineflix.com/', html): docId = re.compile('http://playcineflix.com/(.+?).mp4"').findall( html)[0] children.append('src="http://playcineflix.com/' + docId + '.mp4"') elif re.search('https://video.google.com/get_player', html): docId = re.compile('docid=(.+?)"').findall(html)[0] children.append('src="https://docs.google.com/file/d/' + docId + '/preview"') elif re.search('http://videos.videopress.com/', html): docId = re.compile( 'type="video/mp4" href="http://videos.videopress.com/(.+?).mp4"' ).findall(html)[0] children.append('src="http://videos.videopress.com/' + docId + '.mp4"') elif re.search('http://videos.videopress.com/', html): docId = re.compile( 'type="video/mp4" href="http://videos.videopress.com/(.+?).mp4"' ).findall(html)[0] children.append('src="http://videos.videopress.com/' + docId + '.mp4"') elif re.search('video_alt_url=http://www.mediaplaybox.com', html): docId = re.compile('video_alt_url=http://www.mediaplaybox.com(.+?).mp4' ).findall(html)[0] children.append('src="http://www.mediaplaybox.com:81/' + docId + '.mp4"') elif re.search('video_url=http://www.mediaplaybox.com', html): docId = re.compile( 'video_url=http://www.mediaplaybox.com(.+?).mp4').findall(html)[0] children.append('src="http://www.mediaplaybox.com:81/' + docId + '.mp4"') else: children = re.compile('<embed(.+?)>').findall(html) if children is None or len(children) == 0: children = re.compile('<iframe(.+?)>').findall(html) Logger.logDebug(children) for child in children: video_url = re.compile('src="(.+?)"').findall(child)[0] if (re.search('http://ads', video_url, re.I) or re.search('http://ax-d', video_url, re.I)): continue if video_url.startswith('http://goo.gl/'): Logger.logDebug('Found google short URL = ' + video_url) video_url = HttpUtils.getRedirectedUrl(video_url) Logger.logDebug('After finding out redirected URL = ' + video_url) if re.search('videos.desionlinetheater.com', video_url): XBMCInterfaceUtils.displayDialogMessage( 'Unable to parse', 'A new HTML Guardian is used to protect the page', 'Sounds technical!! hmm, it means cannot find video.', 'Fix: Find me JavaScript Interpreter online service') video_hosting_info = SnapVideo.findVideoHostingInfo(video_url) if video_hosting_info is None: Logger.logDebug('Unrecognized video_url = ' + video_url) continue video_source_img = video_hosting_info.get_video_hosting_image() new_item = ListItem() new_item.add_request_data('videoTitle', 'Part #') new_item.add_request_data('videoLink', video_url) new_item.add_moving_data('videoSourceImg', video_source_img) new_item.add_moving_data('videoSourceName', video_hosting_info.get_video_hosting_name()) new_item.set_next_action_name('Play_Stream') xbmcListItem = xbmcgui.ListItem(label='Part #', iconImage=video_source_img, thumbnailImage=video_source_img) new_item.set_xbmc_list_item_obj(xbmcListItem) new_items.append(new_item) return new_items
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 playHostedVideo(request_obj, response_obj): pbType = int(Container().getAddonContext().addon.getSetting('playbacktype')) Container().getAddonContext().addon.setSetting('ga_video_title', 'false') if pbType == 2 and XBMCInterfaceUtils.isPlaying(): response_obj.addServiceResponseParam("status", "error") response_obj.addServiceResponseParam("title", "XBMC is already playing.") response_obj.addServiceResponseParam("message", "Check PlayIt Service add-on settings. Your this request is ignored.") item = ListItem() item.set_next_action_name('respond') response_obj.addListItem(item) else: if pbType == 0: XBMCInterfaceUtils.stopPlayer() video_url = request_obj.get_data()['videoLink'] if video_url.startswith('http://goo.gl/'): Logger.logDebug('Found google short URL = ' + video_url) video_url = HttpUtils.getRedirectedUrl(video_url) Logger.logDebug('After finding out redirected URL = ' + video_url) request_obj.get_data()['videoLink'] = video_url if __is_valid_url(video_url): contentType = __check_media_url(video_url) if contentType is not None: if contentType == 'audio': response_obj.set_redirect_action_name('play_direct_audio') request_obj.get_data()['track_title'] = '' request_obj.get_data()['track_link'] = video_url request_obj.get_data()['track_artwork_url'] = '' else: response_obj.set_redirect_action_name('play_direct_video') else: if XBMCInterfaceUtils.isPlayingAudio(): response_obj.addServiceResponseParam("status", "error") response_obj.addServiceResponseParam("title", "Stop active music!") response_obj.addServiceResponseParam("message", "Note: XBMC cannot play video when audio playback is in progress.") item = ListItem() item.set_next_action_name('respond') response_obj.addListItem(item) else: video_hosting_info = SnapVideo.findVideoHostingInfo(video_url) if video_hosting_info is None: response_obj.addServiceResponseParam("status", "error") response_obj.addServiceResponseParam("title", "URL not supported") response_obj.addServiceResponseParam("message", "Video URL is currently not supported by PlayIt. Please check if URL selected is correct.") item = ListItem() item.set_next_action_name('respond') response_obj.addListItem(item) else: Container().ga_client.reportContentUsage('hostedvideo', video_hosting_info.get_video_hosting_name()) response_obj.addServiceResponseParam("status", "success") if not XBMCInterfaceUtils.isPlaying(): XBMCInterfaceUtils.clearPlayList(list_type="video") response_obj.addServiceResponseParam("message", "Enjoy your video!") else: response_obj.addServiceResponseParam("title", "Request Enqueued!") response_obj.addServiceResponseParam("message", "Your request has been added to player queue.") response_obj.set_redirect_action_name('play_it') request_obj.get_data()['videoTitle'] = 'PlayIt Video' else: Logger.logError('video_url = ' + str(video_url)) response_obj.addServiceResponseParam("status", "error") response_obj.addServiceResponseParam("title", "Invalid URL") response_obj.addServiceResponseParam("message", "Video URL is not valid one! Please check and try again.") item = ListItem() item.set_next_action_name('respond') response_obj.addListItem(item)
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 = []