Beispiel #1
0
    def _get_refresh_token(self):
        token = PluginCache.get_by_key("token")
        validity_token = PluginCache.get_by_key("validityToken")
        state = PluginCache.get_by_key("state")

        json_payload = {
            "authorizationGrant": {
                "authorizationCode": token,
                "validityToken": validity_token,
                "state": state
            }
        }

        r = Utils.make_request(
            self.session,
            method="POST",
            url=
            "https://obo-prod.oesp.telenettv.be/oesp/v4/BE/nld/web/authorization",
            headers=self.construct_header(),
            data=json_payload)

        json_data = r.json()

        refresh_token = json_data["refreshToken"]

        PluginCache.set_data({
            "refreshToken": refresh_token,
        })
Beispiel #2
0
    def __init__(self, session, logger_instance=None):
        super(self.__class__, self).__init__(session)
        self.logger = logger_instance

        self.device_id = PluginCache.get_by_key("deviceId")
        self.oesp_token = PluginCache.get_by_key("oespToken")
        self.shared_profile_id = PluginCache.get_by_key("sharedProfileId")
        self.license_token = ""

        if self.must_login():
            self.web_authorization()
            self.authorize()
            self.login()
            self.request_tokens()

        self._check_oesp_validity()
Beispiel #3
0
    def _get_oesp_token(self):
        refresh_token = PluginCache.get_by_key("refreshToken")

        json_payload = {
            "refreshToken": refresh_token,
            "username": self.username
        }

        r = Utils.make_request(
            self.session,
            method="POST",
            url=
            "https://obo-prod.oesp.telenettv.be/oesp/v4/BE/nld/web/session?token=true",
            headers=self.construct_header(),
            data=json_payload)

        json_data = r.json()

        oesp_token = json_data["oespToken"]
        shared_profile_id = json_data["customer"]["sharedProfileId"]
        entitlements = json_data["entitlements"]

        PluginCache.set_data({
            "oespToken": oesp_token,
            "sharedProfileId": shared_profile_id,
            "entitlements": entitlements
        })
Beispiel #4
0
    def create_manifest_url(self, base_uri, channel):
        self.license_token = PluginCache.get_by_key("licenseToken")

        streaming_format = StreamingFormat.get_streaming_format()
        if streaming_format == StreamingFormat.MPEG_DASH:
            url = Stream.BASE_URL_MPD
        elif streaming_format == StreamingFormat.SMOOTH_STREAM:
            url = Stream.BASE_URL_HSS
        else:
            url = ""

        formatted_url = url.format(base_uri, channel, self.license_token)

        return formatted_url
Beispiel #5
0
    def get_channels(self):
        r = Utils.make_request(
            self.session,
            method="GET",
            headers=self.construct_header(),
            url="https://obo-prod.oesp.telenettv.be/oesp/v4/BE/nld/web/channels?"
            "includeInvisible=false"
            "&sort=channelNumber")

        json_data = r.json()

        useful_channel_data = []
        entitlements = PluginCache.get_by_key("entitlements")

        if not entitlements:
            return useful_channel_data

        if "channels" in json_data:
            fetched_channel_data = json_data["channels"]
            for channel_data in fetched_channel_data:
                station = channel_data["stationSchedules"][0]["station"]
                video_streams = station["videoStreams"]

                if video_streams:
                    channel = Channel(channel_data["id"], station["id"],
                                      channel_data["title"],
                                      channel_data["channelNumber"],
                                      bool(station["hasLiveStream"]),
                                      station["entitlements"])

                    if not any(x in entitlements
                               for x in channel.entitlements):
                        continue

                    HLS_stream = {}
                    DASH_stream = {}
                    HSS_stream = {}

                    for video_stream in video_streams:
                        if "Orion-HLS" in video_stream["assetTypes"]:
                            HLS_stream = Stream(video_stream["streamingUrl"],
                                                video_stream["contentLocator"],
                                                video_stream["protectionKey"])

                        if "Orion-DASH" in video_stream["assetTypes"]:
                            DASH_stream = Stream(
                                video_stream["streamingUrl"],
                                video_stream["contentLocator"],
                                video_stream["protectionKey"])

                        if "Orion-HSS" in video_stream["assetTypes"]:
                            HSS_stream = Stream(video_stream["streamingUrl"],
                                                video_stream["contentLocator"],
                                                video_stream["protectionKey"])

                    thumbnail = [
                        img["url"] for img in station["images"]
                        if img["assetType"] == "station-logo-xlarge"
                    ][0]

                    imageStream = [
                        img["url"] for img in station["images"]
                        if img["assetType"] == "imageStream"
                    ][0]

                    channel.thumbnail = thumbnail
                    channel.stream_thumbnail = imageStream
                    channel.stream_DASH = DASH_stream
                    channel.stream_HLS = HLS_stream
                    channel.stream_HSS = HSS_stream

                    useful_channel_data.append(channel)

        return useful_channel_data