Example #1
0
def openloadS(url, videoData=None, usePairing=True):
    try:
        ret_error = ''
        if videoData == None:
            videoData = getVideoMetaData(url=url)[0]

        video_id = match_id(url)
        ol_id = client.search_regex(
            '<span[^>]+id="[^"]+"[^>]*>([0-9A-Za-z]+)</span>', videoData,
            'openload ID')

        video_url = 'https://openload.co/stream/%s?mime=true'
        try:
            decoded = decode_id(ol_id)
            video_url = video_url % decoded
        except DecodeError as e:
            print('%s; falling back to method with evaluating' % e, video_id)
            try:
                decoded = eval_id_decoding(videoData, ol_id)
                video_url = video_url % decoded
            except DecodeError as e:
                try:
                    if usePairing == True:
                        print('%s; falling back to method with pairing' % e,
                              video_id)
                        title, video_url = pairing_method(video_id)
                    else:
                        print('%s; pairing is the only option available' % e,
                              video_id)
                        video_url = None
                except DecodeError as e:
                    video_url = None
                    ret_error = str(e)
                    print ret_error

        return (video_url, videoData, ret_error)
    except Exception as e:
        ret_error = 'ERROR host_openload.py>openloadS: Args:%s Url:%s' % (
            e.args, url)
        print ret_error
        return (None, videoData, ret_error)
    def createMeta(self,
                   url,
                   provider,
                   logo,
                   quality,
                   links,
                   key,
                   riptype,
                   showsplit=False,
                   useGetlinkAPI=True,
                   vidtype='Movie',
                   lang='en',
                   sub_url=None,
                   txt='',
                   file_ext='.mp4',
                   testing=False):

        orig_url = url

        if testing == True:
            links.append(url)
            return links

        if control.setting('Host-%s' % name) == False:
            log('INFO', 'createMeta', 'Host Disabled by User')
            return links

        if 'http' not in url and 'google.com/file' in url:
            url = 'https://drive.google.com/' + url.split('.com/')[1]

        httpsskip = False
        if control.setting('use_https_alt') != None and (
                control.setting('use_https_alt') == True
                or control.setting('use_https_alt') == False):
            httpsskip = control.setting('httpsskip')

        #print "createMeta1 : %s %s %s %s" % (url, provider, logo, quality)
        videoData, headers, content, cookie = getVideoMetaData(url, httpsskip)
        try:
            cookie += '; %s' % content['Set-Cookie']
            # cookie_s = cookie.split(';')
            # cookie_n = []
            # for cook in cookie_s:
            # cook = cook.strip()
            # if '=' in cook and cook not in cookie_n:
            # cookie_n.append(cook)
            # cookie = ('; '.join(x for x in sorted(cookie_n)))
            cookie_value = client.search_regex(r"DRIVE_STREAM=([^;]+);",
                                               cookie,
                                               'cookie val',
                                               group=1)
            domain = client.search_regex(r"https?://([^\/]+)",
                                         url,
                                         'host val',
                                         group=1)
            cookie = 'DRIVE_STREAM=%s; path=/; domain=.%s;' % (cookie_value,
                                                               domain)
        except:
            pass
        #print cookie

        #cookie = urllib.quote_plus(cookie).replace('+','%20').replace('%2F','/')
        # DRIVE_STREAM%3Dva1wsBbVn3A%3B%20path%3D/%3B%20domain%3D.docs.google.com%3B
        # DRIVE_STREAM%3DtV76KFL8a6k%3B+path%3D%2F%3B+domain%3D.docs.google.com%3B

        params = {'headers': headers, 'cookie': cookie}
        params = json.dumps(params, encoding='utf-8')
        params = client.b64encode(params)

        if client.geturlhost(url) in self.host[4]:
            pass  # skip for googleapis.com link
        else:
            quality = file_quality(url, quality, videoData)[0]
        isOnline = check(url,
                         videoData,
                         headers=headers,
                         cookie=cookie,
                         httpsskip=httpsskip)[0]
        type = rip_type(url, riptype)

        files = []

        #print "createMeta : %s %s %s %s" % (url, provider, logo, quality)
        titleinfo = txt
        if txt != '':
            titleinfo = txt
        ntitleinfo = titleinfo

        files_ret = []

        enabled = True
        try:
            #udata = urldata(url, videoData=videoData, usevideoData=True)
            if 'google.com/file' in url:
                idstr = '%s' % (url.split('/preview')[0].split('/edit')
                                [0].split('/view')[0])
                idstr = idstr.split('/')
                id = idstr[len(idstr) - 1]
                try:
                    durl, f_res, fs = getFileLink(id, httpsskip)
                except:
                    fs = 0
                    durl = None

                if durl != None:
                    files_ret.append({
                        'source': self.name,
                        'maininfo': '',
                        'titleinfo': ntitleinfo,
                        'quality': quality,
                        'vidtype': vidtype,
                        'rip': type,
                        'provider': provider,
                        'url': durl,
                        'durl': durl,
                        'urldata': createurldata(durl, quality),
                        'params': params,
                        'logo': logo,
                        'online': isOnline,
                        'allowsDownload': self.allowsDownload,
                        'allowsStreaming': self.allowsStreaming,
                        'key': key,
                        'enabled': enabled,
                        'fs': int(fs),
                        'file_ext': file_ext,
                        'ts': time.time(),
                        'lang': lang,
                        'sub_url': sub_url,
                        'subdomain': client.geturlhost(durl),
                        'misc': {
                            'player': 'iplayer',
                            'gp': False
                        }
                    })
                else:
                    fs = client.getFileSize(url, retry429=True)

                files_ret.append({
                    'source': self.name,
                    'maininfo': '',
                    'titleinfo': ntitleinfo,
                    'quality': quality,
                    'vidtype': vidtype,
                    'rip': type,
                    'provider': provider,
                    'url': url,
                    'durl': url,
                    'urldata': urldata('', ''),
                    'params': params,
                    'logo': logo,
                    'online': isOnline,
                    'allowsDownload': self.allowsDownload,
                    'allowsStreaming': self.allowsStreaming,
                    'key': key,
                    'enabled': enabled,
                    'fs': int(fs),
                    'file_ext': file_ext,
                    'ts': time.time(),
                    'lang': lang,
                    'sub_url': sub_url,
                    'subdomain': client.geturlhost(url),
                    'misc': {
                        'player': 'eplayer',
                        'gp': False
                    }
                })
            else:
                fs = client.getFileSize(url, retry429=True)

                files_ret.append({
                    'source': self.name,
                    'maininfo': '',
                    'titleinfo': ntitleinfo,
                    'quality': quality,
                    'vidtype': vidtype,
                    'rip': type,
                    'provider': provider,
                    'url': url,
                    'durl': url,
                    'urldata': urldata('', ''),
                    'params': params,
                    'logo': logo,
                    'online': isOnline,
                    'allowsDownload': self.allowsDownload,
                    'allowsStreaming': self.allowsStreaming,
                    'key': key,
                    'enabled': enabled,
                    'fs': int(fs),
                    'file_ext': file_ext,
                    'ts': time.time(),
                    'lang': lang,
                    'sub_url': sub_url,
                    'subdomain': client.geturlhost(url),
                    'misc': {
                        'player': 'iplayer',
                        'gp': False
                    }
                })
        except Exception as e:
            log(type='ERROR', method='createMeta-1', err=u'%s' % e)

        isGetlinkWork = False
        try:
            if useGetlinkAPI == True and isOnline and 'google.com/file' in url and self.useGetLinkAPI:
                client.setIP4()
                ntitleinfo = titleinfo + ' | (via GetLink API) '
                files = urldata(url)
                files = client.b64decode(files)
                filesJ = json.loads(files)
                if len(filesJ) > 0:
                    for mfile in filesJ:
                        mfile = json.loads(mfile)
                        #print "mfile --- : %s" % mfile
                        furl = mfile['src']
                        f2url = client.request(furl,
                                               followredirect=True,
                                               output='geturl')
                        if 'http' in f2url:
                            furl = f2url
                            #print "furl --- : %s" % furl
                            quality = file_quality(furl, mfile['res'],
                                                   videoData)[0]
                            isOnlineT = check(furl,
                                              videoData,
                                              headers=headers,
                                              cookie=cookie)[0]
                            type = rip_type(furl, riptype)
                        else:
                            isOnlineT = 'Unknown'

                        p = {'headers': '', 'cookie': ''}
                        p = json.dumps(p, encoding='utf-8')
                        p = client.b64encode(p)

                        fs = client.getFileSize(furl, retry429=True)

                        files_ret.append({
                            'source': self.name,
                            'maininfo': '',
                            'titleinfo': ntitleinfo,
                            'quality': quality,
                            'vidtype': vidtype,
                            'rip': type,
                            'provider': provider,
                            'url': furl,
                            'durl': furl,
                            'urldata': urldata('', ''),
                            'params': p,
                            'logo': logo,
                            'online': isOnlineT,
                            'allowsDownload': self.allowsDownload,
                            'allowsStreaming': self.allowsStreaming,
                            'key': key,
                            'enabled': enabled,
                            'fs': int(fs),
                            'file_ext': file_ext,
                            'ts': time.time(),
                            'lang': lang,
                            'sub_url': sub_url,
                            'subdomain': client.geturlhost(furl),
                            'misc': {
                                'player': 'iplayer',
                                'gp': False
                            }
                        })
                        isGetlinkWork = True
                client.setIP6()
        except Exception as e:
            log(type='ERROR', method='createMeta-2', err=u'%s' % e)

        try:
            if showsplit == True and isOnline and isGetlinkWork == False:
                # currently suffers from transcoding failure on most clients
                ntitleinfo = titleinfo + ' | *limited support* '
                files = get_files(url, videoData)[0]
                for furl in files:
                    quality = file_quality(furl, quality, videoData)[0]
                    type = rip_type(furl, riptype)

                    furl = urllib.unquote(furl).decode('utf8')
                    furl = furl.decode('unicode_escape')

                    isOnlineT = check(furl,
                                      videoData,
                                      headers=headers,
                                      cookie=cookie)[0]

                    fs = client.getFileSize(furl, retry429=True)

                    files_ret.append({
                        'source': self.name,
                        'maininfo': '',
                        'titleinfo': ntitleinfo,
                        'quality': quality,
                        'vidtype': vidtype,
                        'rip': type,
                        'provider': provider,
                        'url': furl,
                        'durl': furl,
                        'urldata': createurldata(furl, quality),
                        'params': params,
                        'logo': logo,
                        'online': isOnlineT,
                        'allowsDownload': self.allowsDownload,
                        'allowsStreaming': self.allowsStreaming,
                        'key': key,
                        'enabled': enabled,
                        'fs': int(fs),
                        'file_ext': file_ext,
                        'ts': time.time(),
                        'lang': lang,
                        'sub_url': sub_url,
                        'subdomain': client.geturlhost(furl),
                        'misc': {
                            'player': 'iplayer',
                            'gp': False
                        }
                    })
        except Exception as e:
            log(type='ERROR', method='createMeta-3', err=u'%s' % e)

        for fr in files_ret:
            fr['resumeDownload'] = self.resumeDownload
            links.append(fr)

        log('INFO',
            'createMeta',
            'Successfully processed %s link >>> %s' % (provider, orig_url),
            dolog=self.init)
        return links
