def get_stream_from_url(self, url):
        cred = helperobjects.Credentials(self._addon)
        if not cred.are_filled_in():
            self._addon.openSettings()
            cred.reload()
        url = urlparse.urljoin(self._vrt_base, url)
        r = self._session.post(
            "https://accounts.eu1.gigya.com/accounts.login", {
                'loginID': cred.username,
                'password': cred.password,
                'APIKey': self._API_KEY,
                'targetEnv': 'jssdk',
                'includeSSOToken': 'true',
                'authMode': 'cookie'
            })

        logon_json = r.json()
        if logon_json['errorCode'] == 0:
            uid = logon_json['UID']
            sig = logon_json['UIDSignature']
            ts = logon_json['signatureTimestamp']

            headers = {
                'Content-Type': 'application/json',
                'Referer': self._vrtnu_base_url
            }
            data = '{"uid": "%s", ' \
                   '"uidsig": "%s", ' \
                   '"ts": "%s", ' \
                   '"email": "%s"}' % (uid, sig, ts, cred.username)

            response = self._session.post("https://token.vrt.be",
                                          data=data,
                                          headers=headers)
            securevideo_url = "{0}.securevideo.json".format(
                self.__cut_slash_if_present(url))
            securevideo_response = self._session.get(securevideo_url,
                                                     cookies=response.cookies)
            json = securevideo_response.json()

            mzid = list(json.values())[0]['mzid']
            final_url = urlparse.urljoin(self._BASE_GET_STREAM_URL_PATH, mzid)

            stream_response = self._session.get(final_url)
            hls = self.__get_hls(stream_response.json()['targetUrls']).replace(
                "https", "http")
            subtitle = None
            if self._addon.getSetting("showsubtitles") == "true":
                subtitle = self.__get_subtitle(
                    stream_response.json()['subtitleUrls'])
            return helperobjects.StreamURLS(hls, subtitle)
        else:
            xbmcgui.Dialog().ok(self._addon.getAddonInfo('name'),
                                self._addon.getLocalizedString(32051),
                                self._addon.getLocalizedString(32052))
Esempio n. 2
0
    def _get_session_and_token_from_(self):
        session = requests.session()
        token = None
        cred = helperobjects.Credentials(self._kodi_wrapper)
        if not cred.are_filled_in():
            self._kodi_wrapper.open_settings()
            cred.reload()
        
        r = session.post('https://accounts.vrt.be/accounts.login',
                               {'loginID': cred.username, 'password': cred.password, 'APIKey': self._API_KEY,
                                'sessionExpiration': '-1',
                                'targetEnv': 'jssdk',
                                'include': 'profile,data,emails,subscriptions,preferences,',
                                'includeUserInfo': 'true',
                                'loginMode': 'standard',
                                'lang': 'nl-inf',
                                'source': 'showScreenSet',
                                'sdk': 'js_latest',
                                'authMode': 'cookie',
                                'format': 'json'})

        session.get('https://token.vrt.be/vrtnuinitlogin?provider=site&destination=https://www.vrt.be/vrtnu/')

        logon_json = r.json()

        if logon_json['errorCode'] == 0:
            uid = logon_json['UID']
            sig = logon_json['UIDSignature']
            ts = logon_json['signatureTimestamp']

            data = {'UID': uid, 
                   'UIDSignature': sig,
                   'signatureTimestamp': ts ,
                   'client_id': 'vrtnu-site', 
                   'submit': 'submit'
                   } 

            response = session.post('https://login.vrt.be/perform_login', data=data)

            vrt_player_token_url = session.post(self._TOKEN_URL, headers={'Content-Type': 'application/json'})

            token = vrt_player_token_url.json()['vrtPlayerToken']
            return (session, token)
        else:
            title = self._kodi_wrapper.get_localized_string(32051)
            message = self._kodi_wrapper.get_localized_string(32052)
            self._kodi_wrapper.show_ok_dialog(title, message)
