def initDownloadAgent(self): self.proxyurl = None if self.useProxy: proxyhost = config.mediaportal.yt_proxy_host.value proxyport = config.mediaportal.yt_proxy_port.value self.puser = config.mediaportal.yt_proxy_username.value self.ppass = config.mediaportal.yt_proxy_password.value if '/noconnect' in proxyhost: proxyhost, option = proxyhost.split('/')[-2:] else: option = '' if not proxyhost.startswith('http'): self.proxyurl = 'http://%s:%s/%s' % (proxyhost, proxyport, option) else: self.proxyurl = '%s:%s/%s' % (proxyhost, proxyport, option) else: self.puser = None self.ppass = None self.yt_dwnld_agent = TwAgentHelper(proxy_url=self.proxyurl, p_user=self.puser, p_pass=self.ppass, gzip_decoding=True, followRedirect=True, headers=headers)
def __init__(self, session): self.callBack = None self.errBack = None self.session = session self.error = "" self.useProxy = False puser = "******" ppass = "******" self.yt_tw_agent_hlp = TwAgentHelper(use_proxy=self.useProxy, p_user=puser, p_pass=ppass, use_cookies=True) mp_globals.proxy = self.useProxy
def __init__(self, session): global playing self.__callBack = None self.errBack = None self.session = session self.error = "" self.yt_dwnld_agent = None self.useProxy = ( config.mediaportal.sp_use_yt_with_proxy.value == 'proxy') and ( config.mediaportal.yt_proxy_host.value != 'example_proxy.com!') self.initDownloadAgent() self.tw_agent_hlp = TwAgentHelper(gzip_decoding=True, followRedirect=True, headers=headers) mp_globals.premiumize = self.useProxy playing = False
def __init__(self, session): global playing self.__callBack = None self.errBack = None self.session = session self.error = "" self.yt_dwnld_agent = None self.useProxy = (config.mediaportal.sp_use_yt_with_proxy.value == 'proxy') and (config.mediaportal.yt_proxy_host.value != 'example_proxy.com!') self.initDownloadAgent() self.tw_agent_hlp = TwAgentHelper(gzip_decoding=True, followRedirect=True, headers=headers) mp_globals.premiumize = self.useProxy playing = False
def __init__(self, session): self.__callBack = None self.errBack = None self.session = session self.error = "" self.playing = False #self.useProxy = config.mediaportal.premiumize_use.value and config.mediaportal.sp_use_yt_with_proxy.value and mp_globals.premium_yt_proxy_host self.useProxy = config.mediaportal.premiumize_use.value and config.mediaportal.sp_use_yt_with_proxy.value if mp_globals.yt_dwnld_agent: mp_globals.yt_dwnld_agent.cancelDownload(self.initDownloadAgent) else: self.initDownloadAgent() self.tw_agent_hlp = TwAgentHelper(gzip_decoding=True, redir_agent=True) mp_globals.premiumize = self.useProxy self.retryParse = False
class youtubeUrl: def __init__(self, session): self.callBack = None self.errBack = None self.session = session self.error = "" self.useProxy = False puser = "******" ppass = "******" self.yt_tw_agent_hlp = TwAgentHelper(use_proxy=self.useProxy, p_user=puser, p_pass=ppass, use_cookies=True) mp_globals.proxy = self.useProxy def addCallback(self, cbFunc): self.callBack = cbFunc def addErrback(self, errFunc): self.errBack = errFunc def dataError(self, error): self.error = self.error % str(error) self.errReturn() def errReturn(self, url=None): del self.yt_tw_agent_hlp if self.errBack == None: self.session.openWithCallback(self.cbYTErr, MessageBox, str(self.error), MessageBox.TYPE_INFO, timeout=10) else: self.errBack(self.error) def cbYTErr(self, res): return def getVideoUrl(self, url, videoPrio=2): # this part is from mtube plugin if not self.callBack: self.error = '[YoutubeURL] Error: no callBack set' self.errReturn() if videoPrio == 0: self.VIDEO_FMT_PRIORITY_MAP = { '38': 5, #MP4 Original (HD) # '37' : 5, #MP4 1080p (HD) '22': 4, #MP4 720p (HD) '35': 2, #FLV 480p '18': 1, #MP4 360p '34': 3, #FLV 360p } elif videoPrio == 1: self.VIDEO_FMT_PRIORITY_MAP = { '38': 5, #MP4 Original (HD) # '37' : 5, #MP4 1080p (HD) '22': 4, #MP4 720p (HD) '35': 1, #FLV 480p '18': 2, #MP4 360p '34': 3, #FLV 360p } else: self.VIDEO_FMT_PRIORITY_MAP = { '38': 2, #MP4 Original (HD) # '37' : 1, #MP4 1080p (HD) '22': 1, #MP4 720p (HD) '35': 3, #FLV 480p '18': 4, #MP4 360p '34': 5, #FLV 360p } self.video_url = None self.video_id = url self.videoPrio = videoPrio # Getting video webpage #URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0. watch_url = 'http://www.youtube.com/watch?v=%s&safeSearch=none' % self.video_id self.error = "[YoutubeURL] Error: Unable to retrieve watchpage:\n%s" self.yt_tw_agent_hlp.getWebPage(self.parseVInfo, self.dataError, watch_url, False) def parseVInfo(self, videoinfo): flashvars = self.extractFlashVars(videoinfo, 0) if not flashvars.has_key(u"url_encoded_fmt_stream_map"): # Attempt to see if YouTube has issued an error message if 'reason' not in flashvars: pc = False if 'ypc-offer-title' in videoinfo: pc = True msg = re.search('ypc-offer-title">.*?<a.*?">(.*?)</a', videoinfo, re.S) self.error = '[YoutubeURL] Error: Paid Content' if msg: self.error += ': "%s"' % msg.group(1) else: msg = re.search('class="message">(.*?)</', videoinfo, re.S) if msg: self.error = '[YoutubeURL] Error: %s' % msg.group( 1).strip() else: self.error = '[YoutubeURL] Error: unable to extract "url_encoded_fmt_stream_map" parameter for unknown reason' if not pc and 'og:restrictions:age' in videoinfo: el = '&el=embedded' info_url = ( 'http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en' % (self.video_id, el)) self.error = "[YoutubeURL] Error: Unable to retrieve videoinfo page:\n%s" self.yt_tw_agent_hlp.getWebPage(self.parseVInfo2, self.dataError, info_url, False) return else: reason = unquote_plus(videoinfo['reason'][0]) self.error = '[YoutubeURL] Error: YouTube said: %s' % reason.decode( 'utf-8') self.errReturn(self.video_url) else: links = {} for url_desc in flashvars[u"url_encoded_fmt_stream_map"].split( u","): url_desc_map = parse_qs(url_desc) if not (url_desc_map.has_key(u"url") or url_desc_map.has_key(u"stream")): continue key = int(url_desc_map[u"itag"][0]) url = u"" if url_desc_map.has_key(u"url"): url = urllib.unquote(url_desc_map[u"url"][0]) elif url_desc_map.has_key(u"conn") and url_desc_map.has_key( u"stream"): url = urllib.unquote(url_desc_map[u"conn"][0]) if url.rfind("/") < len(url) - 1: url = url + "/" url = url + urllib.unquote(url_desc_map[u"stream"][0]) elif url_desc_map.has_key( u"stream") and not url_desc_map.has_key(u"conn"): url = urllib.unquote(url_desc_map[u"stream"][0]) if url_desc_map.has_key(u"sig"): url = url + u"&signature=" + url_desc_map[u"sig"][0] elif url_desc_map.has_key(u"s"): sig = url_desc_map[u"s"][0] flashvars = self.extractFlashVars(videoinfo, 1) js = flashvars[u"js"] url = url + u"&signature=" + decryptor.decryptSignature( sig, js) try: links[self.VIDEO_FMT_PRIORITY_MAP[str(key)]] = url except KeyError: print 'skipping', key, 'fmt not in priority videos' continue try: self.video_url = links[sorted( links.iterkeys())[0]].encode('utf-8') del self.yt_tw_agent_hlp self.callBack(self.video_url) except (KeyError, IndexError): self.error = "[YoutubeURL] Error: no video url found" self.errReturn(self.video_url) def parseVInfo2(self, videoinfo): videoinfo = parse_qs(videoinfo) if not videoinfo.has_key(u"url_encoded_fmt_stream_map"): self.error = '[YoutubeURL] Error: unable to extract "url_encoded_fmt_stream_map" parameter for unknown reason' self.errReturn(self.video_url) else: video_fmt_map = {} fmt_infomap = {} tmp_fmtUrlDATA = videoinfo['url_encoded_fmt_stream_map'][0].split( ',') for fmtstring in tmp_fmtUrlDATA: fmturl = fmtid = fmtsig = "" if videoinfo.has_key('url_encoded_fmt_stream_map'): try: for arg in fmtstring.split('&'): if arg.find('=') >= 0: key, value = arg.split('=') if key == 'itag': if len(value) > 3: value = value[:2] fmtid = value elif key == 'url': fmturl = value elif key == 'sig': fmtsig = value if fmtid != "" and fmturl != "" and self.VIDEO_FMT_PRIORITY_MAP.has_key( fmtid): video_fmt_map[ self.VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl), 'fmtsig': fmtsig } fmt_infomap[int(fmtid)] = "%s&signature=%s" % ( unquote_plus(fmturl), fmtsig) fmturl = fmtid = fmtsig = "" except: self.error = "[YoutubeURL] Error parsing fmtstring: %s" % fmtstring self.errReturn(self.video_url) return else: (fmtid, fmturl) = fmtstring.split('|') if self.VIDEO_FMT_PRIORITY_MAP.has_key(fmtid) and fmtid != "": video_fmt_map[self.VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl) } fmt_infomap[int(fmtid)] = unquote_plus(fmturl) if video_fmt_map and len(video_fmt_map): print "[youtubeUrl] found best available video format:", video_fmt_map[ sorted(video_fmt_map.iterkeys())[0]]['fmtid'] best_video = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]] if best_video['fmtsig']: self.video_url = "%s&signature=%s" % ( best_video['fmturl'].split(';')[0], best_video['fmtsig']) else: self.video_url = "%s" % ( best_video['fmturl'].split(';')[0]) del self.yt_tw_agent_hlp self.callBack(self.video_url) else: self.error = "[YoutubeURL] Error: no video url found" self.errReturn(self.video_url) def removeAdditionalEndingDelimiter(self, data): pos = data.find("};") if pos != -1: data = data[:pos + 1] return data def extractFlashVars(self, data, assets): flashvars = {} found = False for line in data.split("\n"): if line.strip().find(";ytplayer.config = ") > 0: found = True p1 = line.find(";ytplayer.config = ") + len( ";ytplayer.config = ") - 1 p2 = line.rfind(";") if p1 <= 0 or p2 <= 0: continue data = line[p1 + 1:p2] break data = self.removeAdditionalEndingDelimiter(data) if found: data = json.loads(data) if assets: flashvars = data["assets"] else: flashvars = data["args"] return flashvars
class youtubeUrl(object): def __init__(self, session): self.__callBack = None self.errBack = None self.session = session self.error = "" self.playing = False #self.useProxy = config.mediaportal.premiumize_use.value and config.mediaportal.sp_use_yt_with_proxy.value and mp_globals.premium_yt_proxy_host self.useProxy = config.mediaportal.premiumize_use.value and config.mediaportal.sp_use_yt_with_proxy.value if mp_globals.yt_dwnld_agent: mp_globals.yt_dwnld_agent.cancelDownload(self.initDownloadAgent) else: self.initDownloadAgent() self.tw_agent_hlp = TwAgentHelper(gzip_decoding=True, redir_agent=True) mp_globals.premiumize = self.useProxy self.retryParse = False def initDownloadAgent(self): print 'initDownloadAgent:' mp_globals.yt_dwnld_agent = None if self.useProxy: #proxyhost = mp_globals.premium_yt_proxy_host #proxyport = mp_globals.premium_yt_proxy_port proxyhost = 'nl.premiumize.me' proxyport = 82 puser = config.mediaportal.premiumize_username.value ppass = config.mediaportal.premiumize_password.value mp_globals.yt_dwnld_agent = TwDownloadAgent(use_proxy=self.useProxy, proxy_host=proxyhost, proxy_port=proxyport, p_user=puser, p_pass=ppass, gzip_decoding=True, redir_agent=True) else: mp_globals.yt_dwnld_agent = TwDownloadAgent(gzip_decoding=True, redir_agent=True) def callBack(self, url): print 'callBack:' self.error = '[YoutubeURL] Playback error:' self.tw_agent_hlp.getRedirectedUrl(url, True).addCallback(self.getRedirect).addErrback(self.dataError) def getRedirect(self, url): print 'getRedirect:' if mp_globals.yt_dwnld_agent and url and 'Forbidden' in url and self.video_url.startswith('http'): if config.mediaportal.premiumize_yt_buffering_opt.value != 'off': self.downloadStream() else: self.dataError(url) elif mp_globals.yt_dwnld_agent and config.mediaportal.premiumize_yt_buffering_opt.value == 'all': self.downloadStream() else: self.__callBack(url) def downloadStream(self): print 'downloadStream:' self.error = '[YoutubeURL] Buffering error:' mp_globals.yt_dwnld_lastnum = (mp_globals.yt_dwnld_lastnum + 1) % 2 mp_globals.yt_dwnld_agent.downloadPage(self.video_url, 'yt_downloaded_file_%d' % mp_globals.yt_dwnld_lastnum, self.playFile).addCallback(self.playFile).addErrback(self.dataError) def playFile(self, data): print 'playFile:',data if data: m = re.search('File="(.*?)" buffering="(.*?)"', data) if m: filepath = m.group(1) buffering = m.group(2) if buffering: if 'canceled' == buffering: print 'Buffering canceled' self.session.open(MessageBoxExt, _('Buffering canceled'), MessageBoxExt.TYPE_INFO, timeout=3) elif 'ready' != buffering: print 'Buffering finished' if filepath and not self.playing: self.playing = True self.__callBack(filepath) def addCallback(self, cbFunc): self.__callBack = cbFunc def addErrback(self, errFunc): self.errBack = errFunc def dataError(self, error): print 'dataError:' self.error += str(error) self.errReturn() def errReturn(self, url=None): mp_globals.yt_dwnld_agent = None if self.errBack == None: self.session.openWithCallback(self.cbYTErr, MessageBoxExt,str(self.error), MessageBoxExt.TYPE_INFO, timeout=10) else: self.errBack(self.error) def cbYTErr(self, res): return def getVideoUrl(self, url, videoPrio=2): # portions of this part is from mtube plugin if not self.__callBack: self.error = '[YoutubeURL] Error: no callBack set' self.errReturn() if videoPrio == 0: self.VIDEO_FMT_PRIORITY_MAP = { '38' : 5, #MP4 Original (HD) # '37' : 5, #MP4 1080p (HD) '22' : 4, #MP4 720p (HD) '35' : 2, #FLV 480p '18' : 1, #MP4 360p '34' : 3, #FLV 360p } elif videoPrio == 1: self.VIDEO_FMT_PRIORITY_MAP = { '38' : 5, #MP4 Original (HD) # '37' : 5, #MP4 1080p (HD) '22' : 4, #MP4 720p (HD) '35' : 1, #FLV 480p '18' : 2, #MP4 360p '34' : 3, #FLV 360p } else: self.VIDEO_FMT_PRIORITY_MAP = { '38' : 2, #MP4 Original (HD) # '37' : 1, #MP4 1080p (HD) '22' : 1, #MP4 720p (HD) '35' : 3, #FLV 480p '18' : 4, #MP4 360p '34' : 5, #FLV 360p } self.video_url = None self.video_id = url self.videoPrio = videoPrio # Getting video webpage #URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0. #watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&safeSearch=none&noredirect=1'%self.video_id watch_url = 'http://www.youtube.com/watch?v=%s&gl=US'%self.video_id self.error = "[YoutubeURL] Error: Unable to retrieve watchpage:\n%s\n" % watch_url print watch_url if mp_globals.yt_dwnld_agent: mp_globals.yt_dwnld_agent.getWebPage(watch_url).addCallback(self.parseVInfo, watch_url).addErrback(self.dataError) else: self.tw_agent_hlp.getWebPage(watch_url).addCallback(self.parseVInfo, watch_url).addErrback(self.dataError) def parseVInfo(self, videoinfo, watch_url): flashvars = self.extractFlashVars(videoinfo, 0) if not flashvars.has_key(u"url_encoded_fmt_stream_map"): if self.useProxy and not self.retryParse: self.retryParse = True self.tw_agent_hlp.getWebPage(watch_url).addCallback(self.parseVInfo, watch_url).addErrback(self.dataError) else: self.checkFlashvars(flashvars, videoinfo, True) else: links = {} for url_desc in flashvars[u"url_encoded_fmt_stream_map"].split(u","): url_desc_map = parse_qs(url_desc) if not (url_desc_map.has_key(u"url") or url_desc_map.has_key(u"stream")): continue key = int(url_desc_map[u"itag"][0]) url = u"" if url_desc_map.has_key(u"url"): url = urllib.unquote(url_desc_map[u"url"][0]) elif url_desc_map.has_key(u"conn") and url_desc_map.has_key(u"stream"): url = urllib.unquote(url_desc_map[u"conn"][0]) if url.rfind("/") < len(url) -1: url = url + "/" url = url + urllib.unquote(url_desc_map[u"stream"][0]) elif url_desc_map.has_key(u"stream") and not url_desc_map.has_key(u"conn"): url = urllib.unquote(url_desc_map[u"stream"][0]) if url_desc_map.has_key(u"sig"): url = url + u"&signature=" + url_desc_map[u"sig"][0] elif url_desc_map.has_key(u"s"): sig = url_desc_map[u"s"][0] flashvars = self.extractFlashVars(videoinfo, 1) if isVEVODecryptor: signature = decryptor.decryptSignature(sig, flashvars[u"js"]) else: signature = None if not signature: self.error = "[YoutubeURL] Error: cannot decrypt signature!" self.errReturn(None) return else: url += u"&signature=" + signature try: links[self.VIDEO_FMT_PRIORITY_MAP[str(key)]] = url except KeyError: print 'skipping',key,'fmt not in priority videos' continue if not links: url = flashvars.get('hlsvp','') print 'hlsvp:',str(url) if url: links[0] = url try: self.video_url = links[sorted(links.iterkeys())[0]].encode('utf-8') self.callBack(self.video_url) except (KeyError,IndexError): self.error = "[YoutubeURL] Error: no video url found" self.errReturn(self.video_url) def parseVInfo2(self, videoinfo): print 'parseVInfo2:' flashvars = parse_qs(videoinfo) if not flashvars.has_key(u"url_encoded_fmt_stream_map"): self.checkFlashvars(flashvars, videoinfo) else: print 'parsing...' video_fmt_map = {} fmt_infomap = {} tmp_fmtUrlDATA = flashvars['url_encoded_fmt_stream_map'][0].split(',') for fmtstring in tmp_fmtUrlDATA: fmturl = fmtid = fmtsig = "" if flashvars.has_key('url_encoded_fmt_stream_map'): try: for arg in fmtstring.split('&'): if arg.find('=') >= 0: key, value = arg.split('=') if key == 'itag': if len(value) > 3: value = value[:2] fmtid = value elif key == 'url': fmturl = value elif key == 'sig': fmtsig = value if fmtid != "" and fmturl != "" and self.VIDEO_FMT_PRIORITY_MAP.has_key(fmtid): video_fmt_map[self.VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl), 'fmtsig': fmtsig } fmt_infomap[int(fmtid)] = "%s&signature=%s" %(unquote_plus(fmturl), fmtsig) fmturl = fmtid = fmtsig = "" except: self.error = "[YoutubeURL] Error parsing fmtstring: %s" % fmtstring self.errReturn(self.video_url) return else: (fmtid,fmturl) = fmtstring.split('|') if self.VIDEO_FMT_PRIORITY_MAP.has_key(fmtid) and fmtid != "": video_fmt_map[self.VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl) } fmt_infomap[int(fmtid)] = unquote_plus(fmturl) if video_fmt_map and len(video_fmt_map): print "[youtubeUrl] found best available video format:",video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmtid'] best_video = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]] if best_video['fmtsig']: self.video_url = "%s&signature=%s" %(best_video['fmturl'].split(';')[0], best_video['fmtsig']) else: self.video_url = "%s" %(best_video['fmturl'].split(';')[0]) self.callBack(self.video_url) else: self.error = "[YoutubeURL] Error: no video url found" self.errReturn(self.video_url) def checkFlashvars(self, flashvars, videoinfo, get_info2=False): # Attempt to see if YouTube has issued an error message if not flashvars.has_key(u"reason"): from imports import decodeHtml pc = False if 'ypc-offer-title' in videoinfo: msg = re.search('ypc-offer-title">.*?<a.*?">(.*?)</a', videoinfo, re.S) if msg: pc = True self.error = '[YoutubeURL] Error: Paid Content' self.error += '\n: "%s"' % msg.group(1) elif 'itemprop="paid" content="True"' in videoinfo: msg = re.search('dir="ltr" title="(.*?)"', videoinfo, re.S) if msg: pc = True self.error = '[YoutubeURL] Error: Paid Content' self.error += ':\n"%s"' % decodeHtml(msg.group(1)) msg = re.search('class="message">(.*?)</', videoinfo, re.S) if msg: txt = msg.group(1).strip() msg = re.search('class="submessage">(.*?)</', videoinfo, re.S) if msg: txt += '\n' + msg.group(1).strip() if not pc: self.error = '[YoutubeURL] Error: %s' % txt else: self.error += txt elif not pc: print 'videoinfo:',videoinfo self.error = '[YoutubeURL] Error: unable to extract "url_encoded_fmt_stream_map" parameter for unknown reason' if not pc and get_info2 and 'og:restrictions:age' in videoinfo: el = '&el=embedded' info_url = ('http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en' % (self.video_id, el)) self.error = "[YoutubeURL] Error: Unable to retrieve videoinfo page:\n%s\n" % info_url if mp_globals.yt_dwnld_agent: mp_globals.yt_dwnld_agent.getWebPage(info_url).addCallback(self.parseVInfo2).addErrback(self.dataError) else: self.tw_agent_hlp.getWebPage(info_url).addCallback(self.parseVInfo2).addErrback(self.dataError) return else: reason = unquote_plus(flashvars['reason'][0]) self.error = '[YoutubeURL] Error: YouTube said: %s' % reason.decode('utf-8') self.errReturn(self.video_url) def removeAdditionalEndingDelimiter(self, data): pos = data.find("};") if pos != -1: data = data[:pos + 1] return data def normalizeUrl(self, url): if url[0:2] == "//": url = "http:" + url return url def extractFlashVars(self, data, assets): flashvars = {} found = False for line in data.split("\n"): if line.strip().find(";ytplayer.config = ") > 0: found = True p1 = line.find(";ytplayer.config = ") + len(";ytplayer.config = ") - 1 p2 = line.rfind(";") if p1 <= 0 or p2 <= 0: continue data = line[p1 + 1:p2] break data = self.removeAdditionalEndingDelimiter(data) if found: data = json.loads(data) if assets: flashvars = data["assets"] else: flashvars = data["args"] for k in ["html", "css", "js"]: if k in flashvars: flashvars[k] = self.normalizeUrl(flashvars[k]) return flashvars
def __init__(self, session): self._callback = None self.session = session self.showmsgbox = True self.tw_agent_hlp = TwAgentHelper()
class get_stream_link: def __init__(self, session): self._callback = None self.session = session self.showmsgbox = True self.tw_agent_hlp = TwAgentHelper() def check_link(self, data, got_link, showmsgbox=True): print "check_link" self._callback = got_link self.showmsgbox = showmsgbox if data: if re.match(".*?http://www.putlocker.com/(file|embed)/", data, re.S): link = data.replace('file','embed') #print "ok:", link if link: getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.streamPutlockerSockshare, link, "putlocker").addErrback(self.errorload) elif re.match(".*?http://www.sockshare.com/(file|embed)/", data, re.S): link = data.replace('file','embed') #print link if link: getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.streamPutlockerSockshare, link, "sockshare").addErrback(self.errorload) elif re.match(".*?http://streamcloud.eu/", data, re.S): #link = re.findall("(http://streamcloud.eu/.*?)'", data, re.S) link = data if link: getPage(link, cookies=ck, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.streamcloud).addErrback(self.errorload) elif re.match('.*?http://xvidstage.com', data, re.S): link = data #print "xvidstage" getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.xvidstage_post, link).addErrback(self.errorload) elif re.match('.*?http://filenuke.com', data, re.S): link = data getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.filenuke, link).addErrback(self.errorload) elif re.match('.*?http://movreel.com/', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.movreel_data, link).addErrback(self.errorload) elif re.match('.*?http://xvidstream.net/', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.xvidstream).addErrback(self.errorload) elif re.match('.*?http://(www|embed).nowvideo.eu', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.nowvideo).addErrback(self.errorload) elif re.match('.*?http://www.uploadc.com', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.uploadc, link).addErrback(self.errorload) elif re.match('.*?http://vreer.com', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vreer, link).addErrback(self.errorload) elif re.match('.*?http://www.monsteruploads.eu', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.monsteruploads, link).addErrback(self.errorload) elif re.match('.*?flashstream.in', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.flashstream).addErrback(self.errorload) elif re.match('.*?ginbig.com', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.ginbig_flashstream, link).addErrback(self.errorload) elif re.match('.*?videoweed.es', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.videoweed).addErrback(self.errorload) elif re.match('.*?novamov.com', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.novamov).addErrback(self.errorload) elif re.match('.*?.movshare.net', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.movshare, link).addErrback(self.errorload) elif re.match('.*divxstage', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.divxstage).addErrback(self.errorload) elif re.match('.*?yesload.net', data, re.S): link = data #print link id = link.split('/') id = id[-1] if id: #print id api_url = "http://yesload.net/player_api/info?token=%s" % id getPage(api_url, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.yesload).addErrback(self.errorload) else: self.stream_not_found() elif re.match('.*?faststream', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.faststream, link).addErrback(self.errorload) elif re.match('.*?primeshare', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.primeshare, link).addErrback(self.errorload) elif re.match('.*?http://vidstream.us', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vidstream_us).addErrback(self.errorload) elif re.match('.*?http://vidstream.in', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vidstream_in, link).addErrback(self.errorload) elif re.match('.*?video.istream.ws/embed', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.check_istream_link).addErrback(self.errorload) elif re.match('.*?http:/.*?flashx.tv', data, re.S): #elif re.match('.*?http:/disabled', data, re.S): link = data #print link hash = re.findall('http://flashx.tv/video/(.*?)/', link) if hash: getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.flashx_tv3b).addErrback(self.errorload) elif re.match('.*?embed.php\?hash=', link) or re.match('.*?embed_player.php\?hash=', link) or re.match('.*?embed_player.php\?vid=', link) or re.match('.*?embed.php\?vid=', link): self.flashx_tv3(link) elif re.match('.*?player/fxtv.php.hash=', link): self.tw_agent_hlp.getRedirectedUrl(self.check_link, self.stream_not_found, link, self._callback, False) else: print "flashx_tv link not found: ",link self.stream_not_found() elif re.match('.*?putme.org', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.putme_org, link).addErrback(self.errorload) elif re.match('.*?divxmov.net', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.divxmov).addErrback(self.errorload) elif re.match('.*?sharesix.com/', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.sharesix).addErrback(self.errorload) elif re.match('.*?zooupload.com/', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.zooupload).addErrback(self.errorload) elif re.match('.*?http://wupfile.com', data, re.S): link = data print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.wupfile_post, link).addErrback(self.errorload) elif re.match('.*?http://bitshare.com', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.bitshare).addErrback(self.errorload) elif re.match('.*?userporn.com', data, re.S): link = data #print link self.userporn_tv(link) elif re.match('.*?ecostream.tv', data, re.S): link = data getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.eco_read).addErrback(self.errorload) elif re.match('.*?http://played.to', data, re.S): link = data getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.played, link).addErrback(self.errorload) elif re.match('.*?stream2k.com', data, re.S): link = data getPage(link, headers={'referer':link}).addCallback(self.stream2k).addErrback(self.errorload) elif re.match('.*?limevideo.net', data, re.S): link = data getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.lmv, link).addErrback(self.errorload) elif re.match('.*?videomega.tv', data, re.S): link = data if re.match('.*?iframe.php', link): getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.videomega).addErrback(self.errorload) else: id = link.split('ref=') if id: link = "http://videomega.tv/iframe.php?ref=%s" % id[1] getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.videomega).addErrback(self.errorload) else: self.stream_not_found() elif re.match('.*?vk.com', data, re.S): link = data getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vkme).addErrback(self.errorload) elif re.match('.*?mightyupload.com/embed', data, re.S): link = data getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.mightyupload).addErrback(self.errorload) elif re.match('.*?mightyupload.com', data, re.S): link = data id = link.split('/') url = "http://www.mightyupload.com/embed-%s.html" % id[3] print url getPage(url, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.mightyupload).addErrback(self.errorload) elif re.match('.*?http://youwatch.org', data, re.S): link = data id = link.split('org/') url = "http://youwatch.org/embed-%s.html" % id[1] getPage(url, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.youwatch).addErrback(self.errorload) else: message = self.session.open(MessageBox, _("No supported Stream Hoster, try another one !"), MessageBox.TYPE_INFO, timeout=5) else: print "Invalid link",link if self.showmsgbox: message = self.session.open(MessageBox, _("Invalid Stream link, try another Stream Hoster !"), MessageBox.TYPE_INFO, timeout=5) def stream_not_found(self): self._callback(None) print "stream_not_found!" if self.showmsgbox: message = self.session.open(MessageBox, _("Stream not found, try another Stream Hoster."), MessageBox.TYPE_INFO, timeout=5) def youwatch(self, data): stream_url = re.findall('file: "(.*?)"', data, re.S) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() def mightyupload(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def vkme(self, data): print "vk.me.." stream_urls = re.findall('url[0-9]+=(http://.*?.vk.me/.*?/videos/.*?[0-9]+.mp4)', data) if stream_urls: print stream_urls stream_url = stream_urls[-1] print stream_url self._callback(stream_url) else: self.stream_not_found() def videomega(self, data): unescape = re.findall('unescape."(.*?)"', data, re.S) if unescape: javadata = urllib2.unquote(unescape[0]) if javadata: stream_url = re.findall('file: "(.*?)"', javadata, re.S) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def lmv(self, data, url): dataPost = {} r = re.findall('input type="hidden".*?name="(.*?)".*?value="(.*?)"', data, re.S) for name, value in r: dataPost[name] = value dataPost.update({'method_free':'Continue to Video'}) print dataPost getPage(url, method='POST', postdata=urlencode(dataPost), headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.lmv2, url).addErrback(self.errorload) def lmv2(self, data, url): dataPost = {} r = re.findall('input type="hidden".*?name="(.*?)".*?value="(.*?)"', data, re.S) for name, value in r: dataPost[name] = value dataPost.update({'method_free':'Continue to Video'}) print dataPost getPage(url, method='POST', postdata=urlencode(dataPost), headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.lmvPlay).addErrback(self.errorload) def lmvPlay(self, data): print data get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[0] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def stream2k(self, data): file = re.findall("file: '(.*?)'", data, re.S) if file: self._callback(file[0]) else: self.stream_not_found() def played(self, data, url): print "hole daten" op = re.findall('type="hidden" name="op".*?value="(.*?)"', data, re.S) id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) referer = re.findall('type="hidden" name="referer".*?value="(.*?)"', data, re.S) hash = re.findall('type="hidden" name="hash".*?value="(.*?)"', data, re.S) if op and id and fname and referer: info = urlencode({ 'fname': fname[0], 'id': id[0], 'imhuman': "Continue to Video", 'op': "download1", 'referer': "", 'hash': hash[0], 'usr_login': ""}) print info getPage(url, method='POST', cookies=cj, postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.played_data2).addErrback(self.errorload) #reactor.callLater(5, self.played_data, url, method='POST', cookies=cj, postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}) else: self.stream_not_found() def played_data(self, *args, **kwargs): print "drin" getPage(*args, **kwargs).addCallback(self.played_data2).addErrback(self.errorload) def played_data2(self, data): print data stream_url = re.findall('file: "(.*?)"', data, re.S) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() def eco_read(self, data): post_url = re.findall('<form name="setss" method="post" action="(.*?)">', data, re.S) if post_url: info = urlencode({'': '1', 'sss': '1'}) print info getPage(post_url[0], method='POST', postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.eco_post).addErrback(self.errorload) else: self.stream_not_found() def eco_post(self, data): url = "http://www.ecostream.tv/assets/js/common.js" data2 = urllib.urlopen(url).read() post_url = re.findall("url: '(http://www.ecostream.tv/.*?)\?s=", data2, re.S) if post_url: print post_url sPattern = "var t=setTimeout\(\"lc\('([^']+)','([^']+)','([^']+)','([^']+)'\)" r = re.findall(sPattern, data) if r: for aEntry in r: sS = str(aEntry[0]) sK = str(aEntry[1]) sT = str(aEntry[2]) sKey = str(aEntry[3]) print "current keys:", sS, sK, sT, sKey sNextUrl = post_url[0]+"?s="+sS+'&k='+sK+'&t='+sT+'&key='+sKey print "URL:", sNextUrl info = urlencode({'s': sS, 'k': sK, 't': sT, 'key': sKey}) print "POST:", info getPage(sNextUrl, method='POST', postdata=info, headers={'Referer':'http://www.ecostream.tv', 'X-Requested-With':'XMLHttpRequest'}).addCallback(self.eco_final).addErrback(self.errorload) else: self.stream_not_found() else: self.stream_not_found() def eco_final(self, data): print "final gefunden" stream_url = re.findall('flashvars="file=(.*?)&', data) if stream_url: kkStreamUrl = "http://www.ecostream.tv"+stream_url[0]+"&start=0" kkStreamUrl = urllib2.unquote(kkStreamUrl) print kkStreamUrl self._callback(kkStreamUrl) else: self.stream_not_found() def zooupload(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def wupfile_post(self, data, url): print "hole daten" op = re.findall('type="hidden" name="op".*?value="(.*?)"', data, re.S) id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) referer = re.findall('type="hidden" name="referer".*?value="(.*?)"', data, re.S) if op and id and fname and referer: info = urlencode({ 'fname': fname[0], 'id': id[0], 'method_free': "Kostenloser Download", 'op': "download1", 'referer': "", 'usr_login': ""}) print info getPage(url, method='POST', postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.wupfile_data).addErrback(self.errorload) else: self.stream_not_found() def wupfile_data(self, data): print "hole streamlink" get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def sharesix(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0].replace('0://','http://') self._callback(stream_url[0].replace('0://','http://')) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0].replace('0://','http://') self._callback(stream_url[0].replace('0://','http://')) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def divxmov(self, data): stream_url = re.findall('<embed type="video/divx" src="(.*?)"', data, re.S) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def putme_org(self, data, url): print "hole post infos" dataPost = {} r = re.findall('input type="hidden".*?name="(.*?)".*?value="(.*?)"', data, re.S) if r: for name, value in r: dataPost[name] = value dataPost.update({'method_free':'Continue to Video'}) print dataPost getPage(url, method='POST', cookies=cj, postdata=urlencode(dataPost), headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.putme_org_post, url).addErrback(self.errorload) else: self.stream_not_found() def putme_org_post(self, data, url): print "hole post infos2" dataPost = {} r = re.findall('input type="hidden".*?name="(.*?)".*?value="(.*?)"', data, re.S) if r: for name, value in r: dataPost[name] = value dataPost.update({'method_free':'Continue to Video'}) print dataPost getPage(url, method='POST', postdata=urlencode(dataPost), headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.putme_org_data).addErrback(self.errorload) else: self.stream_not_found() def putme_org_data(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0].replace('0://','http://') self._callback(stream_url[0].replace('0://','http://')) else: self.stream_not_found() elif re.match(".*?file:", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file:'(.*?)'", sUnpacked) if stream_url: print stream_url[0].replace('0://','http://') self._callback(stream_url[0].replace('0://','http://')) else: self.stream_not_found() elif re.match('.*?value="src=', sUnpacked): stream_url = re.findall('value="src=(.*?flv)&', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def errorload(self, error): print "[streams]:", error self.stream_not_found() def flashx_tv(self, data): stream_url = re.findall('<file>(http://.*?flashx.tv.*?)</file>', data) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def flashx_tv2(self, data): print "flashx_tv2: ",data hash = re.findall('http://play.flashx.tv/player/fxtv.php.hash=(.*?)&', data, re.S) if hash: url = "http://play.flashx.tv/nuevo/player/cst.php?hash=%s" % hash[0] #print url getPage(url, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.flashx_tv).addErrback(self.errorload) else: self.stream_not_found() def flashx_tv3(self, link): print "flashx_tv3: ",link fx = Flashx() stream_url = fx.getVidUrl(link) if stream_url: self._callback(stream_url) else: self.stream_not_found() def flashx_tv3b(self, data): stream_url = re.findall('id="normal_player_cont">.*?src="(.*?)"', data, re.S) if stream_url: self.flashx_tv3(stream_url[0]) else: self.stream_not_found() def vidstream_in(self, data, url): id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) hash = re.findall('type="hidden" name="hash".*?value="(.*?)"', data, re.S) if id and fname and hash: print id, fname, hash post_data = urlencode({'op': "download1", 'usr_login': "", 'id': id[0], 'fname': fname[0], 'hash': hash[0], 'referer': "", 'imhuman': " Proceed+to+video"}) #getPage(url, method='POST', cookies=cj, postdata=post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vidstream_in_data).addErrback(self.errorload) reactor.callLater(6, self.vidstream_in_getPage, url, method='POST', cookies=cj, postdata=post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}) message = self.session.open(MessageBox, _("Stream startet in 6 sec."), MessageBox.TYPE_INFO, timeout=6) else: self.stream_not_found() def vidstream_in_getPage(self, *args, **kwargs): print "drin" getPage(*args, **kwargs).addCallback(self.vidstream_in_data).addErrback(self.errorload) def vidstream_in_data(self, data): stream_url = re.findall('file: "(.*?)"', data, re.S) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def vidstream_us(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?'file'", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("'file','(.*?)'", sUnpacked) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def primeshare(self, data, url): hash = re.findall('<input type="hidden".*?name="hash".*?value="(.*?)"', data) if hash: info = urlencode({'hash': hash[0]}) print info reactor.callLater(16, self.primeshare_getPage, url, method='POST', cookies=cj, postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}) message = self.session.open(MessageBox, _("Stream startet in 16 sec."), MessageBox.TYPE_INFO, timeout=16) else: self.stream_not_found() def primeshare_getPage(self, *args, **kwargs): print "drin" getPage(*args, **kwargs).addCallback(self.primeshare_data).addErrback(self.errorload) def primeshare_data(self, data): print data stream_url = re.findall('file: \'(.*?)\'', data, re.S) if stream_url: self._callback(stream_url[0]) else: #re.findall("'(http://.*?primeshare.tv.*?)'", url) stream_url = re.findall("provider: 'stream'.*?url: '(http://.*?primeshare.tv.*?)'", data, re.S) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def faststream(self, data, url): op = re.findall('type="hidden" name="op".*?value="(.*?)"', data, re.S) id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) referer = re.findall('type="hidden" name="referer".*?value="(.*?)"', data, re.S) hash = re.findall('type="hidden" name="hash".*?value="(.*?)"', data, re.S) if op and id and fname and referer and hash: info = urlencode({ 'fname': fname[0], 'hash': hash[0], 'id': id[0], 'imhuman': "Proceed to video", 'op':"download1", 'referer': "", 'usr_login': ""}) print info reactor.callLater(5, self.faststream_getPage, url, method='POST', postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}) message = self.session.open(MessageBox, _("Stream startet in 6 sec."), MessageBox.TYPE_INFO, timeout=6) else: self.stream_not_found() def faststream_getPage(self, *args, **kwargs): print "drin" getPage(*args, **kwargs).addCallback(self.faststream_data).addErrback(self.errorload) def faststream_data(self, data): stream_url = re.findall('file: "(.*?)"', data, re.S) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def yesload(self, data): stream_url = re.findall('url=(.*?.flv)', data) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def videoweed(self, data): print "drin okdf" r = re.search('flashvars.domain="(.+?)".*flashvars.file="(.+?)".*' + 'flashvars.filekey="(.+?)"', data, re.DOTALL) if r: domain, fileid, filekey = r.groups() api_call = ('%s/api/player.api.php?user=undefined&codes=1&file=%s' + '&pass=undefined&key=%s') % (domain, fileid, filekey) if api_call: getPage(api_call, method='GET').addCallback(self.videoweed_data).addErrback(self.errorload) else: self.stream_not_found() else: self.stream_not_found() def videoweed_data(self, data): rapi = re.search('url=(.+?)&title=', data) if rapi: stream_url = rapi.group(1) if stream_url: print stream_url self._callback(stream_url) else: self.stream_not_found() else: self.stream_not_found() def novamov(self, data): file = re.findall('flashvars.file="(.*?)"', data) key = re.findall('flashvars.filekey="(.*?)"', data) if file and key: url = "http://www.novamov.com/api/player.api.php?file=%s&key=%s" % (file[0], key[0]) aage = "Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17" getPage(url, agent=aage, method='GET').addCallback(self.novamov_data).addErrback(self.errorload) else: self.stream_not_found() def novamov_data(self, data): ar = re.search('url=(.+?)&title', data) if ar: stream_url = ar.group(1) print stream_url self._callback(stream_url) else: self.stream_not_found() def divxstage(self, data): print "divxstage drin" file = re.findall('flashvars.file="(.*?)"', data) key = re.findall('flashvars.filekey="(.*?)"', data) if file and key: url = "http://www.divxstage.eu/api/player.api.php?file=%s&key=%s" % (file[0], key[0]) print url aage = "Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17" getPage(url, agent=aage, method='GET').addCallback(self.movshare_xml).addErrback(self.errorload) else: print "ja" self.stream_not_found() def movshare(self, data, url): info = {} getPage(url, method='POST', cookies=cj, postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.movshare_post).addErrback(self.errorload) def movshare_post(self, data): print "movshare drin" file = re.findall('flashvars.file="(.*?)"', data, re.S) key = re.findall('flashvars.filekey="(.*?)"', data, re.S) if file and key: url = "http://www.movshare.net/api/player.api.php?file=%s&key=%s" % (file[0], key[0]) print url getPage(url, method='GET').addCallback(self.movshare_xml).addErrback(self.errorload) else: print "ja" self.stream_not_found() def movshare_xml(self, data): file_link = re.search('url=(.+?)&title=', data) if file_link: stream_url = file_link.group(1) print stream_url self._callback(stream_url) else: self.stream_not_found() def flashstream(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?'file'", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("'file','(.*?)'", sUnpacked) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def ginbig_flashstream(self, data, url): op = re.findall('<input type="hidden" name="op" value="(.*?)">', data, re.S) id = re.findall('<input type="hidden" name="id" value="(.*?)">', data, re.S) fname = re.findall('<input type="hidden" name="fname" value="(.*?)">', data, re.S) if op and id and fname: post_data = urlencode({'op': 'download1', 'usr_login': '', 'id': id[0], 'fname': fname[0], 'referer': '', 'method_free': 'Kostenloser Download' }) getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.ginbig__flashstream_data).addErrback(self.errorload) else: self.stream_not_found() def ginbig__flashstream_data(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: stream_url = re.findall("'file','(.*?)'", sUnpacked) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def monsteruploads(self, data, url): if not re.match('.*?eval\(function\(p\,a\,c\,k\,e\,d', data, re.S): id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) referer = re.findall('type="hidden" name="referer".*?value="(.*?)"', data, re.S) info = urlencode({ 'op': "download2", 'usr_login': "", 'id': id[0], 'fname': fname[0], 'referer': "", 'method_free': "Kostenloser Download" }) getPage(url, method='POST', postdata = info, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.monsteruploads_post).addErrback(self.errorload) else: get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def monsteruploads_post(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: if re.match('.*?type="video/divx', sUnpacked): stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match('.*?playlist:.*?http://www.monsteruploads.eu', sUnpacked): stream_url = re.findall("playlist:.'(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def vreer(self, data, url): id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) hash = re.findall('type="hidden" name="hash".*?value="(.*?)"', data, re.S) referer = re.findall('type="hidden" name="referer".*?value="(.*?)"', data, re.S) if id and fname and hash and referer: post_data = urlencode({'op': "download2", 'usr_login': "", 'id': id[0], 'fname': fname[0], 'hash': hash[0], 'referer': "", 'method_free': "Free Download"}) getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vreer_post).addErrback(self.errorload) else: self.stream_not_found() def vreer_post(self, data): if re.match('.*?video.flv', data, re.S): stream_url = re.findall('file:."(.*?)"', data, re.S) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() def uploadc(self, data, url): ipcount_val = re.findall('<input type="hidden" name="ipcount_val".*?value="(.*?)">', data) id = re.findall('<input type="hidden" name="id".*?value="(.*?)">', data) fname = re.findall('<input type="hidden" name="fname".*?alue="(.*?)">', data) if id and fname and ipcount_val: post_data = urllib.urlencode({'ipcount_val' : ipcount_val[0], 'op' : 'download2', 'usr_login' : '', 'id' : id[0], 'fname' : fname[0], 'method_free' : 'Slow access'}) print post_data getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.uploadc_post).addErrback(self.errorload) else: print "keine post infos gefunden." self.stream_not_found() def uploadc_post(self, data): print data stream = re.findall("'file','(.*?)'", data, re.S) get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if stream: print stream self._callback(stream[0]) elif get_packedjava: sJavascript = get_packedjava[1] print sJavascript sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print sUnpacked stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def nowvideo(self, data): file = re.findall('flashvars.file="(.*?)"', data) key = re.findall('flashvars.filekey="(.*?)"', data) if file and key: url = "http://www.nowvideo.eu/api/player.api.php?file=%s&key=%s" % (file[0], key[0]) getPage(url, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.nowvideo_xml).addErrback(self.errorload) else: self.stream_not_found() def nowvideo_xml(self, data): rapi = re.search('url=(.+?)&title=', data) if rapi: stream_url = rapi.group(1) self._callback(stream_url) else: self.stream_not_found() def xvidstream(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def movreel_data(self, data, url): id = re.findall('<input type="hidden" name="id".*?value="(.*?)">', data) fname = re.findall('<input type="hidden" name="fname".*?value="(.*?)">', data) if id and fname: post_data = urllib.urlencode({'op': 'download1', 'usr_login': '', 'id': id[0], 'fname': fname[0], 'referer': '', 'method_free': ' Kostenloser Download'}) getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.movreel_post_data, url, fname[0]).addErrback(self.errorload) else: self.stream_not_found() def movreel_post_data(self, data, url, fname): id = re.findall('<input type="hidden" name="id".*?value="(.*?)">', data) rand = re.findall('<input type="hidden" name="rand".*?value="(.*?)">', data) if id and rand: post_data = urllib.urlencode({'op': 'download2', 'usr_login': '', 'id': id[0], 'rand': rand[0], 'referer': '', 'method_free': ' Kostenloser Download'}) getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.movreel_post_data2, fname).addErrback(self.errorload) else: self.stream_not_found() def movreel_post_data2(self, data, fname): stream_url = re.findall("var file_link = '(.*?)'", data, re.S) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def filenuke(self, data, url): print "drin " id = re.findall('<input type="hidden" name="id".*?value="(.*?)">', data) fname = re.findall('<input type="hidden" name="fname".*?alue="(.*?)">', data) post_data = urllib.urlencode({'op': 'download1', 'usr_login': '', 'id': id[0], 'fname': fname[0], 'referer': '', 'method_free': 'free'}) #print post_data getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.filenuke_data).addErrback(self.errorload) def filenuke_data(self, data): print "drin2" get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def streamPutlockerSockshare(self, data, url, provider): if re.match('.*?File Does not Exist', data, re.S): message = self.session.open(MessageBox, "File Does not Exist, or Has Been Removed", MessageBox.TYPE_INFO, timeout=5) elif re.match('.*?Encoding to enable streaming is in progresss', data, re.S): message = self.session.open(MessageBox, "Encoding to enable streaming is in progresss. Try again soon.", MessageBox.TYPE_INFO, timeout=5) else: print "provider:", provider enter = re.findall('<input type="hidden" value="(.*?)" name="fuck_you">', data) print "enter:", enter values = {'fuck_you': enter[0], 'confirm': 'Close+Ad+and+Watch+as+Free+User'} user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = { 'User-Agent' : user_agent} cookiejar = cookielib.LWPCookieJar() cookiejar = urllib2.HTTPCookieProcessor(cookiejar) opener = urllib2.build_opener(cookiejar) urllib2.install_opener(opener) data = urlencode(values) req = urllib2.Request(url, data, headers) try: response = urllib2.urlopen(req) except urllib2.HTTPError, e: print e.code self.stream_not_found() except urllib2.URLError, e: print e.args self.stream_not_found() else:
class youtubeUrl(object): def __init__(self, session): global playing self.__callBack = None self.errBack = None self.session = session self.error = "" self.yt_dwnld_agent = None self.useProxy = ( config.mediaportal.sp_use_yt_with_proxy.value == 'proxy') and ( config.mediaportal.yt_proxy_host.value != 'example_proxy.com!') self.initDownloadAgent() self.tw_agent_hlp = TwAgentHelper(gzip_decoding=True, followRedirect=True, headers=headers) mp_globals.premiumize = self.useProxy playing = False def initDownloadAgent(self): self.proxyurl = None if self.useProxy: proxyhost = config.mediaportal.yt_proxy_host.value proxyport = config.mediaportal.yt_proxy_port.value self.puser = config.mediaportal.yt_proxy_username.value self.ppass = config.mediaportal.yt_proxy_password.value if '/noconnect' in proxyhost: proxyhost, option = proxyhost.split('/')[-2:] else: option = '' if not proxyhost.startswith('http'): self.proxyurl = 'http://%s:%s/%s' % (proxyhost, proxyport, option) else: self.proxyurl = '%s:%s/%s' % (proxyhost, proxyport, option) else: self.puser = None self.ppass = None self.yt_dwnld_agent = TwAgentHelper(proxy_url=self.proxyurl, p_user=self.puser, p_pass=self.ppass, gzip_decoding=True, followRedirect=True, headers=headers) def addCallback(self, cbFunc): self.__callBack = cbFunc def addErrback(self, errFunc): self.errBack = errFunc def dataError(self, error): self.error += str(error) self.errReturn() def errReturn(self, url=None): if self.errBack == None: self.session.openWithCallback(self.cbYTErr, MessageBoxExt, str(self.error), MessageBoxExt.TYPE_INFO, timeout=10) else: self.errBack(self.error) def cbYTErr(self, res): return def getVideoUrl(self, url, videoPrio=2, dash=None, fmt_map=None): dash = config.mediaportal.youtubeenabledash.value # portions of this part is from mtube plugin if not self.__callBack: self.error = '[YoutubeURL] Error: no callBack set' self.errReturn() if fmt_map != None: self.VIDEO_FMT_PRIORITY_MAP = fmt_map elif videoPrio == 0: #360p self.VIDEO_FMT_PRIORITY_MAP = { '18': 1, #MP4 360p '34': 2, #FLV 360p } elif videoPrio == 1: #480p self.VIDEO_FMT_PRIORITY_MAP = { '135': 1, #MP4 480p (DASH) '35': 2, #FLV 480p '18': 3, #MP4 360p '34': 4, #FLV 360p } elif videoPrio == 2: #720p self.VIDEO_FMT_PRIORITY_MAP = { '22': 1, #MP4 720p '135': 2, #MP4 480p (DASH) '35': 3, #FLV 480p '18': 4, #MP4 360p '34': 5, #FLV 360p } elif videoPrio == 3: #1080p self.VIDEO_FMT_PRIORITY_MAP = { '299': 3, #MP4 1080p60 (DASH) '137': 4, #MP4 1080p (DASH) '22': 5, #MP4 720p '135': 6, #MP4 480p (DASH) '35': 7, #FLV 480p '18': 8, #MP4 360p '34': 9, #FLV 360p } if config.mediaportal.youtubeenablevp9.value: self.VIDEO_FMT_PRIORITY_MAP.update({ '303': 1, #VP9 1080p60 (DASH) '248': 2, #VP9 1080p (DASH) }) elif videoPrio == 4: #1440p self.VIDEO_FMT_PRIORITY_MAP = { '299': 5, #MP4 1080p60 (DASH) '137': 6, #MP4 1080p (DASH) '22': 7, #MP4 720p '135': 8, #MP4 480p (DASH) '35': 9, #FLV 480p '18': 10, #MP4 360p '34': 11, #FLV 360p } if config.mediaportal.youtubeenablevp9.value: self.VIDEO_FMT_PRIORITY_MAP.update({ '308': 1, #VP9 1440p60 (DASH) '271': 2, #VP9 1440p (DASH) '303': 3, #VP9 1080p60 (DASH) '248': 4, #VP9 1080p (DASH) }) elif videoPrio == 5: #2160p self.VIDEO_FMT_PRIORITY_MAP = { '299': 7, #MP4 1080p60 (DASH) '137': 8, #MP4 1080p (DASH) '22': 9, #MP4 720p '135': 10, #MP4 480p (DASH) '35': 11, #FLV 480p '18': 12, #MP4 360p '34': 13, #FLV 360p } if config.mediaportal.youtubeenablevp9.value: self.VIDEO_FMT_PRIORITY_MAP.update({ '315': 1, #VP9 2160p60 (DASH) '313': 2, #VP9 2160p (DASH) '308': 3, #VP9 1440p60 (DASH) '271': 4, #VP9 1440p (DASH) '303': 5, #VP9 1080p60 (DASH) '248': 6, #VP9 1080p (DASH) }) self.AUDIO_FMT_PRIORITY_MAP = { '258': 1, #AAC '256': 2, #AAC '141': 3, #AAC ABR256 '140': 4, #AAC ABR128 '139': 5, #AAC ABR48 '172': 6, #VORBIS 256 '171': 7, #VORBIS 128 } self.video_url = None self.audio_url = None self.video_id = url self.videoPrio = videoPrio self.dash = dash # Getting video webpage #URLs for YouTube video pages will change from the format #http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0. watch_url = 'https://www.youtube.com/watch?v=%s&gl=US&hl=en&has_verified=1&bpctr=9999999999' % self.video_id self.error = "[YoutubeURL] Error: Unable to retrieve watchpage:\n%s\n" % watch_url self.yt_dwnld_agent.getWebPage(watch_url).addCallback( self.parseVInfo, watch_url).addErrback(self.dataError) def parseVInfo(self, videoinfo, watch_url): flashvars = self.extractFlashVars(videoinfo, 0) if not flashvars.has_key(u"url_encoded_fmt_stream_map"): self.checkFlashvars(flashvars, videoinfo, True) else: links = {} audio = {} encoded_url_map = "" if self.dash: try: encoded_url_map += u"," + flashvars.get( 'adaptive_fmts', []) except: pass encoded_url_map += u"," + flashvars[u"url_encoded_fmt_stream_map"] for url_desc in encoded_url_map.split(u","): url_desc_map = parse_qs(url_desc) if not (url_desc_map.has_key(u"url") or url_desc_map.has_key(u"stream")): continue try: key = int(url_desc_map[u"itag"][0]) except ValueError: continue url = u"" if url_desc_map.has_key(u"url"): url = urllib.unquote(url_desc_map[u"url"][0]) elif url_desc_map.has_key(u"conn") and url_desc_map.has_key( u"stream"): url = urllib.unquote(url_desc_map[u"conn"][0]) if url.rfind("/") < len(url) - 1: url = url + "/" url = url + urllib.unquote(url_desc_map[u"stream"][0]) elif url_desc_map.has_key( u"stream") and not url_desc_map.has_key(u"conn"): url = urllib.unquote(url_desc_map[u"stream"][0]) if url_desc_map.has_key(u"sig"): url = url + u"&signature=" + url_desc_map[u"sig"][0] elif url_desc_map.has_key(u"s"): sig = url_desc_map[u"s"][0] flashvars = self.extractFlashVars(videoinfo, 1) signature = decryptor.decryptSignature( sig, flashvars[u"js"]) if not signature: self.error = "[YoutubeURL] Error: cannot decrypt url" self.errReturn(None) return else: url += u"&signature=" + signature try: links[self.VIDEO_FMT_PRIORITY_MAP[str(key)]] = url except KeyError: try: audio[self.AUDIO_FMT_PRIORITY_MAP[str(key)]] = url except KeyError: continue url = flashvars.get('hlsvp', '') if url: links = {} links[0] = url #print "#####################################################################################" #try: # for i in links: # type = re.search('.*?itag=(\d+)', links[i]).group(1) # print type + "\t" + links[i] #except: # pass #print "#####################################################################################" try: self.video_url = links[sorted( links.iterkeys())[0]].encode('utf-8') try: if int( re.search('.*?itag=(\d+)', self.video_url).group(1)) > 100: self.audio_url = audio[sorted( audio.iterkeys())[0]].encode('utf-8') #print "#####################################################################################" #for i in audio: # type = re.search('.*?itag=(\d+)', audio[i]).group(1) # print type + "\t" + audio[i] #print "#####################################################################################" except: pass #self.__callBack(self.video_url) self.callBack(self.video_url, self.audio_url) except (KeyError, IndexError): self.error = "[YoutubeURL] Error: no video url found" self.errReturn(self.video_url) def parseVInfo2(self, videoinfo): flashvars = parse_qs(videoinfo) if not flashvars.has_key(u"url_encoded_fmt_stream_map"): if 'hlsvp=' in videoinfo: url = urllib.unquote( re.search('hlsvp=(.*?\.m3u8)', videoinfo).group(1)) self.__callBack(url) else: self.checkFlashvars(flashvars, videoinfo) else: video_fmt_map = {} fmt_infomap = {} tmp_fmtUrlDATA = flashvars['url_encoded_fmt_stream_map'][0].split( ',') for fmtstring in tmp_fmtUrlDATA: fmturl = fmtid = fmtsig = "" if flashvars.has_key('url_encoded_fmt_stream_map'): try: for arg in fmtstring.split('&'): if arg.find('=') >= 0: key, value = arg.split('=') if key == 'itag': if len(value) > 3: value = value[:2] fmtid = value elif key == 'url': fmturl = value elif key == 'sig': fmtsig = value if fmtid != "" and fmturl != "" and self.VIDEO_FMT_PRIORITY_MAP.has_key( fmtid): video_fmt_map[ self.VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl), 'fmtsig': fmtsig } fmt_infomap[int(fmtid)] = "%s&signature=%s" % ( unquote_plus(fmturl), fmtsig) fmturl = fmtid = fmtsig = "" except: self.error = "[YoutubeURL] Error parsing fmtstring: %s" % fmtstring self.errReturn(self.video_url) return else: (fmtid, fmturl) = fmtstring.split('|') if self.VIDEO_FMT_PRIORITY_MAP.has_key(fmtid) and fmtid != "": video_fmt_map[self.VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl) } fmt_infomap[int(fmtid)] = unquote_plus(fmturl) if video_fmt_map and len(video_fmt_map): best_video = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]] if best_video['fmtsig']: self.video_url = "%s&signature=%s" % ( best_video['fmturl'].split(';')[0], best_video['fmtsig']) else: self.video_url = "%s" % ( best_video['fmturl'].split(';')[0]) #self.__callBack(self.video_url) self.callBack(self.video_url) else: self.error = "[YoutubeURL] Error: no video url found" self.errReturn(self.video_url) def checkFlashvars(self, flashvars, videoinfo, get_info2=False): # Attempt to see if YouTube has issued an error message if not flashvars.has_key(u"reason"): from imports import decodeHtml pc = False if 'ypc-offer-title' in videoinfo: msg = re.search('ypc-offer-title">.*?<a.*?">(.*?)</a', videoinfo, re.S) if msg: pc = True self.error = '[YoutubeURL] Error: Paid Content' self.error += '\n: "%s"' % msg.group(1) elif 'itemprop="paid" content="True"' in videoinfo: msg = re.search('dir="ltr" title="(.*?)"', videoinfo, re.S) if msg: pc = True self.error = '[YoutubeURL] Error: Paid Content' self.error += ':\n"%s"' % decodeHtml(msg.group(1)) msg = re.search('class="message">(.*?)</', videoinfo, re.S) if msg: txt = msg.group(1).strip() msg = re.search('class="submessage">(.*?)</', videoinfo, re.S) if msg: txt += '\n' + msg.group(1).strip() if not pc: self.error = '[YoutubeURL] Error: %s' % decodeHtml(txt) else: self.error += txt elif not pc: self.error = '[YoutubeURL] Error: unable to extract "url_encoded_fmt_stream_map" parameter for unknown reason' if not pc and get_info2 and 'og:restrictions:age' in videoinfo: el = '&el=embedded' info_url = ( 'https://www.youtube.com/get_video_info?video_id=%s%s&ps=default&eurl=&gl=US&hl=en' % (self.video_id, el)) self.error = "[YoutubeURL] Error: Unable to retrieve videoinfo page:\n%s\n" % info_url self.yt_dwnld_agent.getWebPage(info_url).addCallback( self.parseVInfo2).addErrback(self.dataError) return else: from imports import stripAllTags reason = unquote_plus(flashvars['reason'][0]) self.error = '[YoutubeURL] Error: YouTube said: %s' % stripAllTags( str(reason)) self.errReturn(self.video_url) def removeAdditionalEndingDelimiter(self, data): pos = data.find("};") if pos != -1: data = data[:pos + 1] return data def normalizeUrl(self, url): if url[0:2] == "//": url = "https:" + url return url def extractFlashVars(self, data, assets): flashvars = {} found = False for line in data.split("\n"): if line.strip().find(";ytplayer.config = ") > 0: found = True p1 = line.find(";ytplayer.config = ") + len( ";ytplayer.config = ") - 1 p2 = line.rfind(";") if p1 <= 0 or p2 <= 0: continue data = line[p1 + 1:p2] break data = self.removeAdditionalEndingDelimiter(data) if found: data = json.loads(data) if assets: flashvars = data["assets"] else: flashvars = data["args"] for k in ["html", "css", "js"]: if k in flashvars: flashvars[k] = self.normalizeUrl(flashvars[k]) return flashvars def callBack(self, url, suburi=None): if suburi and not '.m3u8' in url: self.__callBack(url, suburi=suburi) elif url.startswith('http') and not '.m3u8' in url: self.error = '[YoutubeURL] Playback error:' try: return self.tw_agent_hlp.getRedirectedUrl( url, True).addCallback(self.getRedirect, url).addErrback(self.dataError) except: self.__callBack(url) else: self.yt_dwnld_agent.getWebPage(url).addCallback( self.parseM3U8Playlist).addErrback(self.dataError) def parseM3U8Playlist(self, data): bandwith_list = [] match_sec_m3u8 = re.findall('BANDWIDTH=(\d+).*?\n(.*?m3u8)', data, re.S) videoPrio = int(config.mediaportal.youtubeprio.value) if videoPrio >= 3: bw = int(match_sec_m3u8[-1][0]) elif videoPrio == 2: bw = int(match_sec_m3u8[-1][0]) / 2 elif videoPrio == 1: bw = int(match_sec_m3u8[-1][0]) / 3 else: bw = int(match_sec_m3u8[-1][0]) / 4 for each in match_sec_m3u8: bandwith, url = each bandwith_list.append((int(bandwith), url)) _, best = min((abs(int(x[0]) - bw), x) for x in bandwith_list) url = best[1] url = url.replace('%2F', '%252F').replace('%3D', '%253D').replace( '%2B', '%252B').replace('%3B', '%253B') self.__callBack(url) def getRedirect(self, redir_url, url): if 'Forbidden' in redir_url: if self.useProxy: self.__callBack(url, buffering=True, proxy=(self.proxyurl, self.puser, self.ppass)) else: self.dataError(redir_url) else: self.__callBack(url)
class youtubeUrl(object): def __init__(self, session): global playing self.__callBack = None self.errBack = None self.session = session self.error = "" self.yt_dwnld_agent = None self.useProxy = (config.mediaportal.sp_use_yt_with_proxy.value == 'proxy') and (config.mediaportal.yt_proxy_host.value != 'example_proxy.com!') self.initDownloadAgent() self.tw_agent_hlp = TwAgentHelper(gzip_decoding=True, followRedirect=True, headers=headers) mp_globals.premiumize = self.useProxy playing = False def initDownloadAgent(self): self.proxyurl = None if self.useProxy: proxyhost = config.mediaportal.yt_proxy_host.value proxyport = config.mediaportal.yt_proxy_port.value self.puser = config.mediaportal.yt_proxy_username.value self.ppass = config.mediaportal.yt_proxy_password.value if '/noconnect' in proxyhost: proxyhost, option = proxyhost.split('/')[-2:] else: option = '' if not proxyhost.startswith('http'): self.proxyurl = 'http://%s:%s/%s' % (proxyhost, proxyport, option) else: self.proxyurl = '%s:%s/%s' % (proxyhost, proxyport, option) else: self.puser = None self.ppass = None self.yt_dwnld_agent = TwAgentHelper(proxy_url=self.proxyurl, p_user=self.puser, p_pass=self.ppass, gzip_decoding=True, followRedirect=True, headers=headers) def addCallback(self, cbFunc): self.__callBack = cbFunc def addErrback(self, errFunc): self.errBack = errFunc def dataError(self, error): self.error += str(error) self.errReturn() def errReturn(self, url=None): if self.errBack == None: self.session.openWithCallback(self.cbYTErr, MessageBoxExt,str(self.error), MessageBoxExt.TYPE_INFO, timeout=10) else: self.errBack(self.error) def cbYTErr(self, res): return def getVideoUrl(self, url, videoPrio=2, dash=False, fmt_map=None): # portions of this part is from mtube plugin if not self.__callBack: self.error = '[YoutubeURL] Error: no callBack set' self.errReturn() if fmt_map != None: self.VIDEO_FMT_PRIORITY_MAP = fmt_map elif videoPrio == 0: self.VIDEO_FMT_PRIORITY_MAP = { '38' : 5, #MP4 Original (HD) '37' : 5, #MP4 1080p (HD) '22' : 4, #MP4 720p (HD) '35' : 2, #FLV 480p '18' : 1, #MP4 360p '34' : 3, #FLV 360p } elif videoPrio == 1: self.VIDEO_FMT_PRIORITY_MAP = { '38' : 5, #MP4 Original (HD) '37' : 5, #MP4 1080p (HD) '22' : 4, #MP4 720p (HD) '35' : 1, #FLV 480p '18' : 2, #MP4 360p '34' : 3, #FLV 360p } else: self.VIDEO_FMT_PRIORITY_MAP = { '38' : 2, #MP4 Original (HD) '37' : 1, #MP4 1080p (HD) '22' : 1, #MP4 720p (HD) '35' : 3, #FLV 480p '18' : 4, #MP4 360p '34' : 5, #FLV 360p } self.video_url = None self.video_id = url self.videoPrio = videoPrio self.dash = dash # Getting video webpage #URLs for YouTube video pages will change from the format #http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0. watch_url = 'https://www.youtube.com/watch?v=%s&gl=US&hl=en&has_verified=1&bpctr=9999999999' % self.video_id self.error = "[YoutubeURL] Error: Unable to retrieve watchpage:\n%s\n" % watch_url self.yt_dwnld_agent.getWebPage(watch_url).addCallback(self.parseVInfo, watch_url).addErrback(self.dataError) def parseVInfo(self, videoinfo, watch_url): flashvars = self.extractFlashVars(videoinfo, 0) if not flashvars.has_key(u"url_encoded_fmt_stream_map"): self.checkFlashvars(flashvars, videoinfo, True) else: links = {} encoded_url_map = flashvars[u"url_encoded_fmt_stream_map"] if self.dash: encoded_url_map += flashvars.get('adaptive_fmts', []) for url_desc in encoded_url_map.split(u","): url_desc_map = parse_qs(url_desc) if not (url_desc_map.has_key(u"url") or url_desc_map.has_key(u"stream")): continue try: key = int(url_desc_map[u"itag"][0]) except ValueError: continue url = u"" if url_desc_map.has_key(u"url"): url = urllib.unquote(url_desc_map[u"url"][0]) elif url_desc_map.has_key(u"conn") and url_desc_map.has_key(u"stream"): url = urllib.unquote(url_desc_map[u"conn"][0]) if url.rfind("/") < len(url) -1: url = url + "/" url = url + urllib.unquote(url_desc_map[u"stream"][0]) elif url_desc_map.has_key(u"stream") and not url_desc_map.has_key(u"conn"): url = urllib.unquote(url_desc_map[u"stream"][0]) if url_desc_map.has_key(u"sig"): url = url + u"&signature=" + url_desc_map[u"sig"][0] elif url_desc_map.has_key(u"s"): sig = url_desc_map[u"s"][0] flashvars = self.extractFlashVars(videoinfo, 1) if isVEVODecryptor: signature = decryptor.decryptSignature(sig, flashvars[u"js"]) else: signature = None if not signature: self.error = "[YoutubeURL] Error: cannot decrypt url" self.errReturn(None) return else: url += u"&signature=" + signature try: links[self.VIDEO_FMT_PRIORITY_MAP[str(key)]] = url except KeyError: continue if not links: url = flashvars.get('hlsvp','') if url: links[0] = url try: self.video_url = links[sorted(links.iterkeys())[0]].encode('utf-8') #self.__callBack(self.video_url) self.callBack(self.video_url) except (KeyError,IndexError): self.error = "[YoutubeURL] Error: no video url found" self.errReturn(self.video_url) def parseVInfo2(self, videoinfo): flashvars = parse_qs(videoinfo) if not flashvars.has_key(u"url_encoded_fmt_stream_map"): if 'hlsvp=' in videoinfo: url = urllib.unquote(re.search('hlsvp=(.*?\.m3u8)', videoinfo).group(1)) self.__callBack(url) else: self.checkFlashvars(flashvars, videoinfo) else: video_fmt_map = {} fmt_infomap = {} tmp_fmtUrlDATA = flashvars['url_encoded_fmt_stream_map'][0].split(',') for fmtstring in tmp_fmtUrlDATA: fmturl = fmtid = fmtsig = "" if flashvars.has_key('url_encoded_fmt_stream_map'): try: for arg in fmtstring.split('&'): if arg.find('=') >= 0: key, value = arg.split('=') if key == 'itag': if len(value) > 3: value = value[:2] fmtid = value elif key == 'url': fmturl = value elif key == 'sig': fmtsig = value if fmtid != "" and fmturl != "" and self.VIDEO_FMT_PRIORITY_MAP.has_key(fmtid): video_fmt_map[self.VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl), 'fmtsig': fmtsig } fmt_infomap[int(fmtid)] = "%s&signature=%s" %(unquote_plus(fmturl), fmtsig) fmturl = fmtid = fmtsig = "" except: self.error = "[YoutubeURL] Error parsing fmtstring: %s" % fmtstring self.errReturn(self.video_url) return else: (fmtid,fmturl) = fmtstring.split('|') if self.VIDEO_FMT_PRIORITY_MAP.has_key(fmtid) and fmtid != "": video_fmt_map[self.VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl) } fmt_infomap[int(fmtid)] = unquote_plus(fmturl) if video_fmt_map and len(video_fmt_map): best_video = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]] if best_video['fmtsig']: self.video_url = "%s&signature=%s" %(best_video['fmturl'].split(';')[0], best_video['fmtsig']) else: self.video_url = "%s" %(best_video['fmturl'].split(';')[0]) #self.__callBack(self.video_url) self.callBack(self.video_url) else: self.error = "[YoutubeURL] Error: no video url found" self.errReturn(self.video_url) def checkFlashvars(self, flashvars, videoinfo, get_info2=False): # Attempt to see if YouTube has issued an error message if not flashvars.has_key(u"reason"): from imports import decodeHtml pc = False if 'ypc-offer-title' in videoinfo: msg = re.search('ypc-offer-title">.*?<a.*?">(.*?)</a', videoinfo, re.S) if msg: pc = True self.error = '[YoutubeURL] Error: Paid Content' self.error += '\n: "%s"' % msg.group(1) elif 'itemprop="paid" content="True"' in videoinfo: msg = re.search('dir="ltr" title="(.*?)"', videoinfo, re.S) if msg: pc = True self.error = '[YoutubeURL] Error: Paid Content' self.error += ':\n"%s"' % decodeHtml(msg.group(1)) msg = re.search('class="message">(.*?)</', videoinfo, re.S) if msg: txt = msg.group(1).strip() msg = re.search('class="submessage">(.*?)</', videoinfo, re.S) if msg: txt += '\n' + msg.group(1).strip() if not pc: self.error = '[YoutubeURL] Error: %s' % txt else: self.error += txt elif not pc: self.error = '[YoutubeURL] Error: unable to extract "url_encoded_fmt_stream_map" parameter for unknown reason' if not pc and get_info2 and 'og:restrictions:age' in videoinfo: el = '&el=embedded' info_url = ('https://www.youtube.com/get_video_info?video_id=%s%s&ps=default&eurl=&gl=US&hl=en' % (self.video_id, el)) self.error = "[YoutubeURL] Error: Unable to retrieve videoinfo page:\n%s\n" % info_url self.yt_dwnld_agent.getWebPage(info_url).addCallback(self.parseVInfo2).addErrback(self.dataError) return else: from imports import stripAllTags reason = unquote_plus(flashvars['reason'][0]) self.error = '[YoutubeURL] Error: YouTube said: %s' % stripAllTags(str(reason)) self.errReturn(self.video_url) def removeAdditionalEndingDelimiter(self, data): pos = data.find("};") if pos != -1: data = data[:pos + 1] return data def normalizeUrl(self, url): if url[0:2] == "//": url = "https:" + url return url def extractFlashVars(self, data, assets): flashvars = {} found = False for line in data.split("\n"): if line.strip().find(";ytplayer.config = ") > 0: found = True p1 = line.find(";ytplayer.config = ") + len(";ytplayer.config = ") - 1 p2 = line.rfind(";") if p1 <= 0 or p2 <= 0: continue data = line[p1 + 1:p2] break data = self.removeAdditionalEndingDelimiter(data) if found: data = json.loads(data) if assets: flashvars = data["assets"] else: flashvars = data["args"] for k in ["html", "css", "js"]: if k in flashvars: flashvars[k] = self.normalizeUrl(flashvars[k]) return flashvars def callBack(self, url): if url.startswith('http') and not '.m3u8' in url: self.error = '[YoutubeURL] Playback error:' return self.tw_agent_hlp.getRedirectedUrl(url, True).addCallback(self.getRedirect, url).addErrback(self.dataError) else: self.__callBack(url) def getRedirect(self, redir_url, url): if 'Forbidden' in redir_url: if self.useProxy: self.__callBack(url, buffering=True, proxy=(self.proxyurl, self.puser, self.ppass)) else: self.dataError(redir_url) else: self.__callBack(url)
class youtubeUrl: def __init__(self, session): self.callBack = None self.errBack = None self.session = session self.error = "" self.useProxy = False puser = "******" ppass = "******" self.yt_tw_agent_hlp = TwAgentHelper(use_proxy=self.useProxy, p_user=puser, p_pass=ppass, use_cookies=True) mp_globals.proxy = self.useProxy def addCallback(self, cbFunc): self.callBack = cbFunc def addErrback(self, errFunc): self.errBack = errFunc def dataError(self, error): self.error = self.error % str(error) self.errReturn() def errReturn(self, url=None): del self.yt_tw_agent_hlp if self.errBack == None: self.session.openWithCallback(self.cbYTErr, MessageBox,str(self.error), MessageBox.TYPE_INFO, timeout=10) else: self.errBack(self.error) def cbYTErr(self, res): return def getVideoUrl(self, url, videoPrio=2): # this part is from mtube plugin if not self.callBack: self.error = '[YoutubeURL] Error: no callBack set' self.errReturn() if videoPrio == 0: self.VIDEO_FMT_PRIORITY_MAP = { '38' : 5, #MP4 Original (HD) # '37' : 5, #MP4 1080p (HD) '22' : 4, #MP4 720p (HD) '35' : 2, #FLV 480p '18' : 1, #MP4 360p '34' : 3, #FLV 360p } elif videoPrio == 1: self.VIDEO_FMT_PRIORITY_MAP = { '38' : 5, #MP4 Original (HD) # '37' : 5, #MP4 1080p (HD) '22' : 4, #MP4 720p (HD) '35' : 1, #FLV 480p '18' : 2, #MP4 360p '34' : 3, #FLV 360p } else: self.VIDEO_FMT_PRIORITY_MAP = { '38' : 2, #MP4 Original (HD) # '37' : 1, #MP4 1080p (HD) '22' : 1, #MP4 720p (HD) '35' : 3, #FLV 480p '18' : 4, #MP4 360p '34' : 5, #FLV 360p } self.video_url = None self.video_id = url self.videoPrio = videoPrio # Getting video webpage #URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0. watch_url = 'http://www.youtube.com/watch?v=%s&safeSearch=none'%self.video_id self.error = "[YoutubeURL] Error: Unable to retrieve watchpage:\n%s" self.yt_tw_agent_hlp.getWebPage(self.parseVInfo, self.dataError, watch_url, False) def parseVInfo(self, videoinfo): flashvars = self.extractFlashVars(videoinfo, 0) if not flashvars.has_key(u"url_encoded_fmt_stream_map"): # Attempt to see if YouTube has issued an error message if 'reason' not in flashvars: pc = False if 'ypc-offer-title' in videoinfo: pc = True msg = re.search('ypc-offer-title">.*?<a.*?">(.*?)</a', videoinfo, re.S) self.error = '[YoutubeURL] Error: Paid Content' if msg: self.error += ': "%s"' % msg.group(1) else: msg = re.search('class="message">(.*?)</', videoinfo, re.S) if msg: self.error = '[YoutubeURL] Error: %s' % msg.group(1).strip() else: self.error = '[YoutubeURL] Error: unable to extract "url_encoded_fmt_stream_map" parameter for unknown reason' if not pc and 'og:restrictions:age' in videoinfo: el = '&el=embedded' info_url = ('http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en' % (self.video_id, el)) self.error = "[YoutubeURL] Error: Unable to retrieve videoinfo page:\n%s" self.yt_tw_agent_hlp.getWebPage(self.parseVInfo2, self.dataError, info_url, False) return else: reason = unquote_plus(videoinfo['reason'][0]) self.error = '[YoutubeURL] Error: YouTube said: %s' % reason.decode('utf-8') self.errReturn(self.video_url) else: links = {} for url_desc in flashvars[u"url_encoded_fmt_stream_map"].split(u","): url_desc_map = parse_qs(url_desc) if not (url_desc_map.has_key(u"url") or url_desc_map.has_key(u"stream")): continue key = int(url_desc_map[u"itag"][0]) url = u"" if url_desc_map.has_key(u"url"): url = urllib.unquote(url_desc_map[u"url"][0]) elif url_desc_map.has_key(u"conn") and url_desc_map.has_key(u"stream"): url = urllib.unquote(url_desc_map[u"conn"][0]) if url.rfind("/") < len(url) -1: url = url + "/" url = url + urllib.unquote(url_desc_map[u"stream"][0]) elif url_desc_map.has_key(u"stream") and not url_desc_map.has_key(u"conn"): url = urllib.unquote(url_desc_map[u"stream"][0]) if url_desc_map.has_key(u"sig"): url = url + u"&signature=" + url_desc_map[u"sig"][0] elif url_desc_map.has_key(u"s"): sig = url_desc_map[u"s"][0] flashvars = self.extractFlashVars(videoinfo, 1) js = flashvars[u"js"] url = url + u"&signature=" + decryptor.decryptSignature(sig, js) try: links[self.VIDEO_FMT_PRIORITY_MAP[str(key)]] = url except KeyError: print 'skipping',key,'fmt not in priority videos' continue try: self.video_url = links[sorted(links.iterkeys())[0]].encode('utf-8') del self.yt_tw_agent_hlp self.callBack(self.video_url) except (KeyError,IndexError): self.error = "[YoutubeURL] Error: no video url found" self.errReturn(self.video_url) def parseVInfo2(self, videoinfo): videoinfo = parse_qs(videoinfo) if not videoinfo.has_key(u"url_encoded_fmt_stream_map"): self.error = '[YoutubeURL] Error: unable to extract "url_encoded_fmt_stream_map" parameter for unknown reason' self.errReturn(self.video_url) else: video_fmt_map = {} fmt_infomap = {} tmp_fmtUrlDATA = videoinfo['url_encoded_fmt_stream_map'][0].split(',') for fmtstring in tmp_fmtUrlDATA: fmturl = fmtid = fmtsig = "" if videoinfo.has_key('url_encoded_fmt_stream_map'): try: for arg in fmtstring.split('&'): if arg.find('=') >= 0: key, value = arg.split('=') if key == 'itag': if len(value) > 3: value = value[:2] fmtid = value elif key == 'url': fmturl = value elif key == 'sig': fmtsig = value if fmtid != "" and fmturl != "" and self.VIDEO_FMT_PRIORITY_MAP.has_key(fmtid): video_fmt_map[self.VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl), 'fmtsig': fmtsig } fmt_infomap[int(fmtid)] = "%s&signature=%s" %(unquote_plus(fmturl), fmtsig) fmturl = fmtid = fmtsig = "" except: self.error = "[YoutubeURL] Error parsing fmtstring: %s" % fmtstring self.errReturn(self.video_url) return else: (fmtid,fmturl) = fmtstring.split('|') if self.VIDEO_FMT_PRIORITY_MAP.has_key(fmtid) and fmtid != "": video_fmt_map[self.VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl) } fmt_infomap[int(fmtid)] = unquote_plus(fmturl) if video_fmt_map and len(video_fmt_map): print "[youtubeUrl] found best available video format:",video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmtid'] best_video = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]] if best_video['fmtsig']: self.video_url = "%s&signature=%s" %(best_video['fmturl'].split(';')[0], best_video['fmtsig']) else: self.video_url = "%s" %(best_video['fmturl'].split(';')[0]) del self.yt_tw_agent_hlp self.callBack(self.video_url) else: self.error = "[YoutubeURL] Error: no video url found" self.errReturn(self.video_url) def removeAdditionalEndingDelimiter(self, data): pos = data.find("};") if pos != -1: data = data[:pos + 1] return data def extractFlashVars(self, data, assets): flashvars = {} found = False for line in data.split("\n"): if line.strip().find(";ytplayer.config = ") > 0: found = True p1 = line.find(";ytplayer.config = ") + len(";ytplayer.config = ") - 1 p2 = line.rfind(";") if p1 <= 0 or p2 <= 0: continue data = line[p1 + 1:p2] break data = self.removeAdditionalEndingDelimiter(data) if found: data = json.loads(data) if assets: flashvars = data["assets"] else: flashvars = data["args"] return flashvars
class get_stream_link: def __init__(self, session): self._callback = None self.session = session self.showmsgbox = True self.tw_agent_hlp = TwAgentHelper() def check_link(self, data, got_link, showmsgbox=True): print "check_link" self._callback = got_link self.showmsgbox = showmsgbox if data: if re.match(".*?http://www.putlocker.com/(file|embed)/", data, re.S): link = data.replace('file','embed') #print "ok:", link if link: getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.streamPutlockerSockshare, link, "putlocker").addErrback(self.errorload) elif re.match(".*?http://www.sockshare.com/(file|embed)/", data, re.S): link = data.replace('file','embed') #print link if link: getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.streamPutlockerSockshare, link, "sockshare").addErrback(self.errorload) elif re.match(".*?http://streamcloud.eu/", data, re.S): #link = re.findall("(http://streamcloud.eu/.*?)'", data, re.S) link = data if link: getPage(link, cookies=ck, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.streamcloud).addErrback(self.errorload) elif re.match('.*?http://xvidstage.com', data, re.S): link = data #print "xvidstage" getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.xvidstage_post, link).addErrback(self.errorload) elif re.match('.*?http://filenuke.com', data, re.S): link = data getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.filenuke, link).addErrback(self.errorload) elif re.match('.*?http://movreel.com/', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.movreel_data, link).addErrback(self.errorload) elif re.match('.*?http://xvidstream.net/', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.xvidstream).addErrback(self.errorload) elif re.match('.*?http://(www|embed).nowvideo.eu', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.nowvideo).addErrback(self.errorload) elif re.match('.*?http://www.uploadc.com', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.uploadc, link).addErrback(self.errorload) elif re.match('.*?http://vreer.com', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vreer, link).addErrback(self.errorload) elif re.match('.*?http://www.monsteruploads.eu', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.monsteruploads, link).addErrback(self.errorload) elif re.match('.*?flashstream.in', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.flashstream).addErrback(self.errorload) elif re.match('.*?ginbig.com', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.ginbig_flashstream, link).addErrback(self.errorload) elif re.match('.*?videoweed.es', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.videoweed).addErrback(self.errorload) elif re.match('.*?novamov.com', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.novamov).addErrback(self.errorload) elif re.match('.*?.movshare.net', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.movshare, link).addErrback(self.errorload) elif re.match('.*divxstage', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.divxstage).addErrback(self.errorload) elif re.match('.*?yesload.net', data, re.S): link = data #print link id = link.split('/') id = id[-1] if id: #print id api_url = "http://yesload.net/player_api/info?token=%s" % id getPage(api_url, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.yesload).addErrback(self.errorload) else: self.stream_not_found() elif re.match('.*?faststream', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.faststream, link).addErrback(self.errorload) elif re.match('.*?primeshare', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.primeshare, link).addErrback(self.errorload) elif re.match('.*?http://vidstream.us', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vidstream_us).addErrback(self.errorload) elif re.match('.*?http://vidstream.in', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vidstream_in, link).addErrback(self.errorload) elif re.match('.*?video.istream.ws/embed', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.check_istream_link).addErrback(self.errorload) elif re.match('.*?http:/.*?flashx.tv', data, re.S): #elif re.match('.*?http:/disabled', data, re.S): link = data #print link hash = re.findall('http://flashx.tv/video/(.*?)/', link) if hash: getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.flashx_tv3b).addErrback(self.errorload) elif re.match('.*?embed.php\?hash=', link) or re.match('.*?embed_player.php\?hash=', link) or re.match('.*?embed_player.php\?vid=', link) or re.match('.*?embed.php\?vid=', link): self.flashx_tv3(link) elif re.match('.*?player/fxtv.php.hash=', link): """ req = urllib2.Request(link) try: res = urllib2.urlopen(req) except urllib2.HTTPError, e: print e.code self.stream_not_found() else: r_url = res.geturl() print "Redir: ", r_url if r_url != link: self.check_link(r_url, self._callback, False) else: self.flashx_tv3(link) """ self.tw_agent_hlp.getRedirectedUrl(self.check_link, self.stream_not_found, link, self._callback, False) else: print "flashx_tv link not found: ",link self.stream_not_found() elif re.match('.*?putme.org', data, re.S): link = data #print link getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.putme_org, link).addErrback(self.errorload) elif re.match('.*?divxmov.net', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.divxmov).addErrback(self.errorload) elif re.match('.*?sharesix.com/', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.sharesix).addErrback(self.errorload) elif re.match('.*?zooupload.com/', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.zooupload).addErrback(self.errorload) elif re.match('.*?http://wupfile.com', data, re.S): link = data print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.wupfile_post, link).addErrback(self.errorload) elif re.match('.*?http://bitshare.com', data, re.S): link = data #print link getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.bitshare).addErrback(self.errorload) elif re.match('.*?userporn.com', data, re.S): link = data #print link self.userporn_tv(link) elif re.match('.*?ecostream.tv', data, re.S): link = data getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.eco_read).addErrback(self.errorload) elif re.match('.*?http://played.to', data, re.S): link = data getPage(link, cookies=cj, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.played, link).addErrback(self.errorload) elif re.match('.*?stream2k.com', data, re.S): link = data getPage(link, headers={'referer':link}).addCallback(self.stream2k).addErrback(self.errorload) elif re.match('.*?limevideo.net', data, re.S): link = data getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.lmv, link).addErrback(self.errorload) elif re.match('.*?videomega.tv', data, re.S): link = data if re.match('.*?iframe.php', link): getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.videomega).addErrback(self.errorload) else: id = link.split('ref=') if id: link = "http://videomega.tv/iframe.php?ref=%s" % id[1] getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.videomega).addErrback(self.errorload) else: self.stream_not_found() elif re.match('.*?vk.com', data, re.S): link = data getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vkme).addErrback(self.errorload) elif re.match('.*?mightyupload.com/embed', data, re.S): link = data getPage(link, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.mightyupload).addErrback(self.errorload) elif re.match('.*?mightyupload.com', data, re.S): link = data id = link.split('/') url = "http://www.mightyupload.com/embed-%s.html" % id[3] print url getPage(url, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.mightyupload).addErrback(self.errorload) elif re.match('.*?http://youwatch.org', data, re.S): link = data id = link.split('org/') url = "http://youwatch.org/embed-%s.html" % id[1] getPage(url, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.youwatch).addErrback(self.errorload) else: message = self.session.open(MessageBox, _("No supported Stream Hoster, try another one !"), MessageBox.TYPE_INFO, timeout=5) else: print "Invalid link",link if self.showmsgbox: message = self.session.open(MessageBox, _("Invalid Stream link, try another Stream Hoster !"), MessageBox.TYPE_INFO, timeout=5) def stream_not_found(self): self._callback(None) print "stream_not_found!" if self.showmsgbox: message = self.session.open(MessageBox, _("Stream not found, try another Stream Hoster."), MessageBox.TYPE_INFO, timeout=5) def youwatch(self, data): stream_url = re.findall('file: "(.*?)"', data, re.S) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() def mightyupload(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def vkme(self, data): print "vk.me.." stream_urls = re.findall('url[0-9]+=(http://.*?.vk.me/.*?/videos/.*?[0-9]+.mp4)', data) if stream_urls: print stream_urls stream_url = stream_urls[-1] print stream_url self._callback(stream_url) else: self.stream_not_found() def videomega(self, data): unescape = re.findall('unescape."(.*?)"', data, re.S) if unescape: javadata = urllib2.unquote(unescape[0]) if javadata: stream_url = re.findall('file: "(.*?)"', javadata, re.S) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def lmv(self, data, url): dataPost = {} r = re.findall('input type="hidden".*?name="(.*?)".*?value="(.*?)"', data, re.S) for name, value in r: dataPost[name] = value dataPost.update({'method_free':'Continue to Video'}) print dataPost getPage(url, method='POST', postdata=urlencode(dataPost), headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.lmv2, url).addErrback(self.errorload) def lmv2(self, data, url): dataPost = {} r = re.findall('input type="hidden".*?name="(.*?)".*?value="(.*?)"', data, re.S) for name, value in r: dataPost[name] = value dataPost.update({'method_free':'Continue to Video'}) print dataPost getPage(url, method='POST', postdata=urlencode(dataPost), headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.lmvPlay).addErrback(self.errorload) def lmvPlay(self, data): print data get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[0] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def stream2k(self, data): file = re.findall("file: '(.*?)'", data, re.S) if file: self._callback(file[0]) else: self.stream_not_found() def played(self, data, url): print "hole daten" op = re.findall('type="hidden" name="op".*?value="(.*?)"', data, re.S) id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) referer = re.findall('type="hidden" name="referer".*?value="(.*?)"', data, re.S) hash = re.findall('type="hidden" name="hash".*?value="(.*?)"', data, re.S) if op and id and fname and referer: info = urlencode({ 'fname': fname[0], 'id': id[0], 'imhuman': "Continue to Video", 'op': "download1", 'referer': "", 'hash': hash[0], 'usr_login': ""}) print info getPage(url, method='POST', cookies=cj, postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.played_data2).addErrback(self.errorload) #reactor.callLater(5, self.played_data, url, method='POST', cookies=cj, postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}) else: self.stream_not_found() def played_data(self, *args, **kwargs): print "drin" getPage(*args, **kwargs).addCallback(self.played_data2).addErrback(self.errorload) def played_data2(self, data): print data stream_url = re.findall('file: "(.*?)"', data, re.S) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() def eco_read(self, data): post_url = re.findall('<form name="setss" method="post" action="(.*?)">', data, re.S) if post_url: info = urlencode({'': '1', 'sss': '1'}) print info getPage(post_url[0], method='POST', postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.eco_post).addErrback(self.errorload) else: self.stream_not_found() def eco_post(self, data): url = "http://www.ecostream.tv/assets/js/common.js" data2 = urllib.urlopen(url).read() post_url = re.findall("url: '(http://www.ecostream.tv/.*?)\?s=", data2, re.S) if post_url: print post_url sPattern = "var t=setTimeout\(\"lc\('([^']+)','([^']+)','([^']+)','([^']+)'\)" r = re.findall(sPattern, data) if r: for aEntry in r: sS = str(aEntry[0]) sK = str(aEntry[1]) sT = str(aEntry[2]) sKey = str(aEntry[3]) print "current keys:", sS, sK, sT, sKey sNextUrl = post_url[0]+"?s="+sS+'&k='+sK+'&t='+sT+'&key='+sKey print "URL:", sNextUrl info = urlencode({'s': sS, 'k': sK, 't': sT, 'key': sKey}) print "POST:", info getPage(sNextUrl, method='POST', postdata=info, headers={'Referer':'http://www.ecostream.tv', 'X-Requested-With':'XMLHttpRequest'}).addCallback(self.eco_final).addErrback(self.errorload) else: self.stream_not_found() else: self.stream_not_found() def eco_final(self, data): print "final gefunden" stream_url = re.findall('flashvars="file=(.*?)&', data) if stream_url: kkStreamUrl = "http://www.ecostream.tv"+stream_url[0]+"&start=0" kkStreamUrl = urllib2.unquote(kkStreamUrl) print kkStreamUrl self._callback(kkStreamUrl) else: self.stream_not_found() def zooupload(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def wupfile_post(self, data, url): print "hole daten" op = re.findall('type="hidden" name="op".*?value="(.*?)"', data, re.S) id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) referer = re.findall('type="hidden" name="referer".*?value="(.*?)"', data, re.S) if op and id and fname and referer: info = urlencode({ 'fname': fname[0], 'id': id[0], 'method_free': "Kostenloser Download", 'op': "download1", 'referer': "", 'usr_login': ""}) print info getPage(url, method='POST', postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.wupfile_data).addErrback(self.errorload) else: self.stream_not_found() def wupfile_data(self, data): print "hole streamlink" get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def sharesix(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0].replace('0://','http://') self._callback(stream_url[0].replace('0://','http://')) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0].replace('0://','http://') self._callback(stream_url[0].replace('0://','http://')) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def divxmov(self, data): stream_url = re.findall('<embed type="video/divx" src="(.*?)"', data, re.S) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def putme_org(self, data, url): print "hole post infos" dataPost = {} r = re.findall('input type="hidden".*?name="(.*?)".*?value="(.*?)"', data, re.S) if r: for name, value in r: dataPost[name] = value dataPost.update({'method_free':'Continue to Video'}) print dataPost getPage(url, method='POST', cookies=cj, postdata=urlencode(dataPost), headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.putme_org_post, url).addErrback(self.errorload) else: self.stream_not_found() def putme_org_post(self, data, url): print "hole post infos2" dataPost = {} r = re.findall('input type="hidden".*?name="(.*?)".*?value="(.*?)"', data, re.S) if r: for name, value in r: dataPost[name] = value dataPost.update({'method_free':'Continue to Video'}) print dataPost getPage(url, method='POST', postdata=urlencode(dataPost), headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.putme_org_data).addErrback(self.errorload) else: self.stream_not_found() def putme_org_data(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0].replace('0://','http://') self._callback(stream_url[0].replace('0://','http://')) else: self.stream_not_found() elif re.match(".*?file:", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file:'(.*?)'", sUnpacked) if stream_url: print stream_url[0].replace('0://','http://') self._callback(stream_url[0].replace('0://','http://')) else: self.stream_not_found() elif re.match('.*?value="src=', sUnpacked): stream_url = re.findall('value="src=(.*?flv)&', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def errorload(self, error): print "[streams]:", error self.stream_not_found() def flashx_tv(self, data): stream_url = re.findall('<file>(http://.*?flashx.tv.*?)</file>', data) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def flashx_tv2(self, data): print "flashx_tv2: ",data hash = re.findall('http://play.flashx.tv/player/fxtv.php.hash=(.*?)&', data, re.S) if hash: url = "http://play.flashx.tv/nuevo/player/cst.php?hash=%s" % hash[0] #print url getPage(url, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.flashx_tv).addErrback(self.errorload) else: self.stream_not_found() def flashx_tv3(self, link): print "flashx_tv3: ",link fx = Flashx() stream_url = fx.getVidUrl(link) if stream_url: self._callback(stream_url) else: self.stream_not_found() def flashx_tv3b(self, data): stream_url = re.findall('id="normal_player_cont">.*?src="(.*?)"', data, re.S) if stream_url: self.flashx_tv3(stream_url[0]) else: self.stream_not_found() def vidstream_in(self, data, url): id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) hash = re.findall('type="hidden" name="hash".*?value="(.*?)"', data, re.S) if id and fname and hash: print id, fname, hash post_data = urlencode({'op': "download1", 'usr_login': "", 'id': id[0], 'fname': fname[0], 'hash': hash[0], 'referer': "", 'imhuman': " Proceed+to+video"}) #getPage(url, method='POST', cookies=cj, postdata=post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vidstream_in_data).addErrback(self.errorload) reactor.callLater(6, self.vidstream_in_getPage, url, method='POST', cookies=cj, postdata=post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}) message = self.session.open(MessageBox, _("Stream startet in 6 sec."), MessageBox.TYPE_INFO, timeout=6) else: self.stream_not_found() def vidstream_in_getPage(self, *args, **kwargs): print "drin" getPage(*args, **kwargs).addCallback(self.vidstream_in_data).addErrback(self.errorload) def vidstream_in_data(self, data): stream_url = re.findall('file: "(.*?)"', data, re.S) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def vidstream_us(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?'file'", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("'file','(.*?)'", sUnpacked) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def primeshare(self, data, url): hash = re.findall('<input type="hidden".*?name="hash".*?value="(.*?)"', data) if hash: info = urlencode({'hash': hash[0]}) print info reactor.callLater(16, self.primeshare_getPage, url, method='POST', cookies=cj, postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}) message = self.session.open(MessageBox, _("Stream startet in 16 sec."), MessageBox.TYPE_INFO, timeout=16) else: self.stream_not_found() def primeshare_getPage(self, *args, **kwargs): print "drin" getPage(*args, **kwargs).addCallback(self.primeshare_data).addErrback(self.errorload) def primeshare_data(self, data): print data stream_url = re.findall('file: \'(.*?)\'', data, re.S) if stream_url: self._callback(stream_url[0]) else: #re.findall("'(http://.*?primeshare.tv.*?)'", url) stream_url = re.findall("provider: 'stream'.*?url: '(http://.*?primeshare.tv.*?)'", data, re.S) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def faststream(self, data, url): op = re.findall('type="hidden" name="op".*?value="(.*?)"', data, re.S) id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) referer = re.findall('type="hidden" name="referer".*?value="(.*?)"', data, re.S) hash = re.findall('type="hidden" name="hash".*?value="(.*?)"', data, re.S) if op and id and fname and referer and hash: info = urlencode({ 'fname': fname[0], 'hash': hash[0], 'id': id[0], 'imhuman': "Proceed to video", 'op':"download1", 'referer': "", 'usr_login': ""}) print info reactor.callLater(5, self.faststream_getPage, url, method='POST', postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}) message = self.session.open(MessageBox, _("Stream startet in 6 sec."), MessageBox.TYPE_INFO, timeout=6) else: self.stream_not_found() def faststream_getPage(self, *args, **kwargs): print "drin" getPage(*args, **kwargs).addCallback(self.faststream_data).addErrback(self.errorload) def faststream_data(self, data): stream_url = re.findall('file: "(.*?)"', data, re.S) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def yesload(self, data): stream_url = re.findall('url=(.*?.flv)', data) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def videoweed(self, data): print "drin okdf" r = re.search('flashvars.domain="(.+?)".*flashvars.file="(.+?)".*' + 'flashvars.filekey="(.+?)"', data, re.DOTALL) if r: domain, fileid, filekey = r.groups() api_call = ('%s/api/player.api.php?user=undefined&codes=1&file=%s' + '&pass=undefined&key=%s') % (domain, fileid, filekey) if api_call: getPage(api_call, method='GET').addCallback(self.videoweed_data).addErrback(self.errorload) else: self.stream_not_found() else: self.stream_not_found() def videoweed_data(self, data): rapi = re.search('url=(.+?)&title=', data) if rapi: stream_url = rapi.group(1) if stream_url: print stream_url self._callback(stream_url) else: self.stream_not_found() else: self.stream_not_found() def novamov(self, data): file = re.findall('flashvars.file="(.*?)"', data) key = re.findall('flashvars.filekey="(.*?)"', data) if file and key: url = "http://www.novamov.com/api/player.api.php?file=%s&key=%s" % (file[0], key[0]) aage = "Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17" getPage(url, agent=aage, method='GET').addCallback(self.novamov_data).addErrback(self.errorload) else: self.stream_not_found() def novamov_data(self, data): ar = re.search('url=(.+?)&title', data) if ar: stream_url = ar.group(1) print stream_url self._callback(stream_url) else: self.stream_not_found() def divxstage(self, data): print "divxstage drin" file = re.findall('flashvars.file="(.*?)"', data) key = re.findall('flashvars.filekey="(.*?)"', data) if file and key: url = "http://www.divxstage.eu/api/player.api.php?file=%s&key=%s" % (file[0], key[0]) print url aage = "Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17" getPage(url, agent=aage, method='GET').addCallback(self.movshare_xml).addErrback(self.errorload) else: print "ja" self.stream_not_found() def movshare(self, data, url): info = {} getPage(url, method='POST', cookies=cj, postdata=info, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.movshare_post).addErrback(self.errorload) def movshare_post(self, data): print "movshare drin" file = re.findall('flashvars.file="(.*?)"', data, re.S) key = re.findall('flashvars.filekey="(.*?)"', data, re.S) if file and key: url = "http://www.movshare.net/api/player.api.php?file=%s&key=%s" % (file[0], key[0]) print url getPage(url, method='GET').addCallback(self.movshare_xml).addErrback(self.errorload) else: print "ja" self.stream_not_found() def movshare_xml(self, data): file_link = re.search('url=(.+?)&title=', data) if file_link: stream_url = file_link.group(1) print stream_url self._callback(stream_url) else: self.stream_not_found() def flashstream(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?'file'", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("'file','(.*?)'", sUnpacked) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def ginbig_flashstream(self, data, url): op = re.findall('<input type="hidden" name="op" value="(.*?)">', data, re.S) id = re.findall('<input type="hidden" name="id" value="(.*?)">', data, re.S) fname = re.findall('<input type="hidden" name="fname" value="(.*?)">', data, re.S) if op and id and fname: post_data = urlencode({'op': 'download1', 'usr_login': '', 'id': id[0], 'fname': fname[0], 'referer': '', 'method_free': 'Kostenloser Download' }) getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.ginbig__flashstream_data).addErrback(self.errorload) else: self.stream_not_found() def ginbig__flashstream_data(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: stream_url = re.findall("'file','(.*?)'", sUnpacked) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def monsteruploads(self, data, url): if not re.match('.*?eval\(function\(p\,a\,c\,k\,e\,d', data, re.S): id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) referer = re.findall('type="hidden" name="referer".*?value="(.*?)"', data, re.S) info = urlencode({ 'op': "download2", 'usr_login': "", 'id': id[0], 'fname': fname[0], 'referer': "", 'method_free': "Kostenloser Download" }) getPage(url, method='POST', postdata = info, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.monsteruploads_post).addErrback(self.errorload) else: get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def monsteruploads_post(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: if re.match('.*?type="video/divx', sUnpacked): stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match('.*?playlist:.*?http://www.monsteruploads.eu', sUnpacked): stream_url = re.findall("playlist:.'(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def vreer(self, data, url): id = re.findall('type="hidden" name="id".*?value="(.*?)"', data, re.S) fname = re.findall('type="hidden" name="fname".*?value="(.*?)"', data, re.S) hash = re.findall('type="hidden" name="hash".*?value="(.*?)"', data, re.S) referer = re.findall('type="hidden" name="referer".*?value="(.*?)"', data, re.S) if id and fname and hash and referer: post_data = urlencode({'op': "download2", 'usr_login': "", 'id': id[0], 'fname': fname[0], 'hash': hash[0], 'referer': "", 'method_free': "Free Download"}) getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.vreer_post).addErrback(self.errorload) else: self.stream_not_found() def vreer_post(self, data): if re.match('.*?video.flv', data, re.S): stream_url = re.findall('file:."(.*?)"', data, re.S) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() def uploadc(self, data, url): ipcount_val = re.findall('<input type="hidden" name="ipcount_val".*?value="(.*?)">', data) id = re.findall('<input type="hidden" name="id".*?value="(.*?)">', data) fname = re.findall('<input type="hidden" name="fname".*?alue="(.*?)">', data) if id and fname and ipcount_val: post_data = urllib.urlencode({'ipcount_val' : ipcount_val[0], 'op' : 'download2', 'usr_login' : '', 'id' : id[0], 'fname' : fname[0], 'method_free' : 'Slow access'}) print post_data getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.uploadc_post).addErrback(self.errorload) else: print "keine post infos gefunden." self.stream_not_found() def uploadc_post(self, data): print data stream = re.findall("'file','(.*?)'", data, re.S) get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if stream: print stream self._callback(stream[0]) elif get_packedjava: sJavascript = get_packedjava[1] print sJavascript sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print sUnpacked stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def nowvideo(self, data): file = re.findall('flashvars.file="(.*?)"', data) key = re.findall('flashvars.filekey="(.*?)"', data) if file and key: url = "http://www.nowvideo.eu/api/player.api.php?file=%s&key=%s" % (file[0], key[0]) getPage(url, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.nowvideo_xml).addErrback(self.errorload) else: self.stream_not_found() def nowvideo_xml(self, data): rapi = re.search('url=(.+?)&title=', data) if rapi: stream_url = rapi.group(1) self._callback(stream_url) else: self.stream_not_found() def xvidstream(self, data): get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def movreel_data(self, data, url): id = re.findall('<input type="hidden" name="id".*?value="(.*?)">', data) fname = re.findall('<input type="hidden" name="fname".*?value="(.*?)">', data) if id and fname: post_data = urllib.urlencode({'op': 'download1', 'usr_login': '', 'id': id[0], 'fname': fname[0], 'referer': '', 'method_free': ' Kostenloser Download'}) getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.movreel_post_data, url, fname[0]).addErrback(self.errorload) else: self.stream_not_found() def movreel_post_data(self, data, url, fname): id = re.findall('<input type="hidden" name="id".*?value="(.*?)">', data) rand = re.findall('<input type="hidden" name="rand".*?value="(.*?)">', data) if id and rand: post_data = urllib.urlencode({'op': 'download2', 'usr_login': '', 'id': id[0], 'rand': rand[0], 'referer': '', 'method_free': ' Kostenloser Download'}) getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.movreel_post_data2, fname).addErrback(self.errorload) else: self.stream_not_found() def movreel_post_data2(self, data, fname): stream_url = re.findall("var file_link = '(.*?)'", data, re.S) if stream_url: self._callback(stream_url[0]) else: self.stream_not_found() def filenuke(self, data, url): print "drin " id = re.findall('<input type="hidden" name="id".*?value="(.*?)">', data) fname = re.findall('<input type="hidden" name="fname".*?alue="(.*?)">', data) post_data = urllib.urlencode({'op': 'download1', 'usr_login': '', 'id': id[0], 'fname': fname[0], 'referer': '', 'method_free': 'free'}) #print post_data getPage(url, method='POST', postdata = post_data, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.filenuke_data).addErrback(self.errorload) def filenuke_data(self, data): print "drin2" get_packedjava = re.findall("<script type=.text.javascript.>eval.function(.*?)</script>", data, re.S|re.DOTALL) if get_packedjava: print get_packedjava sJavascript = get_packedjava[1] sUnpacked = cJsUnpacker().unpackByString(sJavascript) if sUnpacked: print "unpacked" print sUnpacked if re.match('.*?type="video/divx', sUnpacked): print "DDIIIIIIIIIVVVXXX" stream_url = re.findall('type="video/divx"src="(.*?)"', sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() elif re.match(".*?file", sUnpacked): print "FFFFFFFFLLLLLLLLLLLVVVVVVVV" stream_url = re.findall("file','(.*?)'", sUnpacked) if stream_url: print stream_url[0] self._callback(stream_url[0]) else: self.stream_not_found() else: self.stream_not_found() else: self.stream_not_found() def streamPutlockerSockshare(self, data, url, provider): if re.match('.*?File Does not Exist', data, re.S): message = self.session.open(MessageBox, "File Does not Exist, or Has Been Removed", MessageBox.TYPE_INFO, timeout=5) elif re.match('.*?Encoding to enable streaming is in progresss', data, re.S): message = self.session.open(MessageBox, "Encoding to enable streaming is in progresss. Try again soon.", MessageBox.TYPE_INFO, timeout=5) else: print "provider:", provider enter = re.findall('<input type="hidden" value="(.*?)" name="fuck_you">', data) print "enter:", enter values = {'fuck_you': enter[0], 'confirm': 'Close+Ad+and+Watch+as+Free+User'} user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = { 'User-Agent' : user_agent} cookiejar = cookielib.LWPCookieJar() cookiejar = urllib2.HTTPCookieProcessor(cookiejar) opener = urllib2.build_opener(cookiejar) urllib2.install_opener(opener) data = urlencode(values) req = urllib2.Request(url, data, headers) try: response = urllib2.urlopen(req) except urllib2.HTTPError, e: print e.code self.stream_not_found() except urllib2.URLError, e: print e.args self.stream_not_found() else: