def click_search(): global last_search_term search_term = mc.ShowDialogKeyboard("Ange sökterm", last_search_term, False) if not search_term or search_term == "": BPLog("Search cancelled") return last_search_term = search_term searched_episodes_item = mc.ListItem() searched_episodes_item.SetLabel("Avsnitt för \"%s\"" %search_term) searched_episodes = client.get_episodes_from_search_term(search_term) searched_episodes_thread = AsyncTask(target=iterate, kwargs={"iterable":searched_episodes, "limit": 50}) searched_episodes_thread.start() searched_shows_item = mc.ListItem() searched_shows_item.SetLabel("Program för \"%s\"" %search_term) searched_shows = client.get_shows_from_search_term(search_term, settings.show_premium()) searched_shows = islice(searched_shows, 200) load_shows(searched_shows, searched_shows_item) mc.ShowDialogWait() searched_episodes_thread.join() searched_episodes = searched_episodes_thread.get_result() add_episodes(searched_episodes, searched_episodes_item) mc.HideDialogWait()
def initiate(): global category_list_index global show_list_index global episode_list_index global labelPrograms global labelEpisodes global country_code global is_sweden global client global initiated BPTraceEnter() mc.ShowDialogWait() if not initiated: job_manager.start() ip_getter.start() try: client = WlpsClient() except Exception, e: track ("Wlps Init Error", { "Locale": mc.GetGeoLocation(), "Platform": mc.GetPlatform(), "Country Code": country_code, "Id": mc.GetUniqueId() }) BPLog("Could not set up API client: " + str(e)) show_error_and_exit(message="Kunde inte kontakta API-servern. Appen stängs ner...") latest_thread = AsyncTask(target=iterate, kwargs={"iterable":client.get_latest_full_episodes(), "limit":100}) latest_thread.start() ip_getter.join(3.0) try: country_code = ip_getter.get_country_code() is_sweden = country_code == "SE" except Exception, e: BPLog("Could not retreive physical location of client: " + str(e))
def load_shows_from_category(): global focused_group cList = mc.GetWindow(14000).GetList(1000) focused_group = 100 cItem = cList.GetItem(cList.GetFocusedItem()) category_id = cItem.GetProperty("id") episodes = client.get_episodes_from_category_id(category_id) latest_episodes_thread = AsyncTask(target=iterate, kwargs={"iterable":episodes, "limit":40}) latest_episodes_thread.start() shows = client.get_shows_from_id(category_id) shows = ifilter(has_episodes, shows) load_shows(shows, cItem) latest_episodes_thread.join() latest_episodes_item = mc.ListItem() latest_episodes_item.SetLabel("Senaste " + cItem.GetLabel()) latest_for_category = latest_episodes_thread.get_result() add_episodes(latest_for_category, latest_episodes_item)
def retry_load_city_info(self): task = AsyncTask(self.info_loader) task.start()
def load_city_info(self, city): self.info_loader.city = city task = AsyncTask(self.info_loader) task.start()
def load_cities(self, country_id): self.db_loader.country_id = country_id task = AsyncTask(self.db_loader) task.start()
def load_countries(self): task = AsyncTask(self.db_loader) task.start()
from flask import Flask from flask import request, jsonify, make_response from bot_exception import BotException from slackclient import SlackClient from config import Config from bot import Bot from async_task import AsyncTask import requests import json config = Config() slack_client = SlackClient(config.bot_token) bot = Bot() app = Flask(__name__) async_task = AsyncTask() @app.errorhandler(BotException) def handle_bot_exception(error): response = jsonify(error.to_dict()) response.status_code = error.status_code return response # # Message Event Listener # Entry point for all events from slack # @app.route('/quotebot', methods=['POST', 'GET']) def event_listener():