Exemple #1
0
def getSources(url):
    sources = []

    soup = BeautifulSoup(http_req(url))

    params = {}

    try:
        params['vid'] = re.search(r'_([0-9a-z]+).html?', url).group(1)
    except:
        html = soup.findAll('script', {'type': 'text/javascript'})
        html = "".join(line.strip() for line in str(html).split("\n"))
        html = re.findall(r'\$\.ajax\({.+?data: {(.+?)}', html)
        html = html[1].replace('"', '').split(',')

        for parameter in html:
            key, value = parameter.split(':')
            params[key] = value.strip()

    mirrors = []

    if (soup.find('iframe')):
        mirrors.append(url)
    else:
        mirrors.append('%sajax.php?p=video&do=getplayer&vid=%s' %
                       (URL['base'], params['vid']))

    multiMirrors = soup.find('ul', {'id': 'menu-bar'})
    if multiMirrors:
        multiMirrors = multiMirrors.findAll('a')

    if (multiMirrors):
        for i in range(len(multiMirrors)):
            mirrors.append(
                '%sajax.php?p=custom&do=requestmirror&vid=%s&mirror=%s' %
                (URL['base'], params['vid'], str(i + 1)))

    mirrors.reverse()

    for mirror in mirrors:
        try:
            if mirror == url:
                mirrorUrl = soup.find('iframe').attrs['src']
            else:
                mirrorUrl = BeautifulSoup(
                    http_req(mirror)).find('iframe').attrs['src']
            mirrorUrl = re.sub(r'https?:\/\/(?:www\.)?.+?\.li/?\??', '',
                               mirrorUrl)
        except:
            continue

        if (re.search(r'mail.ru', mirrorUrl)):
            try:
                source = BeautifulSoup(http_req(mirrorUrl)).findAll(
                    'script', {'type': 'text/javascript'})
                jsonUrl = re.search(r'"metadataUrl":"(.+?)"',
                                    str(source)).group(1)
                req = http_req(jsonUrl, True)
                jsonSource = json.loads(req['source'])

                for source in jsonSource['videos']:
                    name = '%s %s' % ('[mail.ru]', source['key'])
                    link = '%s|Cookie=%s' % (source['url'],
                                             urllib.quote_plus(req['cookie']))
                    item = {'name': name, 'url': link}
                    sources.append(item)
            except:
                pass

        elif (re.search(r'vk.com', mirrorUrl)):
            try:
                from resources.lib.getvk import getVkVideos
                for source in getVkVideos(http_req(mirrorUrl)):
                    item = {'name': source[0], 'url': source[1]}
                    sources.append(item)
            except:
                pass

        elif (re.search(r'ok.ru', mirrorUrl)):
            try:
                id = re.search('\d+', mirrorUrl).group(0)
                u = urlparse.urlparse(mirrorUrl)
                hostUrl = '://'.join([u.scheme, u.netloc])
                jsonUrl = 'http://ok.ru/dk?cmd=videoPlayerMetadata&mid=' + id
                jsonSource = json.loads(http_req(jsonUrl))

                for source in jsonSource['videos']:
                    quality = {
                        'mobile': '144p',
                        'lowest': '240p',
                        'low': '360p',
                        'sd': '480p',
                        'hd': '720p',
                        'full': '1080p'
                    }
                    q = source['name'].strip()
                    q = quality.get(q, None)
                    if not q:
                        continue
                    name = '%s %s' % ('[ok.ru]', q)
                    params = {
                        'User-Agent': HEADERS['User-Agent'],
                        'Referer': mirrorUrl,
                        'Origin': hostUrl
                    }
                    params = '&'.join([
                        '%s=%s' % (k, urllib.quote_plus(v))
                        for k, v in params.iteritems()
                    ])
                    link = '%s|%s' % (source['url'], params)

                    item = {'name': name, 'url': link}
                    sources.append(item)
            except:
                pass
    return sources
Exemple #2
0
def getSources(url):
    sources = []

    soup = BeautifulSoup(http_req(url))



    params = {}

    try:
        params['vid'] = re.search(r'_([0-9a-z]+).html?', url).group(1)
    except:
        html = soup.findAll('script', {'type': 'text/javascript'})
        html = "".join(line.strip() for line in str(html).split("\n"))
        html = re.findall(r'\$\.ajax\({.+?data: {(.+?)}', html)
        html = html[1].replace('"', '').split(',')

        for parameter in html:
            key, value = parameter.split(':')
            params[key] = value.strip()

    mirrors = []

    if(soup.find('iframe')):
        mirrors.append(url)
    else:
        mirrors.append('%sajax.php?p=video&do=getplayer&vid=%s' % (URL['base'], params['vid']))

    multiMirrors = soup.find('ul', {'id': 'menu-bar'})
    if multiMirrors:
        multiMirrors = multiMirrors.findAll('a')

    if(multiMirrors):
        for i in range(len(multiMirrors)):
            mirrors.append('%sajax.php?p=custom&do=requestmirror&vid=%s&mirror=%s' % (URL['base'], params['vid'], str(i+1)))

    mirrors.reverse()

    for mirror in mirrors:
        try:
            if mirror == url:
                mirrorUrl = soup.find('iframe').attrs['src']
            else:
                mirrorUrl = BeautifulSoup(http_req(mirror)).find('iframe').attrs['src']
            mirrorUrl = re.sub(r'https?:\/\/(?:www\.)?.+?\.li/?\??', '', mirrorUrl)
        except:
            continue
        
        if(re.search(r'mail.ru', mirrorUrl)):
            try:
                source = BeautifulSoup(http_req(mirrorUrl)).findAll('script', {'type': 'text/javascript'})
                jsonUrl = re.search(r'"metadataUrl":"(.+?)"', str(source)).group(1)
                req = http_req(jsonUrl, True)
                jsonSource = json.loads(req['source'])
                
                for source in jsonSource['videos']:
                    name = '%s %s' % ('[mail.ru]', source['key'])
                    link = '%s|Cookie=%s' % (source['url'], urllib.quote_plus(req['cookie']))
                    item = {'name': name, 'url': link}
                    sources.append(item)
            except:
                pass
        
        elif(re.search(r'vk.com', mirrorUrl)):
            try:
                from resources.lib.getvk import getVkVideos
                for source in getVkVideos(http_req(mirrorUrl)):
                    item = {'name': source[0], 'url': source[1]}
                    sources.append(item)
            except:
                pass
        
        elif(re.search(r'ok.ru', mirrorUrl)):
            try:
                id = re.search('\d+', mirrorUrl).group(0)
                u = urlparse.urlparse(mirrorUrl)
                hostUrl = '://'.join([u.scheme, u.netloc])
                jsonUrl = 'http://ok.ru/dk?cmd=videoPlayerMetadata&mid=' + id
                jsonSource = json.loads(http_req(jsonUrl))
                
                for source in jsonSource['videos']:
                    quality = {
                        'mobile':   '144p',
                        'lowest':   '240p',
                        'low':      '360p',
                        'sd':       '480p',
                        'hd':       '720p',
                        'full':     '1080p'
                    }
                    q = source['name'].strip()
                    q = quality.get(q, None)
                    if not q:
                        continue
                    name = '%s %s' % ('[ok.ru]', q)
                    params = {
                        'User-Agent':   HEADERS['User-Agent'],
                        'Referer':      mirrorUrl,
                        'Origin':       hostUrl
                    }
                    params = '&'.join(['%s=%s' % (k, urllib.quote_plus(v)) for k, v in params.iteritems()])
                    link = '%s|%s' % (source['url'], params)
                    
                    item = {'name': name, 'url': link}
                    sources.append(item)
            except:
                pass
    return sources
Exemple #3
0
def getSources(url):
	sources = []
	
	soup = BeautifulSoup(http_req(url))
	
	params = {}
	
	try:
		params['vid'] = re.search(r'_([0-9a-z]+).html?', url).group(1)
	except:
		html = soup.find_all('script', {'type': 'text/javascript'})
		html = "".join(line.strip() for line in str(html).split("\n"))
		html = re.findall(r'\$\.ajax\({.+?data: {(.+?)}', html)
		html = html[1].replace('"', '').split(',')
	
		for parameter in html:
			key, value = parameter.split(':')
			params[key] = value.strip()
	
	mirrors = []
	
	multiMirrors = soup.find('ul', {'id': 'menu-bar'})
	if multiMirrors: multiMirrors = multiMirrors.find_all('a')
	
	if(multiMirrors):
		for i in range(len(multiMirrors)):
			mirrors.append('%sajax.php?p=custom&do=requestmirror&vid=%s&mirror=%s' % (URL['base'], params['vid'], i+1))
	else:
		if(soup.find('iframe')):
			mirrors.append(url)
		else:
			mirrors.append('%sajax.php?p=video&do=getplayer&vid=%s' % (URL['base'], params['vid']))
	
	mirrors.reverse()
	
	for mirror in mirrors:
		try:
			if(mirror == url):
				mirrorUrl = soup.find('iframe').attrs['src']
			else:
				mirrorUrl = BeautifulSoup(http_req(mirror)).find('iframe').attrs['src']
			mirrorUrl = re.sub(r'https?:\/\/(?:www\.)?.+?\.li/?\??', '', mirrorUrl)
		except:
			mirrorUrl = ''
		
		if(re.search(r'mail.ru', mirrorUrl)):
			try:
				source = BeautifulSoup(http_req(mirrorUrl)).find_all('script', {'type': 'text/javascript'})
				jsonUrl = re.search(r'"metadataUrl":"(.+?)"', str(source)).group(1)
				req = http_req(jsonUrl, True)
				jsonSource = json.loads(req['source'])
				
				for source in jsonSource['videos']:
					name = '%s %s' % ('[mail.ru]', source['key'])
					link = '%s|Cookie=%s' % (source['url'], urllib.quote_plus(req['cookie']))
					item = {'name': name, 'url': link}
					sources.append(item)
			except: pass
		
		elif(re.search(r'vk.com', mirrorUrl)):
			try:
				from resources.lib.getvk import getVkVideos
				for source in getVkVideos(http_req(mirrorUrl)):
					item = {'name': source[0], 'url': source[1]}
					sources.append(item)
			except: pass
		
		elif(re.search(r'ok.ru', mirrorUrl)):
			try:
				id = re.search('\d+', mirrorUrl).group(0)
				jsonUrl = 'http://ok.ru/dk?cmd=videoPlayerMetadata&mid=' + id
				jsonSource = json.loads(http_req(jsonUrl))
				
				for source in jsonSource['videos']:
					name = '%s %s' % ('[ok.ru]', plugin.en2ro(source['name']))
					link = '%s|User-Agent=%s&Accept=%s&Referer=%s'
					link = link % (source['url'], HEADERS['User-Agent'], HEADERS['Accept'], urllib.quote_plus(URL['base']))
					
					item = {'name': name, 'url': link}
					sources.append(item)
			except: pass
	return sources
