예제 #1
0
def get_channels():
    session = api_login.login(_user, _password)
    api_login._s.headers.update({'Access-Control-Request-Method': 'POST'})
    api_login._s.headers.update(
        {'Access-Control-Request-Headers': 'ssbulsatapi'})
    api_login._s.headers.update({'SSBULSATAPI': session})
    api_login._s.options(_url + '/' + _url_live,
                         timeout=_timeout,
                         headers=api_login._ua)

    r = api_login._s.post(_url + '/' + _url_live,
                          timeout=_timeout,
                          headers=api_login._ua)

    # notifycation
    api_debug.show_notifycation('Live ' +
                                str(r.status_code == requests.codes.ok))
    # debug
    api_debug.log('live headers ' + str(r.request.headers))
    api_debug.log('live body ' + str(r.request.body))

    if r.status_code != requests.codes.ok:
        return [{
            'title': unicode(r),
            'genre': '',
            'sources': '',
            'epg_name': ''
        }]
    else:
        return r.json()
예제 #2
0
def login(username, password):
    r = _s.post(_url + '/' + 'auth', timeout=_timeout, headers=_ua)
    key = r.headers['challenge']
    session = r.headers['ssbulsatapi']

    if r.headers['logged'] == 'true':
        return session

    _s.headers.update({'SSBULSATAPI': session})

    enc = aes.AESModeOfOperationECB(key)
    password_crypt = enc.encrypt(password + (16 - len(password) % 16) * '\0')

    r = _s.post(_url + '/' + 'auth',
                timeout=_timeout,
                headers=_ua,
                data={
                    'user': ['', username],
                    'device_id': ['', _agent],
                    'device_name': ['', _agent],
                    'os_version': ['', _agent],
                    'os_type': ['', _agent],
                    'app_version': ['', '0.01'],
                    'pass': ['', base64.b64encode(password_crypt)]
                })

    # notifycation
    api_debug.show_notifycation('Login ' + r.headers['logged'])
    # debug
    api_debug.log('login headers ' + str(r.request.headers))
    api_debug.log('login body ' + str(r.request.body))

    return session
예제 #3
0
def get_epg(live):
    for i, channel in enumerate(live):
        if channel.has_key('program'):
            #'epg': 'nownext' / '1day' / '1week'
            r = api_login._s.post(_url + '/' + 'epg/short',
                                  timeout=_timeout,
                                  headers=api_login._ua,
                                  data={
                                      'epg': '1day',
                                      'channel': channel['epg_name']
                                  })

            if r.status_code == requests.codes.ok:
                channel['program'] = r.json().items()[0][1]['programme']

    # debug
    api_debug.notifycation('EPG ' + str(r.status_code == requests.codes.ok))
    api_debug.log('EPG ' + str(live))

    return live
예제 #4
0
def get_channel(session):
    api_login._s.headers.update({'Access-Control-Request-Method': 'POST'})
    api_login._s.headers.update(
        {'Access-Control-Request-Headers': 'ssbulsatapi'})
    api_login._s.headers.update({'SSBULSATAPI': session})
    api_login._s.options(_url + '/tv/' + api_login._os_list[_os] + '/live',
                         timeout=_timeout,
                         headers=api_login._ua)

    r = api_login._s.post(_url + '/tv/' + api_login._os_list[_os] + '/live',
                          timeout=_timeout,
                          headers=api_login._ua)

    # debug
    api_debug.notifycation('Channel ' +
                           str(r.status_code == requests.codes.ok))

    if r.status_code != requests.codes.ok:
        return [{}]
    else:
        # debug
        api_debug.log('Channel ' + str(r.json()))

        return r.json()
예제 #5
0
def login(username, password):
    url_auth = 'auth'
    # change auth url for diffrent then 'pcweb'
    if _os != 0:
        url_auth = '?' + url_auth

    r = _s.post(_url + '/' + url_auth, timeout=_timeout, headers=_ua)
    key = r.headers['challenge']
    session = r.headers['ssbulsatapi']

    if r.headers['logged'] == 'true':
        return session

    _s.headers.update({'SSBULSATAPI': session})

    enc = aes.AESModeOfOperationECB(key)
    password_crypt = enc.encrypt(password + (16 - len(password) % 16) * '\0')

    r = _s.post(_url + '/' + url_auth,
                timeout=_timeout,
                headers=_ua,
                data={
                    'user': ['', username],
                    'device_id': ['', _os_list[_os]],
                    'device_name': ['', _os_list[_os]],
                    'os_version': ['', _os_list[_os]],
                    'os_type': ['', _os_list[_os]],
                    'app_version': ['', '0.01'],
                    'pass': ['', base64.b64encode(password_crypt)]
                })

    # debug
    api_debug.notifycation('Login ' + r.headers['logged'])
    api_debug.log('Login ' + str(r.request.headers))

    return session