Beispiel #1
0
def get_link(url, media):
    response = Request().get(url)
    sources = re.search(r'sources:\s?(.*?),\n', response)
    sources = helper.convert_js_2_json(sources.group(1).encode('utf-8'))

    if sources:
        try:
            sources = sorted(sources,
                             key=lambda elem: int(elem['label'][0:-1]),
                             reverse=True)
        except:
            pass

        url = ""
        if len(sources) > 0:
            for source in sources:
                url = source.get('file')
                break

        # if re.search('pegasus-pop.com', url):
        #     header = {
        # 'Origin': 'https://live.90m.tv',
        # 'User-Agent': "Chrome/59.0.3071.115 Safari/537.36",
        # 'referer': media.get('originUrl')
        # }
        # return url + "|%s" % urlencode(header)

    url, mtype = cors.get_link(url, media)

    return url
Beispiel #2
0
def get_link(url):
    response = Request().get(url)
    sources = re.search(r'sources:\s(\[.*\]),', response)
    if sources:
        sources = helper.convert_js_2_json(sources.group(1))
        url = sources[0].get('src')

    return url, 'aparat'
Beispiel #3
0
def get_link(url):
    response = Request().get(url)
    sources = re.search(r'sources:\s?(.*?),\n', response)
    sources = helper.convert_js_2_json(sources.group(1).encode('utf-8'))
    if sources:
        try:
            sources = sorted(sources,
                             key=lambda elem: int(elem['label'][0:-1]),
                             reverse=True)
        except:
            pass

        if len(sources) > 0:
            for source in sources:
                return source.get('file')
Beispiel #4
0
def get_link(url, media):
    request = Request()
    base_url = urlparse(media.get('originUrl'))
    base_url = base_url.scheme + '://' + base_url.netloc
    header = {
        'Referer': url,
        'User-Agent': "Chrome/59.0.3071.115 Safari/537.36",
        'Origin': base_url
    }

    print "Apply iframeembed url %s" % url

    resp = request.get(url, headers=header)
    req = request.get_request()
    if req.history:
        r_url = req.url
        rurl = urlparse(r_url)
        rurl = rurl.scheme + '://' + rurl.netloc
        rid = re.search(r'id=(.*)', r_url).group(1)
        rurl = "{}/getLinkStreamMd5/{}".format(rurl, rid)
        sources = request.get(rurl, headers=header)
        sources = json.loads(sources)
        print 11111111111111111111111111
        print sources
    else:
        sources = re.search(r'sources\s?[=:]\s?(\[.*?\])', resp, re.DOTALL)
        if sources:
            sources = "".join([s for s in sources.group(1).splitlines() if s.strip("\r\n")])
            sources = re.sub(r'\s+', '', sources)
            sources = helper.convert_js_2_json(sources)
            print 2222222222222222222222222
        print sources

    if sources:
        if len(sources) > 1:
            listitems = []
            for i in sources:
                listitems.append("%s (%s)" % (i.get('label'), i.get('file')))
            index = xbmcgui.Dialog().select("Select stream", listitems)
            if index == -1:
                return None, None
            else:
                return sources[index].get('file') + "|%s" % urlencode(header), sources[index].get('label')
        else:
            return sources[0].get('file') + "|%s" % urlencode(header), sources[0].get('label')

    return None, None
Beispiel #5
0
def get_link(url, media):
    print "*********************** Apply xemtivimienphi url %s" % url
    header = {
        'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66",
        'referer': media.get('originUrl')
    }
    response = Request().get(url, headers=header)
    source = re.search(r'source:\s?"(.*?)",', response)
    if source:
        url = source.group(1)
    sources = re.search(r'sources:\s?(\[.*?\])', response)

    if sources:
        url = helper.convert_js_2_json(sources.group(1))[0]

    source = re.search(r"video.src\s?=\s'(.*?)'", response)
    if source:
        url = source.group(1)

    return url, 'OnlineTv'
