Ejemplo n.º 1
0
def get_link_deprecated(url, originURL):
    req = Request()
    response = req.get(url)

    # found playlist
    if re.search('EXT-X-STREAM-INF', response):
        resolutions = re.findall('RESOLUTION=\d+x(\d+)', response)
        matches = re.findall('(http.*)\r', response)
        if '1080' in resolutions:
            idx = next(
                (resolutions.index(i) for i in resolutions if '1080' == i), -1)
            url = matches[idx]
        elif '720' in resolutions:
            idx = next(
                (resolutions.index(i) for i in resolutions if '720' == i), -1)
            url = matches[idx]
        elif '480' in resolutions:
            idx = next(
                (resolutions.index(i) for i in resolutions if '480' == i), -1)
            url = matches[idx]

        response = Request().get(url,
                                 headers={'origin': 'http://www.phimmoi.net'})

    links = re.findall('(https?://(?!so-trym).*)\r', response)
    if links:
        media_type = 'hls4'
        arequest = AsyncRequest(request=req, retry=2)
        results = arequest.head(links,
                                headers={
                                    'origin': 'http://www.phimmoi.net',
                                    'referer': originURL
                                },
                                redirect=False)

        for i in range(len(links)):
            try:
                response = response.replace(links[i],
                                            results[i].headers['location'])
            except:
                print(links[i], results[i].headers)
    else:
        media_type = 'hls3'

    stream_url = PasteBin().dpaste(response, name=url, expire=60)
    playlist = "#EXTM3U\n#EXT-X-VERSION:3\n"
    playlist += "#EXT-X-STREAM-INF:BANDWIDTH=3998000,RESOLUTION=9999x9999\n"
    playlist += "%s\n" % stream_url
    url = PasteBin().dpaste(playlist, name=url, expire=60)
    if 'hls' == media_type:
        url += '|referer=' + urllib.quote_plus(originURL)

    return url, media_type
Ejemplo n.º 2
0
    def get_hydrax_stream(self, stream):
        txt = "#EXTM3U\n#EXT-X-VERSION:4\n#EXT-X-PLAYLIST-TYPE:VOD\n#EXT-X-TARGETDURATION:" + stream[
            'duration'] + "\n#EXT-X-MEDIA-SEQUENCE:0\n"
        links = []
        if stream['type'] == 2:
            i, j = 0, 0
            for ranges in stream['multiRange']:
                p = 0
                for xrange in ranges:
                    txt += "#EXTINF:%s,\n" % stream['extinf'][i]
                    txt += "#EXT-X-BYTERANGE:%s\n" % xrange
                    g, y = xrange.split('@')
                    g = int(g)
                    y = int(y)
                    f = i > 0 and p + 1 or y
                    p = y and f + g - 1 or g - 1
                    part = '%s-%s.js' % (f, p)

                    url = "%s/%s/%s/%s/%s/%s" % (
                        'http://immortal.hydrax.net',
                        stream['id'],
                        stream['range'][j],
                        stream['expired'],
                        stream['multiData'][j]['file'],
                        part
                    )

                    links.append(url)
                    txt += "%s\n" % url
                    i += 1
                j += 1

        txt += "#EXT-X-ENDLIST\n"

        arequest = AsyncRequest()
        results = arequest.head(links, headers={
            'origin': 'http://www.phimmoi.net'
        })
        for i in range(len(links)):
            try:
                txt.replace(links[i], results[i].headers['location'])
            except:
                print(links[i])
                # print(results[i].headers)

        url = PasteBin().dpaste(txt, name=stream['id'], expire=60)
        return url
Ejemplo n.º 3
0
    def get_stream(self, url):
        req = Request()
        r = req.get(url)
        str = ""
        links = []
        for line in r.splitlines():
            if len(line) > 0:
                if re.match('http', line):
                    links.append(line)
                str += '%s\n' % line

        arequest = AsyncRequest(request=req)
        results = arequest.head(links)
        for i in range(len(links)):
            str = str.replace(links[i], results[i].headers['Location '])

        url = PasteBin().dpaste(str, name='animiehay', expire=60)
        return url
Ejemplo n.º 4
0
    def get_stream(self, url):
        req = Request()
        r = req.get(url)
        str = ""
        links = []
        for line in r.splitlines():
            if len(line) > 0:
                if re.match('http', line):
                    links.append(line)
                str += '%s\n' % line

        arequest = AsyncRequest(request=req)
        results = arequest.head(links)
        for i in range(len(links)):
            try:
                str = str.replace(links[i], results[i].headers['Location '])
            except:
                pass

        url = PasteBin().dpaste(str, name='animiehay', expire=60)
        return url
Ejemplo n.º 5
0
    def get_hls_playlist_stream(self, url):
        req = Request()
        response = req.get(url)

        links = re.findall('(https?://(?!so-trym).*)\r', response)
        if links:
            arequest = AsyncRequest(request=req)
            results = arequest.head(links, headers={
                'origin': 'http://www.phimmoi.net',
                'referer': self.originURL
            }, redirect=False)

            for i in range(len(links)):
                response = response.replace(links[i], results[i].headers['location'])

        links = re.findall('(http://so-trym.*)\r', response)
        if links:
            for i in range(len(links)):
                url = '%s|referer=%s' % (links[i], self.originURL)
                response = response.replace(links[i], url)

        url = PasteBin().dpaste(response, name=url, expire=60)
        return url