Esempio n. 3
0
    def _get_new_xvrttoken(self, path, get_roaming_token):
        cred = helperobjects.Credentials(self._kodi_wrapper)
        if not cred.are_filled_in():
            self._kodi_wrapper.open_settings()
            cred.reload()
        data = {
            'loginID': cred.username,
            'password': cred.password,
            'sessionExpiration': '-1',
            'APIKey': self._API_KEY,
            'targetEnv': 'jssdk'
        }
        logon_json = requests.post(self._LOGIN_URL, data).json()
        token = None
        if logon_json['errorCode'] == 0:
            session = logon_json['sessionInfo']
            login_token = logon_json['sessionInfo']['login_token']
            login_cookie = ''.join(('glt_', self._API_KEY, '=', login_token))
            payload = {
                'uid': logon_json['UID'],
                'uidsig': logon_json['UIDSignature'],
                'ts': logon_json['signatureTimestamp'],
                'email': cred.username
            }
            headers = {
                'Content-Type': 'application/json',
                'Cookie': login_cookie
            }
            cookie_jar = requests.post(self._TOKEN_GATEWAY_URL,
                                       headers=headers,
                                       json=payload).cookies

            xvrttoken = TokenResolver._create_token_dictionary(cookie_jar)
            token = xvrttoken['X-VRT-Token']
            if get_roaming_token:
                xvrttoken = TokenResolver._get_roaming_xvrttoken(
                    login_cookie, xvrttoken)
                token = xvrttoken[
                    'X-VRT-Token'] if xvrttoken is not None else None
            json.dump(xvrttoken, open(path, 'w'))
        else:
            title = self._kodi_wrapper.get_localized_string(32051)
            message = self._kodi_wrapper.get_localized_string(32052)
            self._kodi_wrapper.show_ok_dialog(title, message)
        return token
    def _get_new_xvrttoken(self, path, get_roaming_token):
        cred = helperobjects.Credentials(self._kodi_wrapper)
        if not cred.are_filled_in():
            self._kodi_wrapper.open_settings()
            cred.reload()
        data = dict(
            loginID=cred.username,
            password=cred.password,
            sessionExpiration='-1',
            APIKey=self._API_KEY,
            targetEnv='jssdk',
        )
        logon_json = requests.post(self._LOGIN_URL,
                                   data,
                                   proxies=self._proxies).json()
        token = None
        if logon_json.get('errorCode') == 0:
            login_token = logon_json.get('sessionInfo',
                                         dict()).get('login_token')
            login_cookie = 'glt_%s=%s' % (self._API_KEY, login_token)
            payload = dict(
                uid=logon_json.get('UID'),
                uidsig=logon_json.get('UIDSignature'),
                ts=logon_json.get('signatureTimestamp'),
                email=cred.username,
            )
            headers = {
                'Content-Type': 'application/json',
                'Cookie': login_cookie
            }
            cookie_jar = requests.post(self._TOKEN_GATEWAY_URL,
                                       proxies=self._proxies,
                                       headers=headers,
                                       json=payload).cookies

            xvrttoken = TokenResolver._create_token_dictionary(cookie_jar)
            if get_roaming_token:
                xvrttoken = self._get_roaming_xvrttoken(xvrttoken)
            if xvrttoken is not None:
                token = xvrttoken.get('X-VRT-Token')
                json.dump(xvrttoken, open(path, 'w'))
        else:
            self._handle_error(logon_json, cred)
        return token
	def get_stream_from_url(self, url, kodi_wrapper):
            self._kodi_wrapper = kodi_wrapper
            self._vrt_base = 'https://www.vrt.be'
            self._API_KEY = '3_qhEcPa5JGFROVwu5SWKqJ4mVOIkwlFNMSKwzPDAh8QZOtHqu6L4nD5Q7lk0eXOOG'
            session = requests.session()
            cred = helperobjects.Credentials(self._kodi_wrapper)
            if not cred.are_filled_in():
                self._kodi_wrapper.open_settings()
                cred.reload()
            url = urlparse.urljoin(self._vrt_base, url)
            r = session.post('https://accounts.vrt.be/accounts.login',
                                   {'loginID': cred.username, 'password': cred.password, 'APIKey': self._API_KEY,
                                    'sessionExpiration': '-1',
                                    'targetEnv': 'jssdk',
                                    'include': 'profile,data,emails,subscriptions,preferences,',
                                    'includeUserInfo': 'true',
                                    'loginMode': 'standard',
                                    'lang': 'nl-inf',
                                    'source': 'showScreenSet',
                                    'sdk': 'js_latest',
                                    'authMode': 'cookie',
                                    'format': 'json'})

            session.get('https://token.vrt.be/vrtnuinitlogin?provider=site&destination=https://www.vrt.be/vrtnu/')

            logon_json = r.json()

            if logon_json['errorCode'] == 0:
                uid = logon_json['UID']
                sig = logon_json['UIDSignature']
                ts = logon_json['signatureTimestamp']

                data = {'UID': uid, 
                       'UIDSignature': sig,
                       'signatureTimestamp': ts ,
                       'client_id': 'vrtnu-site', 
                       'submit': 'submit'
                       } 

                response = session.post('https://login.vrt.be/perform_login', data=data)

                vrt_player_token_url = session.post(self._TOKEN_URL, headers={'Content-Type': 'application/json'})

                token = vrt_player_token_url.json()['vrtPlayerToken']
                print("###################################################")
                print("##############################o#####################")
                print("##############################ppp#####################")
                print("got token", token)
		# token_response = requests.post(self._TOKEN_URL)
		# token = token_response.json()['vrtPlayerToken']
		stream_response = requests.get(url, {'vrtPlayerToken': token, 'client':'vrtvideo' }).json()
                print(stream_response)
		target_urls = stream_response['targetUrls']
		found_url = False
		index = 0
		while not found_url and index < len(target_urls):
			item = target_urls[index]
			found_url = item['type'] == 'hls_aes'
			stream = item['url']
			index +=1
		return stream
    def get_stream_from_url(self, url):
        session = requests.session()
        cred = helperobjects.Credentials(self._kodi_wrapper)
        if not cred.are_filled_in():
            self._kodi_wrapper.open_settings()
            cred.reload()
        url = urlparse.urljoin(self._vrt_base, url)
        r = session.post(
            'https://accounts.vrt.be/accounts.login', {
                'loginID': cred.username,
                'password': cred.password,
                'APIKey': self._API_KEY,
                'sessionExpiration': '-1',
                'targetEnv': 'jssdk',
                'include': 'profile,data,emails,subscriptions,preferences,',
                'includeUserInfo': 'true',
                'loginMode': 'standard',
                'lang': 'nl-inf',
                'source': 'showScreenSet',
                'sdk': 'js_latest',
                'authMode': 'cookie',
                'format': 'json'
            })

        session.get(
            'https://token.vrt.be/vrtnuinitlogin?provider=site&destination=https://www.vrt.be/vrtnu/'
        )

        logon_json = r.json()

        if logon_json['errorCode'] == 0:
            uid = logon_json['UID']
            sig = logon_json['UIDSignature']
            ts = logon_json['signatureTimestamp']

            data = {
                'UID': uid,
                'UIDSignature': sig,
                'signatureTimestamp': ts,
                'client_id': 'vrtnu-site',
                'submit': 'submit'
            }

            response = session.post('https://login.vrt.be/perform_login',
                                    data=data)

            vrt_player_token_url = session.post(
                self._TOKEN_URL, headers={'Content-Type': 'application/json'})

            token = vrt_player_token_url.json()['vrtPlayerToken']

            url_response = session.get(url)
            strainer = SoupStrainer('div', {'class': 'vrtvideo videoplayer'})
            soup = BeautifulSoup(url_response.content,
                                 'html.parser',
                                 parse_only=strainer)
            vrt_video = soup.find(lambda tag: tag.name == 'div' and tag.get(
                'class') == ['vrtvideo'])

            data_publication_id = vrt_video['data-publicationid']
            data_video_id = vrt_video['data-videoid']
            final_url = self._STREAM_URL_PATH.format(data_publication_id,
                                                     data_video_id, token)

            stream_response = session.get(final_url)
            hls = self.__get_hls(stream_response.json()['targetUrls'])
            subtitle = None
            #if self._kodi_wrapper.get_setting('showsubtitles') == 'true':
            #    subtitle = self.__get_subtitle(stream_response.json()['subtitleUrls'])
            return helperobjects.StreamURLS(hls, subtitle)
        else:
            title = self._kodi_wrapper.get_localized_string(32051)
            message = self._kodi_wrapper.get_localized_string(32052)
            self._kodi_wrapper.show_ok_dialog(title, message)
