示例#1
0
def play(slug, **kwargs):
    data, content = api.play(slug)

    headers = {
        'Authorization': 'Bearer {}'.format(userdata.get('access_token')),
    }

    item = plugin.Item(
        path = data['url'],
        inputstream = inputstream.MPD(),
        headers = headers,
    )

    if 'drm' in data:
        item.inputstream = inputstream.Widevine(license_key = data['drm']['licenseUrl'])
        item.proxy_data['manifest_middleware'] = plugin.url_for(mpd_request)
        if settings.getBool('wv_secure'):
            item.inputstream.properties['license_flags'] = 'force_secure_decoder'

    item.play_next = {}
    if ':episode' in slug:
        item.update(
            label = content['titles']['full'],
            art   = {'thumb': _image(content['images'].get('tileburnedin')), 'fanart':  _image(content['images'].get('tile'), size='1920x1080')},
            info  = {
                'plot': content['summaries']['short'],
                'duration': content['duration'],
                'tvshowtitle': content['seriesTitles']['full'],
                'season': content.get('seasonNumber', 1),
                'episode': content.get('numberInSeason', content.get('numberInSeries', 1)),
                'mediatype': 'episode'
            },
        )

        if settings.getBool('play_next_episode', True):
            item.play_next['next_file'] = _get_play_path(content.get('next'))

    elif ':feature' in slug:
        item.update(
            label = content['titles']['full'],
            art   = {'thumb': _image(content['images'].get('tileburnedin')), 'fanart':_image(content['images'].get('tile'), size='1920x1080')},
            info  = {
                'plot': content['summaries']['short'],
                'duration': content['duration'],
                'year': content['releaseYear'],
                'mediatype': 'movie',
            },
        )

        if settings.getBool('play_next_movie', False):
            for slug in content.get('similars', []):
                if ':feature' in slug:
                    item.play_next['next_file'] = 'urn:hbo:feature:' + slug.split(':')[3]
                    break

    if not settings.getBool('ignore_subs', False):
        for row in data.get('textTracks', []):
            item.subtitles.append([row['url'], row['language']])

    return item
    def playback_data(self, playback_url):
        self._refresh_token(force=True)

        config = self.get_config()
        scenario = config['services']['media']['extras'][
            'restrictedPlaybackScenario']

        if settings.getBool('wv_secure', False):
            scenario = config['services']['media']['extras'][
                'playbackScenarioDefault']

            if settings.getBool('h265', False):
                scenario += '-h265'

                if settings.getBool('dolby_vision', False):
                    scenario += '-dovi'
                elif settings.getBool('hdr10', False):
                    scenario += '-hdr10'

                if settings.getBool('dolby_atmos', False):
                    scenario += '-atmos'

        headers = {
            'accept': 'application/vnd.media-service+json; version=4',
            'authorization': userdata.get('access_token')
        }

        endpoint = playback_url.format(scenario=scenario)
        playback_data = self._session.get(endpoint, headers=headers).json()
        self._check_errors(playback_data)

        return playback_data
示例#3
0
def index(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True), path=plugin.url_for(login), bookmark=False)
    else:
        if not userdata.get('profile_kids', False):
            folder.add_item(label=_(_.FEATURED, _bold=True), path=plugin.url_for(featured, key='sitemap', title=_.FEATURED))
            folder.add_item(label=_(_.TV, _bold=True), path=plugin.url_for(nav, key='tv', title=_.TV))
            folder.add_item(label=_(_.MOVIES, _bold=True), path=plugin.url_for(nav, key='movies', title=_.MOVIES))

            if not settings.getBool('hide_sport', False):
                folder.add_item(label=_(_.SPORT, _bold=True), path=plugin.url_for(nav, key='sport', title=_.SPORT))

        folder.add_item(label=_(_.KIDS, _bold=True), path=plugin.url_for(nav, key='kids', title=_.KIDS))
        folder.add_item(label=_(_.MY_LIST, _bold=True), path=plugin.url_for(my_list))
        folder.add_item(label=_(_.CONTINUE_WATCHING, _bold=True), path=plugin.url_for(continue_watching))
        folder.add_item(label=_(_.SEARCH, _bold=True), path=plugin.url_for(search))

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

        if not userdata.get('kid_lockdown', False):
            folder.add_item(label=_.SELECT_PROFILE, path=plugin.url_for(select_profile), art={'thumb': userdata.get('profile_icon')}, info={'plot': userdata.get('profile_name')}, _kiosk=False, bookmark=False)

        folder.add_item(label=_.LOGOUT, path=plugin.url_for(logout), _kiosk=False, bookmark=False)

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

    return folder
