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 del_favourite(id, **kwargs): favourites = userdata.get('favourites') or [] if id in favourites: favourites.remove(id) userdata.set('favourites', favourites) gui.refresh()
def logout(**kwargs): if not gui.yes_no(_.LOGOUT_YES_NO): return api.logout() mem_cache.empty() gui.refresh()
def delete_watchlist(content_id, **kwargs): data = api.delete_watchlist(content_id) if not data.get('watchlistItems'): gui.redirect(plugin.url_for('')) else: gui.refresh()
def logout(**kwargs): if not gui.yes_no(_.LOGOUT_YES_NO): return api.logout() userdata.delete('kid_lockdown') gui.refresh()
def unfollow_creator(slug, **kwargs): with gui.progress(background=True, percent=90): creator = _get_creator(slug) api.unfollow_creator(creator['_id']) gui.notification(_(_.UNFOLLOWED_CREATOR, creator=creator['title']), icon=creator['avatar']) gui.refresh()
def edit_playlist_value(playlist_id, method, **kwargs): playlist_id = int(playlist_id) playlist = Playlist.get_by_id(playlist_id) method = getattr(playlist, method) if method(): playlist.save() gui.refresh()
def edit_epg_value(epg_id, method, **kwargs): epg_id = int(epg_id) epg = EPG.get_by_id(epg_id) method = getattr(epg, method) if method(): epg.save() gui.refresh()
def install_service(**kwargs): with gui.progress(_.INSTALL_SERVICE, percent=100) as progress: restart_required = gpio.install() if restart_required and gui.yes_no(_.RESTART_REQUIRED): plugin.reboot() gui.refresh()
def edit_profile(key, value, **kwargs): profile = api.active_profile() if key == 'prefer_133': profile['attributes']['playbackSettings']['prefer133'] = bool(int(value)) if api.update_profile(profile): gui.refresh()
def new_epg(**kwargs): epg = EPG.user_create() if not epg: return if settings.getBool('ask_to_add', True) and epg.source_type != EPG.TYPE_ADDON and gui.yes_no(_.ADD_PLAYLIST): Playlist.user_create() gui.refresh()
def delete_epg(epg_id, **kwargs): if not gui.yes_no('Are you sure you want to delete this EPG?'): return epg_id = int(epg_id) epg = EPG.get_by_id(epg_id) epg.delete_instance() gui.refresh()
def logout(**kwargs): if not gui.yes_no(_.LOGOUT_YES_NO): return api.logout() userdata.delete('avatar') userdata.delete('profile') userdata.delete('profile_name') gui.refresh()
def shift_playlist(playlist_id, shift, **kwargs): shift = int(shift) playlist = Playlist.get_by_id(int(playlist_id)) Playlist.update(order = Playlist.order - shift).where(Playlist.order == playlist.order + shift).execute() playlist.order += shift playlist.save() gui.refresh()
def delete_epg(epg_id, **kwargs): if not gui.yes_no(_.CONF_DELETE_EPG): return epg_id = int(epg_id) epg = EPG.get_by_id(epg_id) epg.delete_instance() gui.refresh()
def _create_session(self, force=False): self._config = self.get_config() platform = self._config['alpha_networks_dash'][REGION] self._session._base_url = platform['platform_url'] + '{}' self._session.headers.update({ 'X-AN-WebService-IdentityKey': platform['hss_key'], # hss_key, hls_key, chromecast_key }) if not self.logged_in or (not force and time.time() < userdata.get('token_expires')): return login_type = settings.getEnum('login_type', choices=LOGIN_TYPE, default=LOGIN_MULTI_IP) if login_type == LOGIN_MULTI_IP: # Single device, changing IP address (same as app) data = self._session.post('proxy/loginDevice', headers=self._auth_headers).json() elif login_type == LOGIN_MULTI_DEVICE: # Multiple device, static IP address data = self._session.post('proxy/casAvailableDevice', headers=self._auth_headers).json() elif login_type == LOGIN_PASSWORD: # Supports multiple devices and multiple IP address as long (as others also using password) data = { 'password': userdata.get('password'), 'deviceId': userdata.get('device_id'), 'email': userdata.get('username'), } data = self._session.post('proxy/login', data=data).json() if data['error']: error = _(_.TOKEN_ERROR, msg=data['error']['message']) if data['error']['code'] == -1: self.logout() gui.refresh() if login_type == LOGIN_MULTI_IP: error = _.LOGIN_MULTI_IP_ERROR elif login_type == LOGIN_MULTI_DEVICE: error = _.LOGIN_MULTI_DEVICE_ERROR raise APIError(error) if 'deviceAuthToken' in data['result']: userdata.set('device_token', data['result']['deviceAuthToken']) self._set_auth(data['result']['newAuthToken'])
def delete_playlist(playlist_id, **kwargs): if not gui.yes_no('Are you sure you want to delete this playlist?'): return playlist_id = int(playlist_id) playlist = Playlist.get_by_id(playlist_id) playlist.delete_instance() Playlist.update(order = Playlist.order - 1).where(Playlist.order >= playlist.order).execute() gui.refresh()
def delete_playlist(playlist_id, **kwargs): if not gui.yes_no(_.CONF_DELETE_PLAYLIST): return playlist_id = int(playlist_id) playlist = Playlist.get_by_id(playlist_id) playlist.delete_instance() Playlist.update(order = Playlist.order - 1).where(Playlist.order >= playlist.order).execute() gui.refresh()
def login(**kwargs): singtel_tv_no = gui.input(_.SINGTEL_TV_NO).strip() if not singtel_tv_no: return identification_no = gui.input(_.IDENTIFICATION_NO).strip() if not identification_no: return api.login(singtel_tv_no, identification_no) gui.refresh()
def login(**kwargs): if gui.yes_no(_.LOGIN_WITH, yeslabel=_.DEVICE_LINK, nolabel=_.EMAIL_PASSWORD): result = _device_link() else: result = _email_password() if not result: return gui.refresh()
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 edit_channel_value(slug, method, **kwargs): channel = Channel.select(Channel, Override).where(Channel.slug == slug).join(Override, join_type='LEFT OUTER JOIN', on=(Channel.slug == Override.slug), attr='override').get() create = False if not hasattr(channel, 'override'): channel.override = Override(playlist=channel.playlist, slug=channel.slug) create = True method = getattr(channel.override, method) if method(channel): channel.override.save(force_insert=create) gui.refresh()
def reset_channel(slug, **kwargs): channel = Channel.get_by_id(slug) if channel.custom: if not gui.yes_no(_.CONF_DELETE_CHANNEL): return channel.delete_instance() Override.delete().where(Override.slug == channel.slug).execute() gui.refresh()
def login(**kwargs): if config.has_device_link and gui.yes_no( _.LOGIN_WITH, yeslabel=_.DEVICE_LINK, nolabel=_.EMAIL_PASSWORD): result = _device_link() else: result = _email_password() if not result: return _select_profile() gui.refresh()
def reset_channel(slug, **kwargs): channel = Channel.get_by_id(slug) if channel.custom: if not gui.yes_no('Are you sure you want to delete this channel?'): return channel.delete_instance() Override.delete().where(Override.slug == channel.slug).execute() gui.refresh()
def login(**kwargs): username = gui.input(_.ASK_USERNAME, default=userdata.get('username', '')).strip() if not username: return userdata.set('username', username) password = gui.input(_.ASK_PASSWORD, hide_input=True).strip() if not password: return api.login(username=username, password=password) 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 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_channel(playlist_id, radio, **kwargs): playlist_id = int(playlist_id) radio = int(radio) url = gui.input(_.ENTER_CHANNEL_URL) if not url: return playlist = Playlist.get_by_id(playlist_id) channel = Channel.from_url(playlist, url) channel.radio = radio channel.save(force_insert=True) gui.refresh()
def new_playlist(position=None, **kwargs): playlist = Playlist.user_create() if not playlist: return if position: position = int(position) Playlist.update(order = Playlist.order + 1).where(Playlist.order >= position).execute() playlist.order = position playlist.save() if settings.getBool('ask_to_add', True) and playlist.source_type != Playlist.TYPE_ADDON and gui.yes_no(_.ADD_EPG): EPG.user_create() gui.refresh()