Example #3
0
def eval_id_decoding(videoData, ol_id):
	try:
		# raise # uncomment to test method with pairing
		# js_code = client.search_regex(
			# r"(゚ω゚ノ=.*?\('_'\);.*?)゚ω゚ノ= /`m´)ノ ~┻━┻   //\*´∇`\*/ \['_'\];",
			# videoData, 'openload decrypt code', flags=re.S)
		# js_code = re.sub('''if\s*\([^\}]+?typeof[^\}]+?\}''', '', js_code)
		
		js_code = client.search_regex(r"(゚ω゚ノ=.*?\('_'\);.*?)゚ω゚ノ= /`m´)ノ ~┻━┻   //\*´∇`\*/ \['_'\];",videoData, 'openload decrypt code', flags=re.S)
		decoder = js_code.split("('_');")[-1]
		js_code = re.sub('''if\s*\([^\}]+?typeof[^\}]+?\}''', '', js_code)
	except:
		raise DecodeError('Error: Could not find JavaScript')

	js_code = '''
            var id = "%s"
              , decoded
              , document = {}
              , window = this
              , $ = function(){
                  return {
                    text: function(a){
                      if(a)
                        decoded = a;
                      else
                        return id;
                    },
                    ready: function(a){
                      a()
                    }
                  }
                };
            (function(d, w){
              var f = function(){};
              var s = '';
              var o = null;
              var b = false;
              var n = 0;
              var df = ['close','createAttribute','createDocumentFragment','createElement','createElementNS','createEvent','createNSResolver','createRange','createTextNode','createTreeWalker','evaluate','execCommand','getElementById','getElementsByName','getElementsByTagName','importNode','open','queryCommandEnabled','queryCommandIndeterm','queryCommandState','queryCommandValue','write','writeln'];
              df.forEach(function(e){d[e]=f;});
              var do_ = ['anchors','applets','body','defaultView','doctype','documentElement','embeds','firstChild','forms','images','implementation','links','location','plugins','styleSheets'];
              do_.forEach(function(e){d[e]=o;});
              var ds = ['URL','characterSet','compatMode','contentType','cookie','designMode','domain','lastModified','referrer','title'];
              ds.forEach(function(e){d[e]=s;});
              var wb = ['closed','isSecureContext'];
              wb.forEach(function(e){w[e]=b;});
              var wf = ['addEventListener','alert','atob','blur','btoa','cancelAnimationFrame','captureEvents','clearInterval','clearTimeout','close','confirm','createImageBitmap','dispatchEvent','fetch','find','focus','getComputedStyle','getSelection','matchMedia','moveBy','moveTo','open','postMessage','print','prompt','releaseEvents','removeEventListener','requestAnimationFrame','resizeBy','resizeTo','scroll','scrollBy','scrollTo','setInterval','setTimeout','stop'];
              wf.forEach(function(e){w[e]=f;});
              var wn = ['devicePixelRatio','innerHeight','innerWidth','length','outerHeight','outerWidth','pageXOffset','pageYOffset','screenX','screenY','scrollX','scrollY'];
              wn.forEach(function(e){w[e]=n;});
              var wo = ['applicationCache','caches','crypto','external','frameElement','frames','history','indexedDB','localStorage','location','locationbar','menubar','navigator','onabort','onanimationend','onanimationiteration','onanimationstart','onbeforeunload','onblur','oncanplay','oncanplaythrough','onchange','onclick','oncontextmenu','ondblclick','ondevicemotion','ondeviceorientation','ondrag','ondragend','ondragenter','ondragleave','ondragover','ondragstart','ondrop','ondurationchange','onemptied','onended','onerror','onfocus','onhashchange','oninput','oninvalid','onkeydown','onkeypress','onkeyup','onlanguagechange','onload','onloadeddata','onloadedmetadata','onloadstart','onmessage','onmousedown','onmouseenter','onmouseleave','onmousemove','onmouseout','onmouseover','onmouseup','onoffline','ononline','onpagehide','onpageshow','onpause','onplay','onplaying','onpopstate','onprogress','onratechange','onreset','onresize','onscroll','onseeked','onseeking','onselect','onshow','onstalled','onstorage','onsubmit','onsuspend','ontimeupdate','ontoggle','ontransitionend','onunload','onvolumechange','onwaiting','onwebkitanimationend','onwebkitanimationiteration','onwebkitanimationstart','onwebkittransitionend','onwheel','opener','parent','performance','personalbar','screen','scrollbars','self','sessionStorage','speechSynthesis','statusbar','toolbar','top'];
              wo.forEach(function(e){w[e]=o;});
              var ws = ['name'];
              ws.forEach(function(e){w[e]=s;});
            })(document, window);
            %s;
            decoded;''' % (ol_id, js_code)

	try:
		ret = js2py.eval_js(js_code)
		if ret == '':
			raise DecodeError('Error: Returned null response')
		for char in ret:
			if re.match(r'''[^\w\-\.~:\[\]@!$'()*+,;=`]''', char):
				raise DecodeError('Error: Match error')
		try:
			ret.encode('utf8').decode('ascii') # test if it's ascii string
		except:
			raise DecodeError('Error: Decoding to ASCII')
		if 'API' in ret:
			raise DecodeError('Error: JavaScript returned use API warning message')
		return ret
	except:
		#print "*** print_exc:"
		#traceback.print_exc()
		raise DecodeError('Error: Could not eval ID decoding')
