Example #1
0
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()
Example #2
0
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)