Esempio n. 7
0
class UrlToStreamService(streamservice.StreamService):

    def __init__(self, vrt_base, vrtnu_base_url, kodi_wrapper):
        super(UrlToStreamService, self).__init__(kodi_wrapper)
        self._vrt_base = vrt_base
        self._vrtnu_base_url = vrtnu_base_url
        self._STREAM_URL_PATH = super(UrlToStreamService, self)._BASE_MEDIA_SERVICE_URL + '/videos/{}%24{}?vrtPlayerToken={}'

    def get_stream_from_url(self, url):
<<<<<<< HEAD
        (session, token) = super(UrlToStreamService, self)._get_session_and_token_from_()
        if token is not None:
            url = urlparse.urljoin(self._vrt_base, url)
=======
        session = requests.session()
        cred = helperobjects.Credentials(self._kodi_wrapper)
        if not cred.are_filled_in():
            self._kodi_wrapper.open_settings()
            cred.reload()
        url = urlparse.urljoin(self._vrt_base, url)
        r = session.post('https://accounts.vrt.be/accounts.login',
                               {'loginID': cred.username, 'password': cred.password, 'APIKey': self._API_KEY,
                                'sessionExpiration': '-1',
                                'targetEnv': 'jssdk',
                                'include': 'profile,data,emails,subscriptions,preferences,',
                                'includeUserInfo': 'true',
                                'loginMode': 'standard',
                                'lang': 'nl-inf',
                                'source': 'showScreenSet',
                                'sdk': 'js_latest',
                                'authMode': 'cookie',