示例#4
0
def show(show_id, **kwargs):
    show = api.show(int(show_id))
    
    folder = plugin.Folder(show['tv_show'])

    seasons = []
    extras = None
    for row in show['seasons']:
        if 'season' in row['seasonName'].lower():
            seasons.append(row)
        elif 'extras' in row['seasonName'].lower():
            extras = row

    seasons = sorted(seasons, key=lambda x: int(x['seasonName'].replace('Season', '').strip()))
    if extras and 'extra' in show['noOfEpisodes'].lower() and not settings.getBool('hide_extras', False):
        seasons.append(extras)

    if len(seasons) == 1 and settings.getBool('flatten_single_season', True):
        return _season(show['id'], seasons[0]['seasonId'])

    for row in seasons:
        folder.add_item(
            label = row['seasonName'],
            info = {
                'plot': show['description'],
                'tvshowtitle': show['tv_show'],
                'genre': show['genre'],
                'mediatype': 'season',
            },
            art = {'thumb': show['posterArt'], 'fanart': show['tvBackgroundURL']},
            path = plugin.url_for(season, show_id=show['id'], season_id=row['seasonId']),
        )

    return folder
示例#5
0
def index(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True),  path=plugin.url_for(login), bookmark=False)
    else:
        folder.add_item(label=_(_.FEATURED, _bold=True), path=plugin.url_for(collection, slug='home', content_class='home', label=_.FEATURED))
        folder.add_item(label=_(_.HUBS, _bold=True),  path=plugin.url_for(hubs))
        folder.add_item(label=_(_.MOVIES, _bold=True),  path=plugin.url_for(collection, slug='movies', content_class='contentType'))
        folder.add_item(label=_(_.SERIES, _bold=True),  path=plugin.url_for(collection, slug='series', content_class='contentType'))
        folder.add_item(label=_(_.ORIGINALS, _bold=True),  path=plugin.url_for(collection, slug='originals', content_class='originals'))
        folder.add_item(label=_(_.WATCHLIST, _bold=True),  path=plugin.url_for(collection, slug='watchlist', content_class='watchlist'))
        folder.add_item(label=_(_.SEARCH, _bold=True),  path=plugin.url_for(search))

        if settings.getBool('disney_sync', False):
            folder.add_item(label=_(_.CONTINUE_WATCHING, _bold=True), path=plugin.url_for(sets, set_id=CONTINUE_WATCHING_SET_ID, set_type=CONTINUE_WATCHING_SET_TYPE))

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

        if not userdata.get('kid_lockdown', False):
            folder.add_item(label=_.SELECT_PROFILE, path=plugin.url_for(select_profile), art={'thumb': userdata.get('avatar')}, info={'plot': userdata.get('profile')}, _kiosk=False, bookmark=False)
            #folder.add_item(label=_.PROFILE_SETTINGS, path=plugin.url_for(profile_settings), art={'thumb': userdata.get('avatar')}, info={'plot': userdata.get('profile')}, _kiosk=False)

        folder.add_item(label=_.LOGOUT, path=plugin.url_for(logout), _kiosk=False, bookmark=False)

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

    return folder
示例#6
0
def start():
    log.debug('Shared Service: Started')

    try:
        set_drm_level()
    except Exception as e:
        log.error('Failed to set DRM level')
        log.exception(e)

    player = Player()
    proxy = Proxy()

    try:
        proxy.start()
    except Exception as e:
        log.error('Failed to start proxy server')
        log.exception(e)

    is_donor = False
    try:
        is_donor = check_donor()
    except Exception as e:
        log.error('Failed to check donor')
        log.exception(e)

    if is_donor:
        log.debug('Welcome SlyGuy donor!')

    ## Inital wait on boot
    monitor.waitForAbort(5)

    try:
        while not monitor.abortRequested():
            if not is_donor or settings.getBool('show_news'):
                try:
                    _check_news()
                except Exception as e:
                    log.exception(e)

            if is_donor and settings.getBool('rapid_updates'):
                try:
                    check_updates()
                except Exception as e:
                    log.exception(e)

            if monitor.waitForAbort(60):
                break
    except KeyboardInterrupt:
        pass
    except Exception as e:
        log.exception(e)

    try:
        proxy.stop()
    except:
        pass

    log.debug('Shared Service: Stopped')
