def _add_profile(taken_names, taken_avatars): ## PROFILE AVATAR ## options = [ plugin.Item(label=_(_.RANDOM_AVATAR, _bold=True)), ] values = [ ['_random', None], ] avatars = [] unused = [] for icon_set in api.profile_icons(): for row in icon_set['icons']: icon_info = [icon_set['iconSet'], row['iconIndex']] values.append(icon_info) avatars.append(icon_info) if row['iconImage'] in taken_avatars: label = _(_.AVATAR_USED, label=icon_set['label']) else: label = icon_set['label'] unused.append(icon_info) options.append( plugin.Item(label=label, art={'thumb': row['iconImage']})) index = gui.select(_.SELECT_AVATAR, options=options, useDetails=True) if index < 0: return avatar = values[index] if avatar[0] == '_random': avatar = random.choice(unused or avatars) ## PROFLE KIDS ## kids = gui.yes_no(_.KIDS_PROFILE_INFO, heading=_.KIDS_PROFILE) ## PROFILE NAME ## name = '' while True: name = gui.input(_.PROFILE_NAME, default=name).strip() if not name: return elif name.lower() in taken_names: gui.notification(_(_.PROFILE_NAME_TAKEN, name=name)) else: break ## ADD PROFILE ## profile = api.add_profile(name, icon_set=avatar[0], icon_index=avatar[1], kids=kids) if 'message' in profile: raise PluginError(profile['message']) _set_profile(profile)
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']))
def add_watchlist(id, title, series=0, **kwargs): if int(series) == 1: result = api.set_user_collection(id, is_bookmarked='true') else: result = api.set_user_media(id, is_bookmarked='true') gui.notification(title, heading=_.WATCHLIST_ADDED) gui.refresh()
def follow_creator(slug, **kwargs): with gui.progress(background=True, percent=90): creator = _get_creator(slug) api.follow_creator(creator['_id']) gui.notification(_(_.FOLLOWED_CREATOR, creator=creator['title']), icon=creator['avatar'])
def _select_profile(): profiles = api.user()['accountProfiles'] values = [] options = [] default = -1 for index, profile in enumerate(profiles): values.append(profile['id']) options.append( plugin.Item(label=profile['name'], art={'thumb': config.image(profile['profilePicPath'])})) if profile['id'] == userdata.get('profile_id'): default = index index = gui.select(_.SELECT_PROFILE, options=options, preselect=default, useDetails=True) if index < 0: return api.set_profile(values[index]) gui.notification(_.PROFILE_ACTIVATED, heading=userdata.get('profile_name'), icon=config.image(userdata.get('profile_img')))
def check_alerts(): alerts = userdata.get('alerts', []) if not alerts: return for game in Game.select().where(Game.id << alerts): if game.state == Game.LIVE: alerts.remove(game.id) _to_start = game.start - arrow.utcnow().timestamp if settings.getInt('alert_when') == Alert.STREAM_START: message = _.STREAM_STARTED elif settings.getInt('alert_when') == Alert.KICK_OFF and _to_start > 0 and _to_start <= SERVICE_TIME: message = _.KICKOFF else: continue if settings.getInt('alert_type') == Alert.NOTIFICATION: gui.notification(message, heading=game.title, time=5000, icon=game.image) elif gui.yes_no(message, heading=game.title, yeslabel=_.WATCH, nolabel=_.CLOSE): _get_play_item(game, Game.FULL, play_type=settings.getEnum('live_play_type', PLAY_FROM_TYPES, default=PLAY_FROM_ASK)).play() elif game.state != Game.UPCOMING: alerts.remove(game.id) userdata.set('alerts', alerts)
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'))
def _set_profile(profile): userdata.set('profile', profile['id']) userdata.set('profile_name', profile['alias']) userdata.set('avatar', profile['avatar']['uri']) if profile['id']: gui.notification(_.PROFILE_ACTIVATED, heading=profile['alias'], icon=profile['avatar']['uri'])
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)
def _set_profile(profile, notify=True): userdata.set('avatar_id', profile['avatar_id']) userdata.set('profile_name', profile['name']) userdata.set('profile_id', profile['id']) if notify: gui.notification(_.PROFILE_ACTIVATED, heading=profile['name'], icon=_get_avatar(profile['avatar_id']))
def _add_profile(taken_names, taken_avatars): ## PROFILE AVATAR ## options = [plugin.Item(label=_(_.RANDOM_AVATAR, _bold=True)),] values = ['_random',] avatars = {} unused = [] data = api.collection_by_slug('avatars', 'avatars') for container in data['containers']: if container['set']['contentClass'] == 'hidden': continue category = _get_text(container['set']['texts'], 'title', 'set') for row in container['set'].get('items', []): if row['images'][0]['url'] in taken_avatars: label = _(_.AVATAR_USED, label=category) else: label = category unused.append(row['avatarId']) options.append(plugin.Item(label=label, art={'thumb': row['images'][0]['url']})) values.append(row['avatarId']) avatars[row['avatarId']] = row['images'][0]['url'] index = gui.select(_.SELECT_AVATAR, options=options, useDetails=True) if index < 0: return avatar = values[index] if avatar == '_random': avatar = random.choice(unused or avatars.keys()) ## PROFLE KIDS ## kids = gui.yes_no(_.KIDS_PROFILE_INFO, heading=_.KIDS_PROFILE) ## PROFILE NAME ## name = '' while True: name = gui.input(_.PROFILE_NAME, default=name).strip() if not name: return elif name in taken_names: gui.notification(_(_.PROFILE_NAME_TAKEN, name=name)) else: break profile = api.add_profile(name, kids=kids, avatar=avatar) profile['_avatar'] = avatars[avatar] if 'errors' in profile: raise PluginError(profile['errors'][0].get('description')) _set_profile(profile)
def add_favourite(id, **kwargs): data = _app_data() channel = data['regions'][ALL]['channels'].get(id) if not channel: return favourites = userdata.get('favourites') or [] if id not in favourites: favourites.append(id) userdata.set('favourites', favourites) gui.notification(_.MY_CHANNEL_ADDED, heading=channel['name'], icon=channel['logo'])
def _delete_profile(profiles): options = [] for index, profile in enumerate(profiles): options.append(plugin.Item(label=profile['name'], art={'thumb': profile['iconImage']['url']})) index = gui.select(_.SELECT_DELETE_PROFILE, options=options, useDetails=True) if index < 0: return selected = profiles[index] if gui.yes_no(_.DELETE_PROFILE_INFO, heading=_(_.DELTE_PROFILE_HEADER, name=selected['name'])) and api.delete_profile(selected['id']): gui.notification(_.PROFILE_DELETED, heading=selected['name'], icon=selected['iconImage']['url'])
def alert(asset, title, **kwargs): alerts = userdata.get('alerts', []) if asset not in alerts: alerts.append(asset) gui.notification(title, heading=_.REMINDER_SET) else: alerts.remove(asset) gui.notification(title, heading=_.REMINDER_REMOVED) userdata.set('alerts', alerts) gui.refresh()
def alerts(slug, **kwargs): game = get_game(slug) alerts = userdata.get('alerts', []) if game.id not in alerts: alerts.append(game.id) gui.notification(_.REMINDER_SET, heading=game.title, icon=game.image) else: alerts.remove(game.id) gui.notification(_.REMINDER_REMOVED, heading=game.title, icon=game.image) userdata.set('alerts', alerts) gui.refresh()
def _add_profile(taken_names, taken_avatars): ## PROFILE AVATAR ## options = [ plugin.Item(label=_(_.RANDOM_AVATAR, _bold=True)), ] values = [ '_random', ] avatars = [] unused = [] for avatar in api.profile_config()['avatars']: values.append(avatar['id']) avatars.append(avatar['id']) if avatar['id'] in taken_avatars: label = _(_.AVATAR_USED, _bold=True) else: label = _.AVATAR_NOT_USED unused.append(avatar['id']) options.append( plugin.Item(label=label, art={'thumb': _get_avatar(avatar['id'])})) index = gui.select(_.SELECT_AVATAR, options=options, useDetails=True) if index < 0: return avatar_id = values[index] if avatar_id == '_random': avatar_id = random.choice(unused or avatars) ## PROFILE NAME ## name = '' while True: name = gui.input(_.PROFILE_NAME, default=name).strip() if not name: return elif name.lower() in taken_names: gui.notification(_(_.PROFILE_NAME_TAKEN, name=name)) else: break ## ADD PROFILE ## profile = api.add_profile(name, avatar_id) if 'message' in profile: raise PluginError(profile['message']) _set_profile(profile)
def _set_profile(profile): pin = None if profile['attributes']['parentalControls']['isPinProtected']: pin = gui.input(_.ENTER_PIN, hide_input=True).strip() api.set_profile(profile, pin=pin) if settings.getBool('kid_lockdown', False) and profile['attributes']['kidsModeEnabled']: userdata.set('kid_lockdown', True) userdata.set('avatar', profile['_avatar']) userdata.set('profile', profile['profileName']) userdata.set('profile_id', profile['profileId']) gui.notification(_.PROFILE_ACTIVATED, heading=profile['profileName'], icon=profile['_avatar'])
def alert(match_id, title, **kwargs): match_id = int(match_id) alerts = userdata.get('alerts', []) if match_id not in alerts: alerts.append(match_id) gui.notification(title, heading=_.REMINDER_SET) else: alerts.remove(match_id) gui.notification(title, heading=_.REMINDER_REMOVED) userdata.set('alerts', alerts) gui.refresh()
def _add_profile(taken_names, taken_avatars): ## PROFILE AVATAR ## options = [ plugin.Item(label=_(_.RANDOM_AVATAR, _bold=True)), ] values = [ '_random', ] unused = [] for key in AVATARS: label = '' if key in taken_avatars: label = _(_.AVATAR_USED, label=label) else: unused.append(key) options.append(plugin.Item(label=label, art={'thumb': AVATARS[key]})) values.append(key) index = gui.select(_.SELECT_AVATAR, options=options, useDetails=True) if index < 0: return avatar = values[index] if avatar == '_random': avatar = random.choice(unused or AVATARS.keys()) ## PROFLE KIDS ## kids = gui.yes_no(_.KIDS_PROFILE_INFO, heading=_.KIDS_PROFILE) ## PROFILE NAME ## name = '' while True: name = gui.input(_.PROFILE_NAME, default=name).strip() if not name: return elif name in taken_names: gui.notification(_(_.PROFILE_NAME_TAKEN, name=name)) else: break profile = api.add_profile(name, kids, avatar) _set_profile(profile)
def add_favourite(video_id, title, **kwargs): api.add_favourite(video_id) gui.notification(_(_.FAVOURITE_ADDED, title=title))
def add_watchlist(content_id, title=None, icon=None, **kwargs): gui.notification(_.ADDED_WATCHLIST, heading=title, icon=icon) api.add_watchlist(content_id)
def unfollow_creator(slug, title, icon, **kwargs): api.unfollow_creator(slug) gui.notification(_(_.UNFOLLOWED_CREATOR, creator=title), icon=icon) gui.refresh()
def add_watchlist(series_id, title, **kwargs): api.add_watchlist(series_id) gui.notification(_(_.WATCHLIST_ADDED, title=title))
def follow_creator(slug, title, icon, **kwargs): api.follow_creator(slug) gui.notification(_(_.FOLLOWED_CREATOR, creator=title), icon=icon)