Ejemplo n.º 1
0
 def __getResolutionList__(self, url):
     ret = []
     txt = requests.get(url).text
     array = txt.split("#EXT-X-STREAM-INF")
     for item in array:
         if "RESOLUTION=" not in item:
             continue
         stream = VideoStreamUrl()
         stream.codec = stringHelper.getSub(item, "CODECS=\"", "\"")
         stream.m3u8Url = "http" + stringHelper.getSubOnlyStart(item, "http").strip()
         stream.resolution = stringHelper.getSub(item, "RESOLUTION=", "http").strip()
         stream.resolution = stream.resolution.split(',')[0]
         stream.resolutions = stream.resolution.split("x")
         ret.append(stream)
     return ret
Ejemplo n.º 2
0
    def parseUrl(self, url):
        etype = Type.Null
        sid = ""
        if "tidal.com" not in url:
            return etype, sid

        url = url.lower()
        if 'artist' in url:
            etype = Type.Artist
        if 'album' in url:
            etype = Type.Album
        if 'track' in url:
            etype = Type.Track
        if 'video' in url:
            etype = Type.Video
        if 'playlist' in url:
            etype = Type.Playlist
        if 'mix' in url:
            etype = Type.Mix

        if etype == Type.Null:
            return etype, sid

        sid = stringHelper.getSub(url, etype.name.lower() + '/', '/')
        return etype, sid
Ejemplo n.º 3
0
    def getVideoStreamUrl(self, video_id, quality):
        paras = {
            "videoquality": "HIGH",
            "playbackmode": "STREAM",
            "assetpresentation": "FULL"
        }
        msg, data = self.api.__get__(
            'videos/' + str(video_id) + "/playbackinfopostpaywall", paras)
        if msg is not None:
            return msg, None

        if "vnd.tidal.emu" in data['manifestMimeType']:
            manifest = json.loads(
                base64.b64decode(data['manifest']).decode('utf-8'))
            url = manifest['urls'][0]

            qualityArray = []
            txt = requests.get(url).text
            array = txt.split("#EXT-X-STREAM-INF")
            for item in array:
                if "RESOLUTION=" not in item:
                    continue
                stream = {}
                stream['codec'] = stringHelper.getSub(item, "CODECS=\"", "\"")
                stream['m3u8Url'] = "http" + stringHelper.getSubOnlyStart(
                    item, "http").strip()
                stream['resolution'] = stringHelper.getSub(
                    item, "RESOLUTION=", "http").strip()
                if ',FRAME-RATE' in stream['resolution']:
                    stream['resolution'] = stream[
                        'resolution'][:stream['resolution'].find(',FRAME-RATE'
                                                                 )]
                stream['resolutions'] = stream['resolution'].split("x")
                qualityArray.append(stream)

            icmp = int(quality)
            index = 0
            for item in qualityArray:
                if icmp >= int(item['resolutions'][1]):
                    break
                index += 1
            if index >= len(qualityArray):
                index = len(qualityArray) - 1
            return "", qualityArray[index]
        return "", None