示例#7
0
    def new_session(self):
        self.logged_in = True if userdata.get('_cookies') else False
        if not settings.getBool('save_password', False):
            userdata.delete(PASSWORD_KEY)

        if self.logged_in and settings.getBool(
                'save_password', True) and not userdata.get(PASSWORD_KEY):
            self.logout()
            gui.ok(_.SAVE_PASSWORD_RELOGIN)
示例#8
0
def _process_media(row, in_watchlist=False):
    if settings.getBool('child_friendly',
                        False) and not row.get('is_child_friendly', False):
        #maybe just block playback and add label, so pagination still correct
        return None

    is_published = row.get('is_published', True)
    is_collection = row.get('is_collection', False)
    is_free = row.get('is_free', False)
    is_series = row.get('is_numbered_series', False)
    duration = row.get('duration',
                       0) if plugin.logged_in or is_free else PREVIEW_LENGTH

    context = []

    if plugin.logged_in:
        if in_watchlist:
            context.append((_.REMOVE_WATCHLIST, "RunPlugin({})".format(
                plugin.url_for(remove_watchlist,
                               id=row['id'],
                               title=row['title'],
                               series=int(is_collection)))))
        else:
            context.append((_.ADD_WATCHLIST, "RunPlugin({})".format(
                plugin.url_for(add_watchlist,
                               id=row['id'],
                               title=row['title'],
                               series=int(is_collection)))))

    if is_collection:
        path = plugin.url_for(series, id=row['id'])
    else:
        path = _get_play_path(row['id'])

    item = plugin.Item(
        label=row.get('title'),
        info={
            'plot': row['description'],
            'duration': duration,
            'year': row.get('year_produced')
        },
        art={'thumb': _image(row, 'image_medium')},
        path=path,
        context=context,
        playable=not is_collection,
    )

    if settings.getBool('sync_playback', False):
        try:
            resume_from = row['user_media']['progress_in_seconds']
        except:
            resume_from = 0

        item.properties['ResumeTime'] = resume_from
        item.properties['TotalTime'] = resume_from

    return item
示例#9
0
    def play(self, video_id):
        codecs = ''

        if settings.getBool('vp9', False):
            codecs += 'vp9+'
        if settings.getBool('h265', False):
            codecs += 'hevc+'
        if settings.getBool('h264', True):
            codecs += 'h264+'

        codecs = codecs.rstrip('+')

        params = {
            'capabilities[]': ['codecs={}'.format(codecs), 'multiaudio'],
            'encoding': 'mpd_widevine_modular',
            'subscription_status': 'full',
            'mode': 'paid',
            'showmax_rating': '18-plus',
            'lang': self._language,
            #   'content_country': 'ZA',
        }

        data = self._session.get('playback/play/{}'.format(video_id),
                                 params=params).json()
        if 'url' not in data:
            raise APIError(data.get('message'))

        url = data['url']
        task_id = data['packaging_task_id']
        session_id = data['session_id']

        data = {
            'user_id': userdata.get('user_id'),
            'video_id': video_id,
            'hw_code': userdata.get('device_id'),
            'packaging_task_id': task_id,
            'session_id': session_id,
        }

        params = {
            'showmax_rating': '18-plus',
            'mode': 'paid',
            'subscription_status': 'full',
            'lang': self._language,
        }

        data = self._session.post('playback/verify', params=params,
                                  data=data).json()

        if 'license_request' not in data:
            raise APIError(data.get('message'))

        license_request = data['license_request']
        license_url = API_URL.format(
            'drm/widevine_modular?license_request={}'.format(license_request))

        return url, license_url