Example #4
0
def openloadS(url, videoData=None, usePairing=True, session=None):
	try:
		ret_error = ''
		if videoData == None:
			videoData = client.request(url, headers=openloadhdr)
			
		try:
			ol_id = client.search_regex('<span[^>]+id="[^"]+"[^>]*>([0-9A-Za-z]+)</span>',videoData, 'openload ID')
		except:
			ol_id = None
		try:
			video_id = match_id(url)
		except:
			video_id = None
		log(type='INFO',method='openloadS', err=u'OpenLoad iD: %s' % video_id)
		video_url = None
		e = ''
		try:
			if USE_PHANTOMJS == True and ((session == None or control.setting('%s-%s' % (session, 'Use-PhantomJS')) == True) and control.setting('use_phantomjs') == control.phantomjs_choices[1]) or control.setting('use_phantomjs') == control.phantomjs_choices[2]:
				log(type='INFO',method='openloadS', err=u'trying phantomjs method: %s' % (video_id))
				try:
					v_url, bool = phantomjs.decode(url, user_agent=client.USER_AGENT)
					if bool == False:
						ret_error = v_url
						raise DecodeError(ret_error)
					else:
						video_url = v_url
						ret_error = ''
						log(type='SUCCESS',method='openloadS', err=u'*PhantomJS* method is working: %s' % video_id)
				except:
					raise DecodeError('phantomjs not working')
			else:
				raise DecodeError('phantomjs is disabled')
		except DecodeError as e:
			try:
				if USE_LOGIN_KEY == True and video_url == None:
					log(type='INFO',method='openloadS', err=u'%s; trying L/K API method: %s' % (e,video_id))
					v_url, cont, cu, dlk, ret_error = link_from_api(video_id)
					if v_url == None:
						raise DecodeError('%s' % ret_error)
					else:
						ret_error = ''
						video_url = v_url
						log(type='SUCCESS',method='openloadS', err=u'*L/K API* method is working: %s' % video_id)
				else:
					raise DecodeError('L/K method disabled via hard coded option')
			except DecodeError as e:
				if USE_DECODING1 == True and video_url == None:
					log(type='INFO',method='openloadS', err=u'%s; falling back to decode_id method: %s' % (e,video_id))
					try:
						v_url = 'https://openload.co/stream/%s?mime=true'
						decoded = decode_id(ol_id)
						video_url = v_url % decoded
					except DecodeError as e:
						pass
				if USE_DECODING2 == True and video_url == None:
					log(type='INFO',method='openloadS', err=u'%s; falling back to method with evaluating: %s' % (e,video_id))
					try:
						decoded = eval_id_decoding(videoData, ol_id)
						video_url = video_url % decoded
					except DecodeError as e:
						pass
				if USE_PAIRING == True:
					try:
						if usePairing == True and video_url == None:
							log(type='INFO',method='openloadS', err=u'%s; falling back to method with pairing: %s' % (e,video_id))
							title, video_url = pairing_method(video_id)
							if video_url == None:
								raise DecodeError('Pairing not working')
							ret_error = ''
							log(type='SUCCESS',method='openloadS', err=u'*Pairing* method is working: %s' % video_id)
						elif video_url == None:
							ret_error = 'pairing is the only option available'
							log(type='INFO',method='openloadS', err=u'%s; %s : %s' % (e,ret_error,video_id))
							video_url = None
						elif video_url != None:
							ret_error = ''
					except DecodeError as e:
						video_url = None
						ret_error = str(e)
						print ret_error

		return (video_url, videoData, ret_error)
	except Exception as e:
		ret_error = '%s ID:%s' % (e, video_id)
		log(type='ERROR',method='openloadS', err=u'%s: %s' % (e, video_id))
		
		return (None, videoData, ret_error)