Beispiel #6
0
    def get_link(self, response, movie_url):
        movie = {
            'group': {},
            'episode': [],
            'links': [],
        }

        sources = re.search(r'(eval\(function\(p,a,c,k,e,d\).*)', response)
        if sources:
            sources = sources.group(1)
            sources = Packer().unpack(sources)
            sources = re.search('sources:(.*?]),', sources)

            sources = re.sub(r'(?<={|,)([a-zA-Z][a-zA-Z0-9]*)(?=:)', r'"\1"',
                             sources.group(1))
            try:
                sources = json.loads(sources)
            except:
                return movie
            score = {
                'sd': 1,
                'hd': 2,
                '360p': 1,
                '480p': 2,
                '720p': 3,
                '1080p': 3
            }
            if len(sources) > 1:
                try:
                    sources = sorted(
                        sources,
                        key=lambda elem: elem['label'].lower(
                        ) in score and score[elem['label'].lower()] or 3,
                        reverse=True)
                except:
                    pass
            for source in sources:
                movie['links'].append({
                    'link':
                    source['file'].replace('\\', ''),
                    'title':
                    'Link %s' % source['type'].encode('utf-8'),
                    'type':
                    source['type'].encode('utf-8'),
                    'originUrl':
                    movie_url,
                    'resolve':
                    False
                })

        sources = re.search(r'sources:\s?(\[.*?\]),', response)
        if sources:
            sources = helper.convert_js_2_json(sources.group(1))
            try:
                sources = sorted(sources,
                                 key=lambda elem: int(elem['label'][0:-1]),
                                 reverse=True)
            except:
                pass
            for source in sources:
                movie['links'].append({
                    'link':
                    source.get('file').replace('\\', ''),
                    'title':
                    'Link {}'.format(source.get('label')).encode('utf8'),
                    'type':
                    source.get('type').encode('utf-8'),
                    'originUrl':
                    movie_url,
                    'resolve':
                    False
                })

        # sources = re.search(r'data-lazy-src="(.*?)"', response)
        # if sources:
        #     source = sources.group(1)
        #     print source
        #
        #     movie['links'].append({
        #         'link': source,
        #         'title': 'Link Unknow',
        #         'type': 'Unknow',
        #         'originUrl': movie_url,
        #         'resolve': False
        #     })

        sources = re.search('<iframe.*src="(http.*?)" frameborder', response)
        if sources:
            source = sources.group(1)

            movie['links'].append({
                'link': source,
                'title': 'Link Unknow',
                'type': 'Unknow',
                'originUrl': movie_url,
                'resolve': False
            })
            # response = Request().get(sources.group(1))
            # return self.get_link(response, movie_url)

        return movie
Beispiel #7
0
    def get_link(self, response, originUrl):
        movie = {
            'group': {},
            'episode': [],
            'links': [],
        }

        sources = re.findall(r"<iframe.*?src=['|\"](http.*?)['|\"]\s?",
                             response)
        if len(sources) > 0:
            for source in sources:
                if source in 'http://lb.animehay.tv/play/' and len(
                        source) == len('http://lb.animehay.tv/play/'):
                    continue

                movie['links'].append({
                    'link': source,
                    'title': 'Link direct',
                    'type': 'mp4',
                    'resolve': False
                })

        sources = re.search(r'player.setup.*"sources":\s?(\[.*?\])', response,
                            re.DOTALL)

        if sources:
            sources = json.loads(sources.group(1))
            if sources and len(sources) > 0:
                for source in sources:
                    movie['links'].append({
                        'link': source['file'],
                        'title': 'Link %s' % source['label'],
                        'type': source['type'],
                        'resolve': False
                    })

        sources = re.search(
            r"<iframe.*?src=['|\"](.*animehay.tv/play/{5,}.*?)['|\"]\s?",
            response)
        if sources:
            res = Request()
            if 'key=' in sources.group(1):
                vkey = re.search('key=(.*)', sources.group(1)).group(1)
                # http://vl.animehay.tv/initPlayer/f555b31844becd2e378d4978457014521af38ab8e66834ade1062b44827ef642
                resp = res.post('http://vl.animehay.tv/initPlayer/%s' % vkey)
                resp = json.loads(resp)
                if 'availablePlayers' not in resp:
                    return movie

                if 'p2pdrive' in resp['availablePlayers']:
                    data = json.loads(
                        res.post('http://vl.animehay.tv/getDataPlayer/%s/%s' %
                                 ('p2pdrive', vkey)))
                    source = data['data']

                    if source:
                        movie['links'].append({
                            'link': source,
                            'title': 'Link p2pdrive',
                            'type': 'hls',
                            'resolve': False
                        })

                if 'gphoto' in resp['availablePlayers']:
                    data = json.loads(
                        res.post('http://vl.animehay.tv/getDataPlayer/%s/%s' %
                                 ('gphoto', vkey)))
                    data = res.get(data['data'])
                    sources = json.loads(
                        re.search(r"var\s?sources\s?=\s?(\[.*?\])",
                                  data).group(1))
                    if sources and len(sources) > 0:
                        for source in sources:
                            movie['links'].append({
                                'link':
                                source['file'],
                                'title':
                                'Link %s' % source['label'],
                                'type':
                                'mp4',
                                'resolve':
                                False
                            })

                if 'fembed' in resp['availablePlayers']:
                    data = json.loads(
                        res.post('http://vl.animehay.tv/getDataPlayer/%s/%s' %
                                 ('fembed', vkey)))
                    data = res.get(data['data'])
                    source = re.search(r"<iframe.*?src=['|\"](.*?)['|\"]\s?",
                                       data).group(1)
                    if source:
                        movie['links'].append({
                            'link': source,
                            'title': 'Link fembed',
                            'type': 'mp4',
                            'resolve': False
                        })

                if 'okru' in resp['availablePlayers']:
                    data = json.loads(
                        res.post('http://vl.animehay.tv/getDataPlayer/%s/%s' %
                                 ('okru', vkey)))
                    data = res.get(data['data'])
                    source = re.search(r"<iframe.*?src=['|\"](.*?)['|\"]\s?",
                                       data).group(1)
                    if source:
                        movie['links'].append({
                            'link': source,
                            'title': 'Link okru',
                            'type': 'mp4',
                            'resolve': False
                        })

                if 'openload' in resp['availablePlayers']:
                    data = json.loads(
                        res.post('http://vl.animehay.tv/getDataPlayer/%s/%s' %
                                 ('openload', vkey)))
                    data = res.get(data['data'])
                    source = re.search(r"<iframe.*?src=['|\"](.*?)['|\"]\s?",
                                       data).group(1)
                    if source:
                        movie['links'].append({
                            'link': source,
                            'title': 'Link openload',
                            'type': 'mp4',
                            'resolve': False
                        })
                return movie
            else:
                res.get(sources.group(1))
                link = res.get_request().url
                vkey = re.search('id=(.*)', link)
                if vkey:
                    vkey = vkey.group(1)
                    base_url = urlparse(link)
                    base_url = base_url.scheme + '://' + base_url.netloc
                    urlVideo = "{}/hls/{}/{}.playlist.m3u8".format(
                        base_url, vkey, vkey)

                    movie['links'].append({
                        'link': urlVideo,
                        'title': 'Link p2pdrive',
                        'type': 'hls',
                        'resolve': False,
                        'originUrl': originUrl
                    })

        sources = re.search(r'player.setup\((.*?)\);', response, re.DOTALL)
        if sources:
            source = sources.group(1)
            source = re.search(r'"file":\s"(.*?)",', source)
            movie['links'].append({
                'link': source.group(1),
                'title': 'Link direct',
                'type': 'mp4',
                'resolve': False
            })

        sources = re.search(r"var\s?source\s?=\s?(\[.*?\]);", response)
        if sources:
            sources = helper.convert_js_2_json(sources.group(1))
            for source in sources:
                movie['links'].append({
                    'link':
                    source.get('file'),
                    'title':
                    'Link %s' % py2_encode(source.get('label')),
                    'type':
                    py2_encode(source.get('type')),
                    'originUrl':
                    originUrl,
                    'resolve':
                    False
                })

        sources = re.search(r'var\s?source\s?=\s?"(\[.*?\])";', response)
        if sources:
            sources = helper.convert_js_2_json(
                sources.group(1).replace('\\', ''))
            for source in sources:
                movie['links'].append({
                    'link':
                    source.get('file'),
                    'title':
                    'Link %s' % py2_encode(source.get('label')),
                    'type':
                    py2_encode(source.get('type')),
                    'originUrl':
                    originUrl,
                    'resolve':
                    False
                })
        # sources = re.search('<script rel="nofollow" src="(.*)" async>', response)
        # if sources:
        #     response = Request().get(sources.group(1))
        #     if 'links:' in response:
        #         sources = json.loads(re.search('links: (.*?),', response).group(1))
        #         for key, value in sources.items():
        #             if value:
        #                 label = key[1:].encode('utf-8')
        #                 movie['links'].append({
        #                     'link': value,
        #                     'title': 'Link %s' % label,
        #                     'type': label,
        #                     'resolve': True
        #                 })
        #
        #         movie['links'] = sorted(movie['links'], key=lambda elem: int(elem['type']), reverse=True)

        return movie