示例#10
0
def start():
    http = HTTP()

    monitor = xbmc.Monitor()
    restart_queued = False

    boot_merge = settings.getBool('boot_merge', False)
    set_kodi_string('_iptv_merge_force_run')

    while not monitor.waitForAbort(1):
        http.start() if settings.getBool('http_api', False) else http.stop()

        forced = get_kodi_string('_iptv_merge_force_run') or 0

        if forced or boot_merge or (settings.getBool('auto_merge', True) and time.time() - userdata.get('last_run', 0) > settings.getInt('reload_time_hours', 12) * 3600):
            set_kodi_string('_iptv_merge_force_run', '1')

            url = router.url_for('run_merge', forced=int(forced))
            dirs, files = xbmcvfs.listdir(url)
            result, msg = int(files[0][0]), unquote_plus(files[0][1:])
            if result:
                restart_queued = True

            userdata.set('last_run', int(time.time()))
            set_kodi_string('_iptv_merge_force_run')

        if restart_queued and settings.getBool('restart_pvr', False):
            if forced: progress = gui.progressbg(heading='Reloading IPTV Simple Client')

            if KODI_VERSION > 18:
                restart_queued = False
                try: xbmcaddon.Addon(IPTV_SIMPLE_ID).setSetting('m3uPathType', '0')
                except Exception as e: pass

            elif forced or (not xbmc.getCondVisibility('Pvr.IsPlayingTv') and not xbmc.getCondVisibility('Pvr.IsPlayingRadio')):
                restart_queued = False
                kodi_rpc('Addons.SetAddonEnabled', {'addonid': IPTV_SIMPLE_ID, 'enabled': False})

                wait_delay = 4
                for i in range(wait_delay):
                    if monitor.waitForAbort(1):
                        break
                    if forced: progress.update((i+1)*int(100/wait_delay))

                kodi_rpc('Addons.SetAddonEnabled', {'addonid': IPTV_SIMPLE_ID, 'enabled': True})

            if forced:
                progress.update(100)
                progress.close()

        boot_merge = False

    http.stop()
示例#11
0
def _providers(playlist=False, epg=False):
    if not playlist and not epg:
        hide_public = settings.getBool('hide_public', False)
        hide_custom = settings.getBool('hide_custom', False)
    else:
        hide_public, hide_custom = False, False

    remove_numbers = settings.getBool('remove_numbers', False)

    if epg:
        channels = api.epg()
    elif playlist:
        channels = api.channels()
    else:
        channels = _channels()

    providers = {}
    if not playlist and not epg:
        providers[ALL] = {
            'name': _.ALL,
            'channels': [],
            'logo': None,
            'sort': 0
        }

    for channel in channels:
        key = channel['providerDisplayName'].lower()

        if (key == PUBLIC and hide_public) or (key == CUSTOM and hide_custom):
            continue

        if key not in providers:
            sort = 2 if key in (PUBLIC, CUSTOM) else 1
            providers[key] = {
                'name': channel['providerDisplayName'],
                'channels': [],
                'logo': PROVIDER_ART.get(key, None),
                'sort': sort
            }

        if remove_numbers:
            channel['title'] = re.sub('^[0-9]+\.[0-9]+', '',
                                      channel['title']).strip()

        providers[key]['channels'].append(channel)
        if not playlist and not epg:
            providers[ALL]['channels'].append(channel)

    if not playlist and not epg and len(providers) == 2:
        providers.pop(ALL)

    return providers
