def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_info_link = 'http://www.videozer.com/player_control/settings.php?v=' + video_id + '&fv=v1.1.45' jsonObj = json.load(urllib.urlopen(video_info_link)) key1 = jsonObj["cfg"]["environment"]["rkts"] key2 = jsonObj["cfg"]["login"]["pepper"] key3 = jsonObj["cfg"]["ads"]["lightbox2"]["time"] values = binascii.unhexlify(decrypt(jsonObj["cfg"]["login"]["spen"], jsonObj["cfg"]["login"]["salt"], 950569)).split(';') spn = HttpUtils.getUrlParams(values[0]) outk = HttpUtils.getUrlParams(values[1]) ikey = getikey(int(outk["ik"])) urlKey = '' for spnkey in spn: spnval = spn[spnkey] if spnval == '1': cypher = jsonObj["cfg"]["info"]["sece2"] urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey, ln=256) + '&' if spnval == '2': cypher = jsonObj["cfg"]["ads"]["g_ads"]["url"] urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey) + '&' if spnval == '3': cypher = jsonObj["cfg"]["ads"]["g_ads"]["type"] urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey, 26, 25431, 56989, 93, 32589, 784152) + '&' if spnval == '4': cypher = jsonObj["cfg"]["ads"]["g_ads"]["time"] urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey, 82, 84669, 48779, 32, 65598, 115498) + '&' if spnval == '5': cypher = jsonObj["cfg"]["login"]["euno"] urlKey = urlKey + spnkey + '=' + decrypt(cypher, key2, ikey, 10, 12254, 95369, 39, 21544, 545555) + '&' if spnval == '6': cypher = jsonObj["cfg"]["login"]["sugar"] urlKey = urlKey + spnkey + '=' + decrypt(cypher, key3, ikey, 22, 66595, 17447, 52, 66852, 400595) + '&' urlKey = urlKey + "start=0" video_link = "" for videoStrm in jsonObj["cfg"]["quality"]: if videoStrm["d"]: video_link = str(base64.b64decode(videoStrm["u"])) if video_link == "": video_info.set_video_stopped(False) raise Exception("VIDEO_STOPPED") video_link = video_link + '&' + urlKey video_info.set_video_name(jsonObj["cfg"]["info"]["video"]["title"]) video_info.set_video_image(jsonObj["cfg"]["environment"]["thumbnail"]) video_info.set_video_stopped(False) video_info.add_video_link(VIDEO_QUAL_SD, video_link) except: video_info.set_video_stopped(True) return video_info
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: HttpUtils.HttpClient().enableCookies() html = HttpUtils.HttpClient().getHtmlContent(url='http://www.vplay.ro/watch/' + str(video_id)) html = HttpUtils.HttpClient().getHtmlContent(url='http://www.vplay.ro/play/dinosaur.do', params={'key':str(video_id)}) params = HttpUtils.getUrlParams(html) video_link = HttpUtils.getRedirectedUrl(url=params['nqURL']) HttpUtils.HttpClient().disableCookies() video_info.set_video_stopped(False) video_info.add_video_link(VIDEO_QUAL_SD, video_link) video_info.set_video_image(params['th']) except: video_info.set_video_stopped(True) return video_info
def __initialize__(self, params=None): print params self.set_action_id('__start__') if params is None: self.set_params({}) elif type(params) is str: self.set_params(HttpUtils.getUrlParams(params)) elif type(params) is dict: self.set_params(params) if self.get_params().has_key('actionId') and self.get_params()['actionId'] != '': self.set_action_id(self.get_params()['actionId']) if self.get_params().has_key('data') and self.get_params()['data'] != '': self.set_data(AddonUtils.decodeData(self.get_params()['data']))
def __init__(self, params=None): Logger.logDebug(params) self.set_action_id('__start__') if params is None: self.set_params({}) elif type(params) is str: self.set_params(HttpUtils.getUrlParams(params)) elif type(params) is dict: self.set_params(params) if self.get_params().has_key( 'actionId') and self.get_params()['actionId'] != '': self.set_action_id(self.get_params()['actionId']) if self.get_params().has_key( 'data') and self.get_params()['data'] != '': self.set_data(AddonUtils.decodeData(self.get_params()['data']))
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 retrieveAudioInfo(audioUrl): url = 'https://api.soundcloud.com/' + audioUrl jObj = json.loads(HttpUtils.HttpClient().getHtmlContent(url=url)) video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(url) video_info.add_video_link(VIDEO_QUAL_SD, jObj['http_mp3_128_url'], addUserAgent=False, addReferer=False) video_info.set_video_image('') video_info.set_video_name('') Logger.logDebug(jObj['http_mp3_128_url']) video_info.set_video_stopped(False) return video_info
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_info_link = 'http://www.zalaa.com/' + str(video_id) html = HttpUtils.HttpClient().getHtmlContent(url=video_info_link) link = ''.join(html.splitlines()).replace('\'', '"') video_link = re.compile('s1.addVariable\("file","(.+?)"\);').findall( link)[0] video_info.add_video_link(VIDEO_QUAL_SD, video_link) video_info.set_video_stopped(False) except: video_info.set_video_stopped(True) return video_info
def __retrieveChannels__(tvChannels, dtUrl, channelType): contentDiv = BeautifulSoup.SoupStrainer('div', {'class':re.compile(r'\bhentry\b')}) soup = HttpClient().getBeautifulSoup(url=dtUrl, parseOnlyThese=contentDiv) for tvChannelTag in soup.div.findAll('div', recursive=False): try: tvChannel = {} running_tvshows = [] finished_tvshows = [] tmp_tvshows_list = None firstRow = False for tag in tvChannelTag.findAll(re.compile('div|a'), recursive=False): if tag.name == 'div' and tag.get('class') == 'nav_up': continue if not firstRow: channelImg = '' if(tag.find('img').has_key('src')): channelImg = str(tag.find('img')['src']) else: channelImg = str(tag.find('img')['file']) channelName = re.compile(BASE_WSITE_URL + '/category/(tv-serials|pakistan-tvs)/(.+?)/').findall(str(tag.find('a')['href']))[0][1] channelName = string.upper(channelName.replace('-', ' ')) Logger.logDebug(channelName) tvChannels[channelName] = tvChannel tvChannel['iconimage'] = channelImg tvChannel['channelType'] = channelType firstRow = True else: if tag.name == 'div' and tag.get('class') == 'dtLink': txt = tag.getText() Logger.logDebug(txt) 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: Logger.logWarning('UNKNOWN TV SHOW CATEGORY') elif tag.name == 'a': tvshowUrl = str(tag['href']) tvshowName = tag.getText().encode('utf-8') Logger.logDebug(tvshowName) tmp_tvshows_list.append({'name':HttpUtils.unescape(tvshowName), 'url':tvshowUrl}) except Exception, e: Logger.logFatal(e) Logger.logDebug(tvChannelTag)
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_info_link = 'http://videobam.com/' + str(video_id) html = HttpUtils.HttpClient().getHtmlContent(url=video_info_link) streams = re.compile('(low|high): \'(.+?)\'').findall(html) for streamType, streamUrl in streams: if streamType == 'low': video_info.add_video_link(VIDEO_QUAL_SD, streamUrl) elif streamType == 'high': video_info.add_video_link(VIDEO_QUAL_HD_720, streamUrl) video_info.set_video_stopped(False) except: video_info.set_video_stopped(True) return video_info
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_info_link = 'http://embed.tune.pk/play/' + str( video_id) + '?autoplay=no' html = HttpUtils.HttpClient().getHtmlContent(url=video_info_link) image = re.compile("preview_img = '(.+?)';").findall(html) if image is not None and len(image) == 1: video_info.set_video_image(str(image[0])) html = html.replace('\n\r', '').replace('\r', '').replace('\n', '') sources = re.compile("{(.+?)}").findall( re.compile("sources:(.+?)]").findall(html)[0]) for source in sources: video_link = str(re.compile('file[: ]*"(.+?)"').findall(source)[0]) Logger.logDebug(video_link) label_text = re.compile('label[: ]*"(.+?)"').findall(source) if label_text is not None and len(label_text) == 1: label = str(label_text[0]) Logger.logDebug(label) if label == '240p': video_info.add_video_link(VIDEO_QUAL_LOW, video_link) elif label == '360p' and video_info.get_video_link( VIDEO_QUAL_SD) is None: video_info.add_video_link(VIDEO_QUAL_SD, video_link) elif label == '480p' or label == 'SD': video_info.add_video_link(VIDEO_QUAL_SD, video_link) elif label == '720p' or label == 'HD': video_info.add_video_link(VIDEO_QUAL_HD_720, video_link) elif label == '1080p': video_info.add_video_link(VIDEO_QUAL_HD_1080, video_link) else: video_info.add_video_link(VIDEO_QUAL_SD, video_link) else: video_info.add_video_link(VIDEO_QUAL_SD, video_link) video_info.set_video_stopped(False) except Exception, e: Logger.logError(e) video_info.set_video_stopped(True)
def __retrieveTVShowEpisodes__(threads, response_obj): if threads is None: return for aTag in threads.findAll('a', {'class':re.compile(r'\btitle\b')}): episodeName = aTag.getText() if not re.search(r'\b(Watch|Episode|Video|Promo)\b', episodeName, re.IGNORECASE): pass else: item = ListItem() item.add_request_data('episodeName', HttpUtils.unescape(episodeName)) episodeUrl = str(aTag['href']) if not episodeUrl.lower().startswith(BASE_WSITE_URL): if episodeUrl[0] != '/': episodeUrl = '/' + episodeUrl episodeUrl = BASE_WSITE_URL + episodeUrl item.add_request_data('episodeUrl', episodeUrl) item.set_next_action_name('Episode_VLinks') xbmcListItem = xbmcgui.ListItem(label=episodeName) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item)
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_info_link = 'http://stagevu.com/video/' + str(video_id) html = HttpUtils.HttpClient().getHtmlContent(url=video_info_link) html = ''.join(html.splitlines()).replace('\t', '').replace('\'', '"') match = re.compile( '<param name="src" value="(.+?)"(.+?)<param name="movieTitle" value="(.+?)"(.+?)<param name="previewImage" value="(.+?)"' ).findall(html) video_info.add_video_link(VIDEO_QUAL_SD, match[0][0]) video_info.set_video_name(match[0][2]) video_info.set_video_image(match[0][4]) video_info.set_video_stopped(False) except: video_info.set_video_stopped(True) return video_info
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_link = 'http://cdn.playwire.com/' + str(video_id) + '.xml' soup = BeautifulStoneSoup(HttpUtils.HttpClient().getHtmlContent(url=video_link), convertEntities=BeautifulStoneSoup.XML_ENTITIES) cfg = soup.find("config") img_link = cfg.findNext("poster").string video_link = cfg.findNext("src").string video_info.set_video_stopped(False) video_info.set_video_image(img_link) video_info.set_video_name("PLAYWIRE Video") if re.search(r'\Artmp',video_link): video_info.add_video_link(VIDEO_QUAL_HD_720, video_link, addUserAgent=False) else: video_info.add_video_link(VIDEO_QUAL_HD_720, video_link, addUserAgent=True) except: video_info.set_video_stopped(True) return video_info
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_info_link = 'http://www.veoh.com/rest/v2/execute.xml?method=veoh.video.findByPermalink&permalink=' + str(video_id) + '&apiKey=' + API_KEY soup = BeautifulStoneSoup(HttpUtils.HttpClient().getHtmlContent(url=video_info_link), convertEntities=BeautifulStoneSoup.XML_ENTITIES) videoObj = soup.findChild(name='video') video_link = HttpUtils.getRedirectedUrl(str(videoObj['ipodurl'])) img_link = str(videoObj['highresimage']) video_title = str(videoObj['title']) video_info.set_video_stopped(False) video_info.set_video_image(img_link) video_info.set_video_name(video_title) video_info.add_video_link(VIDEO_QUAL_SD, video_link) except: video_info.set_video_stopped(True) return video_info
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_info_link = 'http://veevr.com/embed/' + str(video_id) soup = HttpUtils.HttpClient().getBeautifulSoup(url=video_info_link) thumbTag = soup.findChild('img', attrs={'id':'vid-thumb'}) imageUrl = thumbTag['src'] videoTitle = thumbTag['alt'] vidTag = soup.findChild('img', attrs={'id':'smil-load'}) videoUrl = vidTag['src'] video_info.add_video_link(VIDEO_QUAL_SD, videoUrl) video_info.set_video_name(videoTitle) video_info.set_video_image(imageUrl) video_info.set_video_stopped(False) except: video_info.set_video_stopped(True) return video_info
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_info_link = 'http://www.vimeo.com/moogaloop/load/clip:' + str( video_id) soup = BeautifulStoneSoup( HttpUtils.HttpClient().getHtmlContent(url=video_info_link), convertEntities=BeautifulStoneSoup.XML_ENTITIES) referrerObj = soup.findChild(name='referrer') req_sig = referrerObj.findChild(name='request_signature').getText() req_sig_exp = referrerObj.findChild( name='request_signature_expires').getText() videoObj = soup.findChild(name='video') img_link = videoObj.findChild(name='thumbnail').getText() video_title = videoObj.findChild(name='caption').getText() qual = 'sd' video_link = "http://player.vimeo.com/play_redirect?clip_id=%s&sig=%s&time=%s&quality=%s&codecs=H264,VP8,VP6&type=moogaloop_local&embed_location=" % ( video_id, req_sig, req_sig_exp, qual) video_info.add_video_link(VIDEO_QUAL_SD, video_link) if (videoObj.findChild(name='ishd').getText() == '1'): qual = 'hd' video_link = "http://player.vimeo.com/play_redirect?clip_id=%s&sig=%s&time=%s&quality=%s&codecs=H264,VP8,VP6&type=moogaloop_local&embed_location=" % ( video_id, req_sig, req_sig_exp, qual) video_info.add_video_link(VIDEO_QUAL_HD_720, video_link) video_info.set_video_stopped(False) video_info.set_video_image(img_link) video_info.set_video_name(video_title) except: video_info.set_video_stopped(True) return video_info
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 returnVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_link_info = 'http://www.mediaplaybox' + video_id video_link_info = video_link_info.replace('/:81/', '/').replace( 'mediaplaybox:81', 'mediaplaybox.com') + '.mp4' video_link = video_link_info.replace('_ipod.mp4', '.flv') hd_video_link = video_link.replace('_ipod.mp4', '_hd.mp4') video_info.set_video_stopped(False) video_info.set_video_name("Media PlayBox Video") try: response = HttpUtils.HttpClient().getResponse(url=hd_video_link) if response.status < 400: video_info.add_video_link(VIDEO_QUAL_HD_720, hd_video_link, addUserAgent=False) except Exception, e: print 'No HD link' video_info.add_video_link(VIDEO_QUAL_SD, video_link, addUserAgent=False)
def __retrieveTVShowEpisodes__(threads, response_obj): if threads is None: return aTags = threads.findAll('a', {'class':re.compile(r'\btitle\b')}) videoEpisodes = [] for aTag in aTags: episodeName = aTag.getText() if not re.search(r'\b(Watch|Episode|Video|Promo)\b', episodeName, re.IGNORECASE): pass else: videoEpisodes.append(aTag) if len(videoEpisodes) == 0: videoEpisodes = aTags for aTag in videoEpisodes: episodeName = aTag.getText() item = ListItem() titleInfo = HttpUtils.unescape(episodeName) movieInfo = re.compile("(.+?)\((\d+)\)").findall(titleInfo) if(len(movieInfo) >= 1 and len(movieInfo[0]) >= 2): title = unicode(movieInfo[0][0].rstrip()).encode('utf-8') year = unicode(movieInfo[0][1]).encode('utf-8') item.add_moving_data('movieTitle', title) item.add_moving_data('movieYear', year) item.add_request_data('episodeName', titleInfo) episodeUrl = str(aTag['href']) if not episodeUrl.lower().startswith(BASE_WSITE_URL): if episodeUrl[0] != '/': episodeUrl = '/' + episodeUrl episodeUrl = BASE_WSITE_URL + episodeUrl item.add_request_data('episodeUrl', episodeUrl) item.set_next_action_name('Episode_VLinks') xbmcListItem = xbmcgui.ListItem(label=episodeName) item.set_xbmc_list_item_obj(xbmcListItem) response_obj.addListItem(item)
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_info_link = 'http://www.facebook.com/video/video.php?v=' + str( video_id) html = urllib.unquote_plus(HttpUtils.HttpClient().getHtmlContent( url=video_info_link).replace('\u0025', '%')) video_title = re.compile( 'addVariable\("video_title"\, "(.+?)"').findall(html)[0] img_link = re.compile('addVariable\("thumb_url"\, "(.+?)"').findall( html)[0] high_video_link = re.compile( 'addVariable\("highqual_src"\, "(.+?)"').findall(html) low_video_link = re.compile( 'addVariable\("lowqual_src"\, "(.+?)"').findall(html) video_link = re.compile('addVariable\("video_src"\, "(.+?)"').findall( html) if len(high_video_link) > 0: video_info.add_video_link(VIDEO_QUAL_HD_720, high_video_link[0]) if len(low_video_link) > 0: video_info.add_video_link(VIDEO_QUAL_SD, low_video_link[0]) if len(video_link) > 0: video_info.add_video_link(VIDEO_QUAL_SD, video_link[0]) video_info.set_video_stopped(False) video_info.set_video_name(video_title) video_info.set_video_image(img_link) except: raise video_info.set_video_stopped(True) return video_info
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: HttpUtils.HttpClient().enableCookies() html = HttpUtils.HttpClient().getHtmlContent( url='http://www.vplay.ro/watch/' + str(video_id)) html = HttpUtils.HttpClient().getHtmlContent( url='http://www.vplay.ro/play/dinosaur.do', params={'key': str(video_id)}) params = HttpUtils.getUrlParams(html) video_link = HttpUtils.getRedirectedUrl(url=params['nqURL']) HttpUtils.HttpClient().disableCookies() video_info.set_video_stopped(False) video_info.add_video_link(VIDEO_QUAL_SD, video_link) video_info.set_video_image(params['th']) except: video_info.set_video_stopped(True) return video_info
def retieveMovieStreams(request_obj, response_obj): if (request_obj.get_data().has_key('videoInfo')): title = request_obj.get_data()['videoInfo']['title'] Container().ga_client.reportContentUsage('movie', title) soup = None if request_obj.get_data().has_key('movieInfo'): soup = BeautifulSoup.BeautifulSoup(request_obj.get_data()['movieInfo']) elif request_obj.get_data().has_key('moviePageUrl'): soup = HttpUtils.HttpClient().getBeautifulSoup( url=request_obj.get_data()['moviePageUrl']) if soup is None: return videoSources = [] videoSourceLinks = None tags = soup.findAll('p') if len(tags) < 5: tags.extend(soup.findAll('span')) Logger.logDebug(soup.prettify()) Logger.logDebug( ' ------------------------------------------------------- ') for tag in tags: Logger.logDebug(tag) if re.search('^(Source|ONLINE|Server)', tag.getText(), re.IGNORECASE): if videoSourceLinks is not None and len(videoSourceLinks) > 0: videoSources.append(videoSourceLinks) videoSourceLinks = [] else: aTags = tag.findAll( 'a', attrs={ 'href': re.compile( '(desiflicks.com|desionlinetheater.com|wp.me|cine.sominaltvfilms.com|media.thesominaltv.com|mediaplaybox.com)' ) }, recursive=True) if aTags is None or len(aTags) != 1: continue aTag = aTags[0] if aTag is not None: infoLink = str(aTag['href']).replace('http://adf.ly/377117/', '') if videoSourceLinks == None: videoSourceLinks = [] if infoLink not in videoSourceLinks: videoSourceLinks.append(infoLink) if videoSourceLinks is not None and len(videoSourceLinks) > 0: videoSources.append(videoSourceLinks) new_items = [] sourceCount = 0 for videoSource in videoSources: sourceCount = sourceCount + 1 new_items.extend( __prepareVideoSourceLinks__(videoSource, str(sourceCount))) if (request_obj.get_data().has_key('videoInfo')): __addVideoInfo__(new_items, request_obj.get_data()['videoInfo']) response_obj.set_item_list(new_items) playNowItem = __findPlayNowStream__(response_obj.get_item_list()) if playNowItem is not None: request_obj.set_data({ 'videoPlayListItems': playNowItem.get_request_data()['videoPlayListItems'] })
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 retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_info.set_video_image('http://i.ytimg.com/vi/' + video_id + '/default.jpg') html = HttpUtils.HttpClient().getHtmlContent( url='http://www.youtube.com/get_video_info?video_id=' + video_id + '&asv=3&el=detailpage&hl=en_US') stream_map = None html = html.decode('utf8') html = html.replace('\n', '') html = html.replace('\r', '') html = html + '&' title = urllib.unquote_plus( re.compile('&title=(.+?)&').findall(html)[0]).replace( '/\+/g', ' ') print title if re.search('status=fail', html): video_info.set_video_stopped(True) return video_info stream_info = re.compile('url_encoded_fmt_stream_map=(.+?)&').findall( html) stream_map = '' if (len(stream_info) == 0): stream_map = re.compile('fmt_stream_map": "(.+?)"').findall( html)[0].replace("\\/", "/") else: stream_map = stream_info[0] if stream_map == None: video_info.set_video_stopped(True) return video_info stream_map = urllib.unquote_plus(stream_map) formatArray = stream_map.split(',') for formatContent in formatArray: if formatContent == '': continue formatUrl = "" try: formatUrl = urllib.unquote( re.compile("url=([^&]+)").findall(formatContent) [0]) + "&title=" + urllib.quote_plus(title) except: print "Unexpected error" if re.search("rtmpe", stream_map): try: conn = urllib.unquote( re.compile("conn=([^&]+)").findall(formatContent)[0]) host = re.compile("rtmpe:\/\/([^\/]+)").findall(conn)[0] stream = re.compile("stream=([^&]+)").findall( formatContent)[0] path = 'videoplayback' formatUrl = "-r %22rtmpe:\/\/" + host + "\/" + path + "%22 -V -a %22" + path + "%22 -f %22WIN 11,3,300,268%22 -W %22http:\/\/s.ytimg.com\/yt\/swfbin\/watch_as3-vfl7aCF1A.swf%22 -p %22http:\/\/www.youtube.com\/watch?v=" + video_id + "%22 -y %22" + urllib.unquote( stream) + "%22" except: print "Unexpected error" if (formatUrl[0:4] == "http" or formatUrl[0:2] == "-r"): formatQual = re.compile("itag=([^&]+)").findall( formatContent)[0] if not re.search("signature=", formatUrl): formatUrl += "&signature=" + re.compile( "sig=([^&]+)").findall(formatContent)[0] qual = formatQual url = formatUrl if (qual == '13'): # 176x144 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '17'): # 176x144 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '36'): # 320x240 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '5'): # 400\\327226 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '34'): # 480x360 FLV video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '6'): # 640\\327360 FLV video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '35'): # 854\\327480 HD video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '18'): # 480x360 MP4 video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '22'): # 1280x720 MP4 video_info.add_video_link(VIDEO_QUAL_HD_720, url) elif (qual == '37'): # 1920x1080 MP4 video_info.add_video_link(VIDEO_QUAL_HD_1080, url) elif (qual == '38' and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None): # 4096\\3272304 EPIC MP4 video_info.add_video_link(VIDEO_QUAL_HD_1080, url) elif (qual == '43' and video_info.get_video_link(VIDEO_QUAL_SD) is None): # 360 WEBM video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '44'): # 480 WEBM video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '45' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None): # 720 WEBM video_info.add_video_link(VIDEO_QUAL_HD_720, url) elif (qual == '46' and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None): # 1080 WEBM video_info.add_video_link(VIDEO_QUAL_HD_1080, url) elif (qual == '120' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None): # New video qual video_info.add_video_link(VIDEO_QUAL_HD_720, url) # 3D streams - MP4 # 240p -> 83 # 360p -> 82 # 520p -> 85 # 720p -> 84 # 3D streams - WebM # 360p -> 100 # 360p -> 101 # 720p -> 102 else: # unknown quality video_info.add_video_link(VIDEO_QUAL_SD, url) video_info.set_video_stopped(False) except Exception, e: logging.exception(e) video_info.set_video_stopped(True)
def add_video_link(self, video_qual, video_link, addUserAgent=True): if addUserAgent: video_link = video_link.replace(' ', '%20') + '|' + HttpUtils.getUserAgentForXBMCPlay() self.__video_links[video_qual] = video_link
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 __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 retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: video_info.set_video_image('http://i.ytimg.com/vi/' + video_id + '/default.jpg') html = HttpUtils.HttpClient().getHtmlContent( url='http://www.youtube.com/watch?v=' + video_id + '&fmt=18') stream_map = None html = html.replace('\\u0026', '&') match = re.compile('url_encoded_fmt_stream_map=(.+?)&').findall(html) if len(match) == 0: stream_map = (re.compile('url_encoded_fmt_stream_map": "(.+?)"'). findall(html)[0]).replace('\\/', '/').split('url=') else: stream_map = urllib.unquote(match[0]).decode('utf8').split('url=') if re.search('status=fail', html): video_info.set_video_stopped(True) return video_info if stream_map == None: video_info.set_video_stopped(True) return video_info for attr in stream_map: if attr == '': continue parts = urllib.unquote(attr).decode('utf8').split('&qual') url = parts[0] qual = re.compile('&itag=(\d*)').findall(parts[1])[0] if (qual == '13'): #176x144 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '17'): #176x144 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '36'): #320x240 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '5'): #400\\327226 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '34'): #480x360 FLV video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '6'): #640\\327360 FLV video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '35'): #854\\327480 HD video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '18'): #480x360 MP4 video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '22' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None): #1280x720 MP4 video_info.add_video_link(VIDEO_QUAL_HD_720, url) elif (qual == '37' and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None): #1920x1080 MP4 video_info.add_video_link(VIDEO_QUAL_HD_1080, url) elif (qual == '38'): #4096\\3272304 EPIC MP4 video_info.add_video_link(VIDEO_QUAL_HD_1080, url) elif (qual == '43' and video_info.get_video_link(VIDEO_QUAL_SD) is None): #4096\\3272304 WEBM video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '44' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None): #4096\\3272304 WEBM video_info.add_video_link(VIDEO_QUAL_HD_720, url) elif (qual == '45' and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None): #4096\\3272304 WEBM video_info.add_video_link(VIDEO_QUAL_HD_1080, url) elif (qual == '120' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None): #New video qual video_info.add_video_link(VIDEO_QUAL_HD_720, url) else: #unknown quality video_info.add_video_link(VIDEO_QUAL_SD, url) video_info.set_video_stopped(False) except: video_info.set_video_stopped(True) return video_info
def add_video_link(self, video_qual, video_link, addUserAgent=True, addReferer=False, refererUrl=None): if addUserAgent: video_link = video_link.replace(' ', '%20') + '|' + HttpUtils.getUserAgentForXBMCPlay() if addReferer and refererUrl is not None: video_link = video_link + '&Referer=' + refererUrl self.__video_links[video_qual] = video_link
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: HttpUtils.HttpClient().enableCookies() video_info.set_video_image('http://i.ytimg.com/vi/' + video_id + '/default.jpg') html = HttpUtils.HttpClient().getHtmlContent(url='http://www.youtube.com/get_video_info?video_id=' + video_id + '&asv=3&el=detailpage&hl=en_US') stream_map = None html = html.decode('utf8') html = html.replace('\n', '') html = html.replace('\r', '') html = unicode(html + '&').encode('utf-8') if re.search('status=fail', html): # XBMCInterfaceUtils.displayDialogMessage('Video info retrieval failed', 'Reason: ' + ((re.compile('reason\=(.+?)\.').findall(html))[0]).replace('+', ' ') + '.') Logger.logInfo('YouTube video is removed for Id = ' + video_id + ' reason = ' + html) video_info.set_video_stopped(True) return video_info title = urllib.unquote_plus(re.compile('title=(.+?)&').findall(html)[0]).replace('/\+/g', ' ') video_info.set_video_name(title) stream_info = None if not re.search('url_encoded_fmt_stream_map=&', html): stream_info = re.compile('url_encoded_fmt_stream_map=(.+?)&').findall(html) stream_map = None if (stream_info is None or len(stream_info) == 0) and re.search('fmt_stream_map": "', html): stream_map = re.compile('fmt_stream_map": "(.+?)"').findall(html)[0].replace("\\/", "/") elif stream_info is not None: stream_map = stream_info[0] if stream_map is None: params = HttpUtils.getUrlParams(html) Logger.logDebug('ENTERING live video scenario...') for key in params: Logger.logDebug(key + " : " + urllib.unquote_plus(params[key])) hlsvp = urllib.unquote_plus(params['hlsvp']) playlistItems = HttpUtils.HttpClient().getHtmlContent(url=hlsvp).splitlines() qualityIdentified = None for item in playlistItems: Logger.logDebug(item) if item.startswith('#EXT-X-STREAM-INF'): if item.endswith('1280x720'): qualityIdentified = VIDEO_QUAL_HD_720 elif item.endswith('1080'): qualityIdentified = VIDEO_QUAL_HD_1080 elif item.endswith('854x480'): qualityIdentified = VIDEO_QUAL_SD elif item.endswith('640x360'): qualityIdentified = VIDEO_QUAL_LOW elif item.startswith('http') and qualityIdentified is not None: videoUrl = HttpUtils.HttpClient().addHttpCookiesToUrl(item, extraExtraHeaders={'Referer':'https://www.youtube.com/watch?v=' + video_id}) video_info.add_video_link(qualityIdentified, videoUrl) qualityIdentified = None video_info.set_video_stopped(False) return video_info stream_map = urllib.unquote_plus(stream_map) Logger.logDebug(stream_map) formatArray = stream_map.split(',') streams = {} for formatContent in formatArray: if formatContent == '': continue formatUrl = '' try: formatUrl = urllib.unquote(re.compile("url=([^&]+)").findall(formatContent)[0]) + "&title=" + urllib.quote_plus(title) except Exception, e: Logger.logFatal(e) if re.search("rtmpe", stream_map): try: conn = urllib.unquote(re.compile("conn=([^&]+)").findall(formatContent)[0]); host = re.compile("rtmpe:\/\/([^\/]+)").findall(conn)[0]; stream = re.compile("stream=([^&]+)").findall(formatContent)[0]; path = 'videoplayback'; formatUrl = "-r %22rtmpe:\/\/" + host + "\/" + path + "%22 -V -a %22" + path + "%22 -f %22WIN 11,3,300,268%22 -W %22http:\/\/s.ytimg.com\/yt\/swfbin\/watch_as3-vfl7aCF1A.swf%22 -p %22http:\/\/www.youtube.com\/watch?v=" + video_id + "%22 -y %22" + urllib.unquote(stream) + "%22" except Exception, e: Logger.logFatal(e) if formatUrl == '': continue Logger.logDebug('************************') Logger.logDebug(formatContent) formatQual = '' if(formatUrl[0: 4] == "http" or formatUrl[0: 2] == "-r"): formatQual = re.compile("itag=([^&]+)").findall(formatContent)[0] if not re.search("signature=", formatUrl): sig = re.compile("sig=([^&]+)").findall(formatContent) if sig is not None and len(sig) == 1: formatUrl += "&signature=" + sig[0] else: sig = re.compile("s=([^&]+)").findall(formatContent) if sig is not None and len(sig) == 1: formatUrl += "&signature=" + parseSignature(sig[0]) qual = formatQual url = HttpUtils.HttpClient().addHttpCookiesToUrl(formatUrl, addHeaders=False,addCookies=False, extraExtraHeaders={'Referer':'https://www.youtube.com/watch?v=' + video_id}) streams[int(qual)] = url
def retrieveVideoInfo(video_id): video_info = VideoInfo() video_info.set_video_hosting_info(getVideoHostingInfo()) video_info.set_video_id(video_id) try: html = HttpUtils.HttpClient().getHtmlContent( url='https://docs.google.com/file/' + str(video_id) + '?pli=1') html = html.decode('utf8') title = re.compile("'title': '(.+?)'").findall(html)[0] video_info.set_video_name(title) stream_map = re.compile('fmt_stream_map":"(.+?)"').findall( html)[0].replace("\/", "/") formatArray = stream_map.split(',') for formatContent in formatArray: formatContentInfo = formatContent.split('|') qual = formatContentInfo[0] url = (formatContentInfo[1]).decode('unicode-escape') if (qual == '13'): # 176x144 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '17'): # 176x144 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '36'): # 320x240 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '5'): # 400\\327226 video_info.add_video_link(VIDEO_QUAL_LOW, url) elif (qual == '34'): # 480x360 FLV video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '6'): # 640\\327360 FLV video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '35'): # 854\\327480 HD video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '18'): # 480x360 MP4 video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '22'): # 1280x720 MP4 video_info.add_video_link(VIDEO_QUAL_HD_720, url) elif (qual == '37'): # 1920x1080 MP4 video_info.add_video_link(VIDEO_QUAL_HD_1080, url) elif (qual == '38' and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None): # 4096\\3272304 EPIC MP4 video_info.add_video_link(VIDEO_QUAL_HD_1080, url) elif (qual == '43' and video_info.get_video_link(VIDEO_QUAL_SD) is None): # 360 WEBM video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '44'): # 480 WEBM video_info.add_video_link(VIDEO_QUAL_SD, url) elif (qual == '45' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None): # 720 WEBM video_info.add_video_link(VIDEO_QUAL_HD_720, url) elif (qual == '46' and video_info.get_video_link(VIDEO_QUAL_HD_1080) is None): # 1080 WEBM video_info.add_video_link(VIDEO_QUAL_HD_1080, url) elif (qual == '120' and video_info.get_video_link(VIDEO_QUAL_HD_720) is None): # New video qual video_info.add_video_link(VIDEO_QUAL_HD_720, url) # 3D streams - MP4 # 240p -> 83 # 360p -> 82 # 520p -> 85 # 720p -> 84 # 3D streams - WebM # 360p -> 100 # 360p -> 101 # 720p -> 102 else: # unknown quality video_info.add_video_link(VIDEO_QUAL_SD, url) video_info.set_video_stopped(False) except Exception, e: logging.exception(e) video_info.set_video_stopped(True)
def getInfoAt(mid): return HttpUtils.POST(URLS.get('GetInfo'), {'mid': mid}, {'Referer': 'https://space.bilibili.com/%s/' % mid})