Beispiel #8
0
    def get_link(self, response, originUrl):
        movie = {
            'group': {},
            'episode': [],
            'links': [],
        }

        # subitle
        subtitle = None
        sub_re = re.search(r'tracks:\s?(\[.*\]),', response, re.DOTALL)
        if sub_re:
            try:
                sub_re = re.search(r'file:\s?"(.*?)",', sub_re.group(1))
                subtitle = sub_re.group(1)
            except:
                pass

        sources = re.search(r'sources:\s?(.*?)\n', response)
        if sources:
            try:
                sources = helper.convert_js_2_json(
                    sources.group(1).replace('}],', '}]'))
                sources = json.loads(sources)
                sources = sorted(sources,
                                 key=lambda elem: int(elem['label'][0:-1]),
                                 reverse=True)
            except:
                pass

            if len(sources) > 0:
                for source in sources:
                    label = 'label' in source and source['label'] or ''
                    movie['links'].append({
                        'link':
                        self.parse_link(source['file']),
                        'title':
                        'Link %s' % label.encode('utf-8'),
                        'type':
                        label.encode('utf-8'),
                        'resolve':
                        False,
                        'subtitle':
                        subtitle,
                        'originUrl':
                        originUrl
                    })

            return movie

        sources = re.search('<iframe.*src=(".*?")', response)
        if sources is not None:
            source = sources.group(1).replace('"', '')
            if source:
                movie['links'].append({
                    'link':
                    source,
                    'title':
                    'Link %s' % source.encode('utf-8'),
                    'type':
                    'Unknow',
                    'resolve':
                    False,
                    'originUrl':
                    originUrl
                })
                return movie

        return movie