示例#12
0
def home(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not _setup(check_only=True):
        folder.add_item(
            label=_(_.SETUP_IPTV_SIMPLE, _bold=True),
            path=plugin.url_for(setup),
        )

    folder.add_item(
        label=_.PLAYLISTS,
        path=plugin.url_for(playlists),
    )

    folder.add_item(
        label=_.EPGS,
        path=plugin.url_for(epgs),
    )

    folder.add_item(
        label=_.MANAGE_TV,
        path=plugin.url_for(manager, radio=0),
    )

    folder.add_item(
        label=_.MANAGE_RADIO,
        path=plugin.url_for(manager, radio=1),
    )

    folder.add_item(
        label=_.RUN_MERGE,
        path=plugin.url_for(merge),
    )

    if settings.getBool('http_api'):
        folder.add_item(
            label="HTTP API Running",
            path=plugin.url_for(http_info),
        )

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

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

    return folder
def _process_rows(rows, content_class=None):
    items = []
    continue_watching = {}

    if settings.getBool('disney_sync', False):
        continue_watching = api.continue_watching()

    for row in rows:
        item = None
        content_type = row.get('type')

        if content_type == 'DmcVideo':
            program_type = row.get('programType')

            if program_type == 'episode':
                if content_class in ('episode', 'ContinueWatchingSet'):
                    item = _parse_video(row)
                else:
                    item = _parse_series(row)
            else:
                item = _parse_video(row)

            if item.playable and settings.getBool('disney_sync', False):
                item.resume_from = continue_watching.get(row['contentId'], 0)

        elif content_type == 'DmcSeries':
            item = _parse_series(row)

        elif content_type == 'StandardCollection':
            item = _parse_collection(row)

        if not item:
            continue

        if content_class == 'WatchlistSet':
            item.context.insert(0, (_.DELETE_WATCHLIST, 'RunPlugin({})'.format(
                plugin.url_for(delete_watchlist,
                               content_id=row['contentId']))))
        elif content_type == 'DmcSeries' or (content_type == 'DmcVideo'
                                             and program_type != 'episode'):
            item.context.insert(0, (_.ADD_WATCHLIST, 'RunPlugin({})'.format(
                plugin.url_for(add_watchlist,
                               content_id=row['contentId'],
                               title=item.label,
                               icon=item.art.get('thumb')))))

        items.append(item)

    return items
示例#14
0
def _process_channels(channels, group=ALL):
    items = []

    show_chno = settings.getBool('show_chno', True)

    if settings.getBool('show_epg', True):
        now = arrow.now()
        epg_count = 5
    else:
        epg_count = None

    for id in sorted(channels.keys(),
                     key=lambda x: channels[x]['chno']
                     if show_chno else channels[x]['name']):
        channel = channels[id]

        if group != ALL and channel['group'] != group:
            continue

        if not epg_count:
            plot = channel['description']
        else:
            plot = u''
            count = 0
            for index, row in enumerate(channel.get('programs', [])):
                start = arrow.get(row[0])
                try:
                    stop = arrow.get(channel['programs'][index + 1][0])
                except:
                    stop = start.shift(hours=1)

                if (now > start and now < stop) or start > now:
                    plot += u'[{}] {}\n'.format(
                        start.to('local').format('h:mma'), row[1])
                    count += 1
                    if count == epg_count:
                        break

        item = plugin.Item(
            label=u'{} | {}'.format(channel['chno'], channel['name'])
            if show_chno else channel['name'],
            info={'plot': plot},
            art={'thumb': channel['logo']},
            playable=True,
            path=plugin.url_for(play, id=id, _is_live=True),
        )
        items.append(item)

    return items
示例#15
0
def home(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True),
                        path=plugin.url_for(login),
                        bookmark=False)
    else:
        folder.add_item(label=_(_.CHANNELS, _bold=True),
                        path=plugin.url_for(editorial,
                                            id=LINEAR_ID,
                                            title=_.CHANNELS))
        _home(folder)

        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=_.LOGOUT,
                        path=plugin.url_for(logout),
                        _kiosk=False,
                        bookmark=False)

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

    return folder
示例#16
0
def home(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    folder.add_item(label=_(_.HOME, _bold=True),
                    path=plugin.url_for(content, slug='home'))
    folder.add_item(label=_(_.LIVE_TV, _bold=True),
                    path=plugin.url_for(content,
                                        slug=LIVE_TV_SLUG,
                                        label=_.LIVE_TV,
                                        expand_media=1))
    folder.add_item(label=_(_.SHOWS, _bold=True), path=plugin.url_for(shows))
    folder.add_item(label=_(_.MOVIES, _bold=True),
                    path=plugin.url_for(content, slug='movies'))
    folder.add_item(label=_(_.SPORT, _bold=True),
                    path=plugin.url_for(content, slug='sport'))
    folder.add_item(label=_(_.NEWS, _bold=True),
                    path=plugin.url_for(content, slug='news'))
    folder.add_item(label=_(_.CATEGORIES, _bold=True),
                    path=plugin.url_for(content, slug='all-categories'))
    folder.add_item(label=_(_.SEARCH, _bold=True), path=plugin.url_for(search))

    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
示例#17
0
def home(**kwargs):
    folder = plugin.Folder()

    if not plugin.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True),
                        path=plugin.url_for(login),
                        bookmark=False)
    else:
        folder.add_item(label=_(_.SERIES, _bold=True),
                        path=plugin.url_for(series))
        folder.add_item(label=_(_.MOVIES, _bold=True),
                        path=plugin.url_for(movies))
        folder.add_item(label=_(_.KIDS, _bold=True), path=plugin.url_for(kids))
        folder.add_item(label=_(_.SEARCH, _bold=True),
                        path=plugin.url_for(search))

        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=_.LOGOUT,
                        path=plugin.url_for(logout),
                        _kiosk=False,
                        bookmark=False)

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

    return folder