Exemple #4
0
def getSources(url):
    sources = []

    soup = BeautifulSoup(http_req(url))

    params = {}

    try:
        params['vid'] = re.search(r'_([0-9a-z]+).html?', url).group(1)
    except:
        html = soup.find_all('script', {'type': 'text/javascript'})
        html = "".join(line.strip() for line in str(html).split("\n"))
        html = re.findall(r'\$\.ajax\({.+?data: {(.+?)}', html)
        html = html[1].replace('"', '').split(',')

        for parameter in html:
            key, value = parameter.split(':')
            params[key] = value.strip()

    mirrors = []

    multiMirrors = soup.find('ul', {'id': 'menu-bar'})
    if multiMirrors: multiMirrors = multiMirrors.find_all('a')

    if (multiMirrors):
        for i in range(len(multiMirrors)):
            mirrors.append(
                '%sajax.php?p=custom&do=requestmirror&vid=%s&mirror=%s' %
                (URL['base'], params['vid'], i + 1))
    else:
        if (soup.find('iframe')):
            mirrors.append(url)
        else:
            mirrors.append('%sajax.php?p=video&do=getplayer&vid=%s' %
                           (URL['base'], params['vid']))

    mirrors.reverse()

    for mirror in mirrors:
        try:
            if (mirror == url):
                mirrorUrl = soup.find('iframe').attrs['src']
            else:
                mirrorUrl = BeautifulSoup(
                    http_req(mirror)).find('iframe').attrs['src']
            mirrorUrl = re.sub(r'https?:\/\/(?:www\.)?.+?\.li/?\??', '',
                               mirrorUrl)
        except:
            mirrorUrl = ''

        if (re.search(r'mail.ru', mirrorUrl)):
            try:
                source = BeautifulSoup(http_req(mirrorUrl)).find_all(
                    'script', {'type': 'text/javascript'})
                jsonUrl = re.search(r'"metadataUrl":"(.+?)"',
                                    str(source)).group(1)
                req = http_req(jsonUrl, True)
                jsonSource = json.loads(req['source'])

                for source in jsonSource['videos']:
                    name = '%s %s' % ('[mail.ru]', source['key'])
                    link = '%s|Cookie=%s' % (source['url'],
                                             urllib.quote_plus(req['cookie']))
                    item = {'name': name, 'url': link}
                    sources.append(item)
            except:
                pass

        elif (re.search(r'vk.com', mirrorUrl)):
            try:
                from resources.lib.getvk import getVkVideos
                for source in getVkVideos(http_req(mirrorUrl)):
                    item = {'name': source[0], 'url': source[1]}
                    sources.append(item)
            except:
                pass

        elif (re.search(r'ok.ru', mirrorUrl)):
            try:
                id = re.search('\d+', mirrorUrl).group(0)
                jsonUrl = 'http://ok.ru/dk?cmd=videoPlayerMetadata&mid=' + id
                jsonSource = json.loads(http_req(jsonUrl))

                for source in jsonSource['videos']:
                    name = '%s %s' % ('[ok.ru]', plugin.en2ro(source['name']))
                    link = '%s|User-Agent=%s&Accept=%s&Referer=%s'
                    link = link % (source['url'], HEADERS['User-Agent'],
                                   HEADERS['Accept'],
                                   urllib.quote_plus(URL['base']))

                    item = {'name': name, 'url': link}
                    sources.append(item)
            except:
                pass
    return sources