Exemplo n.º 1
0
def playlist(output, **kwargs):
    data = api.panel(CHANNELS_PANEL)

    try:
        chnos = Session().get(CHNO_URL).json()
    except:
        chnos = {}

    with codecs.open(output, 'w', encoding='utf8') as f:
        f.write(u'#EXTM3U\n')

        for row in data.get('contents', []):
            asset = row['data']['asset']

            if row['contentType'] != 'video':
                continue

            chid = asset['id']
            chno = chnos.get(chid) or ''

            f.write(
                u'#EXTINF:-1 tvg-id="{id}" tvg-chno="{channel}" channel-id="{channel}" tvg-logo="{logo}",{name}\n{path}\n'
                .format(id=chid,
                        channel=chno,
                        logo=_get_image(asset, 'video', 'thumb'),
                        name=asset['title'],
                        path=plugin.url_for(play,
                                            id=chid,
                                            play_type=PLAY_FROM_START,
                                            _is_live=True)))
Exemplo n.º 2
0
def playlist(output, **kwargs):
    data = api.panel(panel_id=CHANNELS_PANEL)

    try:
        chnos = Session().get(CHNO_URL).json()
    except:
        chnos = {}

    with codecs.open(output, 'w', encoding='utf8') as f:
        f.write(u'#EXTM3U\n')

        for row in data.get('contents', []):
            if row['data']['type'] != 'live-linear':
                continue

            chid = row['data']['playback']['info']['assetId']
            chno = chnos.get(chid) or ''

            f.write(
                u'#EXTINF:-1 tvg-id="{id}" tvg-chno="{channel}" channel-id="{channel}" tvg-logo="{logo}",{name}\n{path}\n'
                .format(id=chid,
                        channel=chno,
                        logo=row['data']['contentDisplay']['images']
                        ['tile'].replace('${WIDTH}', str(768)),
                        name=row['data']['playback']['info']['title'],
                        path=plugin.url_for(play,
                                            id=chid,
                                            play_type=PLAY_FROM_START,
                                            _is_live=True)))
Exemplo n.º 3
0
    def new_session(self):
        self.logged_in = False

        self._session = Session(HEADERS, base_url=API_URL)

        if userdata.get('singtel_tv_no'):
            self.logged_in = True
Exemplo n.º 4
0
def get_integrations():
    try:
        return Session().gz_json(INTEGRATIONS_URL)
    except Exception as e:
        log.debug('Failed to get integrations')
        log.exception(e)
        return {}
Exemplo n.º 5
0
    def new_session(self):
        self.logged_in = False
        self._session = Session(headers=HEADERS)
        self._set_authentication()

        self._default_params = DEFAULT_PARAMS
        self._default_params['signedUp'] = False  #self.logged_in
Exemplo n.º 6
0
    def new_session(self):
        self.logged_in = False
        self._session = Session(headers=HEADERS, base_url=BASE_URL)
        self.logged_in = userdata.get('key', None) != None

        #LEGACY
        userdata.delete('token')
        userdata.delete('user_id')
Exemplo n.º 7
0
    def new_session(self):
        self.logged_in = False
        self._auth_headers = {}
        self._config = {}

        self._session = Session(headers=HEADERS)
        self._session.after_request = self._check_response

        self._set_authentication()
Exemplo n.º 8
0
    def _process_source(self, source, method_name, file_path):
        remove_file(file_path)

        path = source.path.strip()
        source_type = source.source_type
        archive_type = source.archive_type

        if source_type == Source.TYPE_ADDON:
            addon_id = path
            addon, data = merge_info(addon_id, self.integrations, merging=True)

            if method_name not in data:
                raise Error('{} could not be found for {}'.format(
                    method_name, addon_id))

            template_tags = {
                '$ID': addon_id,
                '$FILE': file_path,
                '$IP': xbmc.getIPAddress(),
            }

            path = data[method_name]
            for tag in template_tags:
                path = path.replace(tag, template_tags[tag])

            path = path.strip()
            if path.lower().startswith('plugin'):
                self._call_addon_method(path)
                return

            if path.lower().startswith('http'):
                source_type = Source.TYPE_URL
            else:
                source_type = Source.TYPE_FILE

            archive_extensions = {
                '.gz': Source.ARCHIVE_GZIP,
                '.xz': Source.ARCHIVE_XZ,
            }

            name, ext = os.path.splitext(path.lower())
            archive_type = archive_extensions.get(ext, Source.ARCHIVE_NONE)

        if source_type == Source.TYPE_URL and path.lower().startswith('http'):
            log.debug('Downloading: {} > {}'.format(path, file_path))
            Session().chunked_dl(path, file_path)
        elif not xbmcvfs.exists(path):
            raise Error(_(_.LOCAL_PATH_MISSING, path=path))
        else:
            log.debug('Copying local file: {} > {}'.format(path, file_path))
            xbmcvfs.copy(path, file_path)

        if archive_type == Source.ARCHIVE_GZIP:
            gzip_extract(file_path)
        elif archive_type == Source.ARCHIVE_XZ:
            xz_extract(file_path)