示例#18
0
def _landing(slug, params=None):
    items = []

    to_add = []

    def expand(row):
        if not row['personalised'] and row.get('contents'):
            items.extend(_parse_contents(row.get('contents', [])))
        else:
            data = api.panel(link=row['links']['panels'])
            items.extend(_parse_contents(data.get('contents', [])))

    for row in api.landing(slug, params)['panels']:
        if row['panelType'] == 'hero-carousel' and settings.getBool(
                'show_hero_contents', True):
            expand(row)

        elif row['panelType'] not in ('hero-carousel',
                                      'genre-menu-sticky') and 'id' in row:
            to_add.append(row)

    if not items and len(to_add) == 1:
        expand(to_add[0])
    else:
        for row in to_add:
            items.append(
                plugin.Item(
                    label=row['title'],
                    path=plugin.url_for(panel, link=row['links']['panels']),
                ))

    return items
示例#19
0
def home(**kwargs):
    folder = plugin.Folder()

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True),
                        path=plugin.url_for(login),
                        bookmark=False)
    else:
        folder.add_item(label=_(_.LIVE, _bold=True), path=plugin.url_for(live))
        folder.add_item(label=_(_.PLAYED, _bold=True),
                        path=plugin.url_for(played))
        folder.add_item(label=_(_.UPCOMING, _bold=True),
                        path=plugin.url_for(upcoming))

        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=_.LOGOUT,
                        path=plugin.url_for(logout),
                        _kiosk=False,
                        bookmark=False)

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

    return folder
示例#20
0
def home(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True),
                        path=plugin.url_for(login))
    else:
        folder.add_item(label=_(_.FEATURED, _bold=True),
                        path=plugin.url_for(page, slug='/', label=_.FEATURED))
        folder.add_item(label=_(_.LIVE, _bold=True),
                        path=plugin.url_for(page, slug='/live'))
        folder.add_item(label=_(_.SEARCH, _bold=True),
                        path=plugin.url_for(search))

        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=_.LOGOUT,
                        path=plugin.url_for(logout),
                        _kiosk=False,
                        bookmark=False)

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

    return folder
示例#21
0
def _get_channels(only_live=True):
    subscriptions = userdata.get('subscriptions', [])
    channels = []
    rows = api.channels()

    for row in sorted(rows, key=lambda r: float(r.get('sky$liveChannelOrder', 'inf'))):
        if only_live and 'Live' not in row.get('sky$channelType', []):
            continue

        label = row['title']

        subscribed = _is_subscribed(subscriptions, row.get('media$categories'))

        if not subscribed:
            label = _(_.LOCKED, label=label)

        if settings.getBool('hide_unplayable', False) and not subscribed:
            continue

        if label.lower().startswith('entpopup'):
            label = row.get('description', label)

        channels.append({
            'label': label,
            'title': row['title'],
            'channel': row.get('sky$skyGOChannelID', ''),
            'plot': row.get('description'),
            'image': _get_image(row),
            'path':  plugin.url_for(play, id=row['id'], _is_live=True),
        })

    return channels
示例#22
0
def show(slug, **kwargs):
    _show, sections, embedded = api.show(slug)

    categories = []
    for i in _show['categories']:
        categories.append(i['label'])

    fanart = _get_image(_show['coverImage'], '?width=1920&height=548')
    folder = plugin.Folder(_show['title'], fanart=fanart)

    count = 0
    for row in sections:
        if row['_embedded']['sectionType'] == 'similarContent':
            folder.add_item(
                label=row['label'],
                art={'thumb': _get_image(_show['tileImage'])},
                path=plugin.url_for(similar,
                                    href=row['_embedded']['id'],
                                    label=_show['title'],
                                    fanart=fanart),
            )
        else:
            for module in row['_embedded']['layout']['slots']['main'][
                    'modules']:
                if module['type'] != 'showVideoCollection':
                    continue

                for _list in module['lists']:
                    count += 1
                    if count == 1 and _show[
                            'videosAvailable'] == 1 and settings.getBool(
                                'flatten_single_season', True):
                        # Try to flatten
                        try:
                            data = embedded[embedded[_list['href']]['content']
                                            [0]['href']]
                            item = _process_video(data,
                                                  _show['title'],
                                                  categories=categories)
                            folder.add_items(item)
                            continue
                        except:
                            pass

                    item = plugin.Item(
                        label=_list['label'] or module['label'],
                        art={'thumb': _get_image(_show['tileImage'])},
                        path=plugin.url_for(video_list,
                                            href=_list['href'],
                                            label=_show['title'],
                                            fanart=fanart),
                    )

                    if 'season' in item.label.lower():
                        item.info['mediatype'] = 'season'
                        folder.items.insert(0, item)
                    else:
                        folder.items.append(item)

    return folder
示例#23
0
def home(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True),
                        path=plugin.url_for(login),
                        bookmark=False)
    else:
        folder.add_item(label=_(_.LIVE_CHANNELS, _bold=True),
                        path=plugin.url_for(live_channels))
        folder.add_item(label=_(_.CATCH_UP, _bold=True),
                        path=plugin.url_for(catch_up))
        # folder.add_item(label=_(_.MATCH_HIGHLIGHTS, _bold=True), path=plugin.url_for(catch_up, catalog_id='Match_Highlights', title=_.MATCH_HIGHLIGHTS))
        # folder.add_item(label=_(_.INTERVIEWS, _bold=True),       path=plugin.url_for(catch_up, catalog_id='Interviews', title=_.INTERVIEWS))
        # folder.add_item(label=_(_.SPECIALS, _bold=True),         path=plugin.url_for(catch_up, catalog_id='Specials', title=_.SPECIALS))

        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=_.LOGOUT,
                        path=plugin.url_for(logout),
                        _kiosk=False,
                        bookmark=False)

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

    return folder
示例#24
0
def _set_profile(profile, switching=True):
    if switching:
        api.set_profile(profile['profileId'])

    if settings.getBool('kid_lockdown',
                        False) and profile['profileType'] == 'child':
        userdata.set('kid_lockdown', True)

    _profile = {
        'id': profile['profileId'],
        'name': profile['name'],
        'avatar': profile['avatarId']
    }
    if profile['profileType'] == 'child':
        _profile.update({
            'child':
            1,
            'birth': [profile['birth']['month'], profile['birth']['year']],
        })

    userdata.set('profile', _profile)

    if switching:
        gui.notification(_.PROFILE_ACTIVATED,
                         heading=_profile['name'],
                         icon=_avatar(_profile['avatar']))
示例#25
0
def _parse_elements(elements, from_menu=False):
    entitlements = _get_entitlements()

    items = []
    for elem in elements:
        elem['locked'] = entitlements and elem['channelCode'] not in entitlements

        if elem['locked'] and settings.getBool('hide_locked'):
            continue

        if elem['type'] == 'movie':
            item = _parse_movie(elem)

        elif elem['type'] == 'episode':
            item = _parse_episode(elem, from_menu=from_menu)

        elif elem['type'] == 'show':
            item = _parse_show(elem)

        elif elem['type']  == 'series':
            log.debug('Series! You should no longer see this. Let me know if you do...')
            continue

        else:
            continue

        items.append(item)

    return items
