コード例 #1
0
def RefreshItem(rating_key=None,
                came_from="/recent",
                item_title=None,
                force=False,
                refresh_kind=None,
                previous_rating_key=None,
                timeout=8000,
                randomize=None,
                trigger=True):
    assert rating_key
    from interface.main import fatality
    header = " "
    if trigger:
        set_refresh_menu_state(u"Triggering %sRefresh for %s" %
                               ("Force-" if force else "", item_title))
        Thread.Create(refresh_item,
                      rating_key=rating_key,
                      force=force,
                      refresh_kind=refresh_kind,
                      parent_rating_key=previous_rating_key,
                      timeout=int(timeout))

        header = u"%s of item %s triggered" % ("Refresh" if not force else
                                               "Forced-refresh", rating_key)
    return fatality(randomize=timestamp(), header=header, replace_parent=True)
コード例 #2
0
def TriggerDownloadSubtitle(rating_key=None,
                            subtitle_id=None,
                            item_title=None,
                            language=None,
                            randomize=None):
    from interface.main import fatality

    set_refresh_menu_state("Downloading subtitle for %s" % item_title
                           or rating_key)
    search_results = get_item_task_data("AvailableSubsForItem", rating_key,
                                        language)

    download_subtitle = None
    for subtitle in search_results:
        if str(subtitle.id) == subtitle_id:
            download_subtitle = subtitle
            break
    if not download_subtitle:
        Log.Error(u"Something went horribly wrong")

    else:
        scheduler.dispatch_task("DownloadSubtitleForItem",
                                rating_key=rating_key,
                                subtitle=download_subtitle)

    scheduler.clear_task_data("AvailableSubsForItem")

    return fatality(randomize=timestamp(), header=" ", replace_parent=True)
コード例 #3
0
def TriggerDownloadSubtitle(rating_key=None, subtitle_id=None, item_title=None, language=None, randomize=None):
    from interface.main import fatality

    set_refresh_menu_state(_("Downloading subtitle for %(title_or_id)s", title_or_id=item_title or rating_key))
    search_results = get_item_task_data("AvailableSubsForItem", rating_key, language)

    download_subtitle = None
    for subtitle in search_results:
        if str(subtitle.id) == subtitle_id:
            download_subtitle = subtitle
            break
    if not download_subtitle:
        Log.Error(u"Something went horribly wrong")

    else:
        scheduler.dispatch_task("DownloadSubtitleForItem", rating_key=rating_key, subtitle=download_subtitle)

    scheduler.clear_task_data("AvailableSubsForItem")

    return fatality(randomize=timestamp(), header=" ", replace_parent=True)
コード例 #4
0
def RefreshItem(rating_key=None, came_from="/recent", item_title=None, force=False, refresh_kind=None,
                previous_rating_key=None, timeout=8000, randomize=None, trigger=True):
    assert rating_key
    from interface.main import fatality
    header = " "
    if trigger:
        t = u"Triggering refresh for %(title)s"
        if force:
            u"Triggering forced refresh for %(title)s"
        set_refresh_menu_state(_(t,
                                 title=item_title))
        Thread.Create(refresh_item, rating_key=rating_key, force=force, refresh_kind=refresh_kind,
                      parent_rating_key=previous_rating_key, timeout=int(timeout))

        t = u"Refresh of item %(item_id)s triggered"
        if force:
            t = u"Forced refresh of item %(item_id)s triggered"
        header = _(t,
                   item_id=rating_key)
    return fatality(randomize=timestamp(), header=header, replace_parent=True)