Exemplo n.º 9
0
    def new_session(self):
        self.logged_in = False

        ## Legacy ##
        userdata.delete('pswd')
        userdata.delete('access_token')
        ############

        self._session = Session(HEADERS, base_url=API_URL)
        self._set_authentication()
Exemplo n.º 10
0
    def new_session(self):
        self.logged_in = False

        host = settings.get('business_host') if settings.getBool(
            'business_account', False) else DEFAULT_HOST
        if host != userdata.get('host', DEFAULT_HOST):
            userdata.delete('access_token')
            userdata.set('host', host)

        self._session = Session(HEADERS, base_url=API_URL.format(host))
        self._set_authentication()
Exemplo n.º 11
0
    def get_brightcove_src(self, bc_accont, referenceID):
        headers = {
            'User-Agent':
            'Mozilla/5.0 (CrKey armv7l 1.5.16041) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.0 Safari/537.36',
            'Origin': 'https://www.supercars.com',
            'X-Forwarded-For': '18.233.21.73',
            'BCOV-POLICY': BRIGHTCOVE_KEY,
        }

        brightcove_url = BRIGHTCOVE_URL.format(bc_accont, referenceID)
        data = Session().get(brightcove_url, headers=headers).json()
        return util.process_brightcove(data)
Exemplo n.º 12
0
    def new_session(self):
        self._session = Session(HEADERS)
        self._cache_key = self._region = settings.getEnum('region', REGIONS, default=US)

        if self._region in X_FORWARDS:
            self._session.headers.update({'x-forwarded-for': X_FORWARDS[self._region]})

        elif self._region == CUSTOM:
            region_ip = settings.get('region_ip', '0.0.0.0')
            if region_ip != '0.0.0.0':
                self._session.headers.update({'x-forwarded-for': region_ip})
                self._cache_key = region_ip

        self._cache_key += str(settings.getBool('show_epg', False))
Exemplo n.º 13
0
    def play(self, slug):
        self._refresh_token()
        
        data = self._session.get('/video/{slug}/stream/'.format(slug=slug)).json()
        resp = self._session.head(data['iframe'])
        url = resp.headers.get('Location').replace('.html', '')

        data = Session(headers=HEADERS).get(url).json()
        if 'response' not in data:
            raise APIError('{}'.format(data.get('message', 'unknown error getting playdata')))

        play_url = data['response']['body']['outputs'][0]['url']
        subtitles = data['response']['body'].get('subtitles', [])

        return play_url, subtitles
Exemplo n.º 14
0
def _check_news():
    _time = int(time())
    if _time < settings.getInt('_last_news_check', 0) + NEWS_CHECK_TIME:
        return

    settings.setInt('_last_news_check', _time)

    news = Session(timeout=15).gz_json(NEWS_URL)
    if not news:
        return

    if 'id' not in news or news['id'] == settings.get('_last_news_id'):
        return

    settings.set('_last_news_id', news['id'])
    settings.set('_news', json.dumps(news))
Exemplo n.º 15
0
    def _get(self, url, attempt=1):
        cookies = {'cookie_notice_accepted': 'true'}
        cookies.update(userdata.get('_cookies'))

        r = Session().get(BASE_URL + url,
                          timeout=20,
                          cookies=cookies,
                          headers=HEADERS)

        password = userdata.get(PASSWORD_KEY)
        if 'membersignin' in r.text and password and attempt <= 3:
            self.login(userdata.get('username'), password)
            return self._get(url, attempt=attempt + 1)

        if 'membersignin' in r.text:
            raise APIError(_.SESSION_EXPIRED)

        return r
Exemplo n.º 16
0
def _avatar(profile, download=False):
    _type = profile.get('avatarImageType')

    if _type == 'user-upload':
        url = api.url('gateway', UPLOAD_AVATAR.format(image_id=profile['avatarImageId'], token=userdata.get('access_token')))
    elif _type == 'character':
        url = api.url('artist', CHARACTER_AVATAR.format(image_id=profile['avatarImageId']))
    else:
        return None

    if not download:
        return url

    dst_path = os.path.join(ADDON_PROFILE, 'profile.png')

    try:
        Session().chunked_dl(url, dst_path)
    except:
        return None
    else:
        return dst_path