示例#26
0
def index(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True),  path=plugin.url_for(login), bookmark=False)
    else:
        folder.add_item(label=_(_.FEATURED, _bold=True), path=plugin.url_for(page, slug='urn:hbo:page:home', label=_.FEATURED))
        folder.add_item(label=_(_.SERIES, _bold=True), path=plugin.url_for(page, slug='urn:hbo:page:series', label=_.SERIES))
        folder.add_item(label=_(_.MOVIES, _bold=True), path=plugin.url_for(page, slug='urn:hbo:page:movies', label=_.MOVIES))
        folder.add_item(label=_(_.ORIGINALS, _bold=True), path=plugin.url_for(page, slug='urn:hbo:page:originals', label=_.ORIGINALS))
        folder.add_item(label=_(_.JUST_ADDED, _bold=True), path=plugin.url_for(page, slug='urn:hbo:page:just-added', label=_.JUST_ADDED))
        folder.add_item(label=_(_.LAST_CHANCE, _bold=True), path=plugin.url_for(page, slug='urn:hbo:page:last-chance', label=_.LAST_CHANCE))
        folder.add_item(label=_(_.COMING_SOON, _bold=True), path=plugin.url_for(page, slug='urn:hbo:page:coming-soon', label=_.COMING_SOON))
        folder.add_item(label=_(_.TRENDING_NOW, _bold=True), path=plugin.url_for(page, slug='urn:hbo:page:trending', label=_.TRENDING_NOW))

        folder.add_item(label=_(_.SEARCH, _bold=True), path=plugin.url_for(search))

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

        if not userdata.get('kid_lockdown', False):
            profile = userdata.get('profile', {})
            folder.add_item(label=_.SELECT_PROFILE, path=plugin.url_for(select_profile), art={'thumb': profile.get('avatar')}, info={'plot': profile.get('name')}, _kiosk=False, bookmark=False)

        folder.add_item(label=_.LOGOUT, path=plugin.url_for(logout), _kiosk=False, bookmark=False)

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

    return folder
示例#27
0
def home(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True),
                        path=plugin.url_for(login),
                        bookmark=False)
    else:
        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=_.LOGOUT,
                        path=plugin.url_for(logout),
                        _kiosk=False,
                        bookmark=False)

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

    return folder
示例#28
0
    def login(self, username, password, kickdevice=None):
        self.logout()

        raw_id = self._format_id(settings.get('device_id')).lower()
        device_id = hashlib.sha1(raw_id.encode('utf8')).hexdigest()

        log.debug('Raw device id: {}'.format(raw_id))
        log.debug('Hashed device id: {}'.format(device_id))

        hex_password = self._hex_password(password, device_id)

        params = {
            'appID': APP_ID,
            'format': 'json',
        }

        payload = {
            'username': username,
            'password': hex_password,
            'deviceId': device_id,
            'accountType': 'foxtel',
        }

        if kickdevice:
            payload['deviceToKick'] = kickdevice
            log.debug('Kicking device: {}'.format(kickdevice))

        data = self._session.post(
            '/auth.class.api.php/logon/{site_id}'.format(site_id=VOD_SITEID),
            data=payload,
            params=params).json()

        response = data['LogonResponse']
        devices = response.get('CurrentDevices', [])
        error = response.get('Error')
        success = response.get('Success')

        if error:
            if not devices or kickdevice:
                raise APIError(_(_.LOGIN_ERROR, msg=error.get('Message')))

            options = [d['Nickname'] for d in devices]
            index = gui.select(_.DEREGISTER_CHOOSE, options)
            if index < 0:
                raise APIError(_(_.LOGIN_ERROR, msg=error.get('Message')))

            kickdevice = devices[index]['DeviceID']

            return self.login(username, password, kickdevice=kickdevice)

        userdata.set('token', success['LoginToken'])
        userdata.set('deviceid', success['DeviceId'])
        userdata.set('entitlements', success.get('Entitlements', ''))

        if settings.getBool('save_password', False):
            userdata.set('pswd', password)
            log.debug('Password Saved')

        self.logged_in = True
示例#29
0
def _set_profile(profile, notify=True):
    api.set_profile(profile['id'])

    if settings.getBool('kid_lockdown', False) and profile['isKidsProfile']:
        userdata.set('kid_lockdown', True)

    if notify:
        gui.notification(_.PROFILE_ACTIVATED, heading=userdata.get('profile_name'), icon=userdata.get('profile_icon'))
示例#30
0
def callback():
    function = settings.get('function')

    if not settings.getBool('silent', False):
        gui.notification(_(_.RUN_FUNCTION, function=function))

    log.debug('Running function: {}'.format(function))
    xbmc.executebuiltin(function)