Exemplo n.º 17
0
def check_updates(force=False):
    _time = int(time())
    if not force and _time < settings.getInt('_last_updates_check',
                                             0) + UPDATES_CHECK_TIME:
        return

    settings.setInt('_last_updates_check', _time)

    new_md5 = Session(timeout=15).get(ADDONS_MD5).text.split(' ')[0]
    if not force and new_md5 == settings.get('addon_md5'):
        return 0

    settings.set('_addon_md5', new_md5)

    updates = []
    slyguy_addons = get_slyguy_addons()
    slyguy_installed = [
        x['addonid'] for x in kodi_rpc('Addons.GetAddons', {
            'installed': True,
            'enabled': True
        })['addons'] if x['addonid'] in slyguy_addons
    ]

    for addon_id in slyguy_installed:
        addon = get_addon(addon_id, install=False)
        if not addon:
            continue

        cur_version = addon.getAddonInfo('version')
        new_version = slyguy_addons[addon_id]['version']

        if LooseVersion(cur_version) < LooseVersion(new_version):
            updates.append([addon, cur_version, new_version])

    if not force and not updates:
        return 0

    log.debug('Updating repos due to {} addon updates'.format(len(updates)))
    xbmc.executebuiltin('UpdateAddonRepos')
    return updates
Exemplo n.º 18
0
    def login(self, username, password):
        self.logout()

        s = Session()
        s.headers.update(HEADERS)

        if not password:
            raise APIError(_.LOGIN_ERROR)

        r = s.get(BASE_URL + 'superview/', timeout=20)
        soup = BeautifulSoup(r.text, 'html.parser')

        login_form = soup.find(id="membersignin")
        inputs = login_form.find_all('input')

        data = {}
        for elem in inputs:
            if elem.attrs.get('value'):
                data[elem.attrs['name']] = elem.attrs['value']

        data.update({
            'signinusername': username,
            'signinpassword': password,
        })

        r = s.post(BASE_URL + 'superview/',
                   data=data,
                   allow_redirects=False,
                   timeout=20)
        if r.status_code != 302:
            raise APIError(_.LOGIN_ERROR)

        if settings.getBool('save_password', False):
            userdata.set(PASSWORD_KEY, password)

        for cookie in r.cookies:
            if cookie.name.startswith('wordpress_logged_in'):
                userdata.set('_cookies', {cookie.name: cookie.value})
                break
Exemplo n.º 19
0
 def new_session(self):
     self.logged_in = False
     self._session = Session(base_url=API_URL, headers=HEADERS)
     self._set_authentication()
Exemplo n.º 20
0
 def new_session(self):
     self.logged_in = False
     self._session = Session(HEADERS, timeout=30)
     self._set_authentication(userdata.get('access_token'))
     self._set_languages()
Exemplo n.º 21
0
from distutils.version import LooseVersion

from kodi_six import xbmc

from slyguy import gui, router, settings
from slyguy.session import Session
from slyguy.util import kodi_rpc, get_addon
from slyguy.log import log
from slyguy.constants import ROUTE_SERVICE, ROUTE_SERVICE_INTERVAL, KODI_VERSION

from .proxy import Proxy
from .monitor import monitor
from .player import Player
from .constants import *

session = Session(timeout=15)


def _check_updates():
    _time = int(time())
    if _time < settings.getInt('_last_updates_check', 0) + UPDATES_CHECK_TIME:
        return

    settings.setInt('_last_updates_check', _time)

    new_md5 = session.get(ADDONS_MD5).text.split(' ')[0]
    if new_md5 == settings.get('addon_md5'):
        return

    settings.set('_addon_md5', new_md5)
Exemplo n.º 22
0
    def new_session(self):
        self.logged_in = False

        self._session = Session(HEADERS, base_url=API_BASE)
        self._set_authentication()
Exemplo n.º 23
0
def _channels():
    return Session().gz_json(DATA_URL)
Exemplo n.º 24
0
 def __init__(self):
     self._session = Session(HEADERS, base_url=API_URL)
Exemplo n.º 25
0
import codecs

from slyguy import plugin, inputstream, settings
from slyguy.session import Session
from slyguy.mem_cache import cached

from .language import _
from .constants import M3U8_URL

session = Session()


@plugin.route('')
def home(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    folder.add_item(label=_(_.LIVE_TV, _bold=True),
                    path=plugin.url_for(live_tv))

    if settings.getBool('bookmarks', True):
        folder.add_item(label=_(_.BOOKMARKS, _bold=True),
                        path=plugin.url_for(plugin.ROUTE_BOOKMARKS),
                        bookmark=False)

    folder.add_item(label=_.SETTINGS,
                    path=plugin.url_for(plugin.ROUTE_SETTINGS),
                    _kiosk=False,
                    bookmark=False)

    return folder
Exemplo n.º 26
0
 def new_session(self):
     self.logged_in = False
     self._session = Session(headers=HEADERS)
Exemplo n.º 27
0
    def new_session(self):
        self.logged_in = False

        self._session = Session(HEADERS)
        self._set_authentication()
Exemplo n.º 28
0
 def new_session(self):
     self._logged_in = False
     self._session = Session(HEADERS, base_url=API_URL, timeout=TIMEOUT)
     self._set_access_token(userdata.get('access_token'))
Exemplo n.º 29
0
 def new_session(self):
     self._session = Session(HEADERS)
Exemplo n.º 30
0
def _data():
    return Session().gz_json(DATA_URL)