示例#1
0
def genre_index(section):
    return with_fanart(
        [
            {"label": g.localized, "path": plugin.url_for("by_genre", section=section, genre=g.name)}
            for g in sorted(Genre.all())
        ]
    )
示例#2
0
def search_index(section):
    storage = container.search_storage()
    if 'search_term' in storage:
        del storage['search_term']
    context_menu = [
        (lang(40309), actions.background(plugin.url_for('clear_search_history')))
    ]
    items = [{
        'label': lang(34009),
        'path': plugin.url_for('new_search', section=section),
        'context_menu': context_menu,
        'replace_context_menu': True,
    }, {
        'label': lang(34010),
        'path': plugin.url_for('advanced_search', section=section),
        'context_menu': context_menu,
        'replace_context_menu': True,
    }]
    if 'search_recent' in storage:
        items.extend([{
            'label': s,
            'path': plugin.url_for('do_search', section=section, name=s),
            'context_menu': context_menu + [
                (lang(40311), actions.background(plugin.url_for('delete_search', name=s)))
            ],
            'replace_context_menu': True,
        } for s in reversed(storage['search_recent'])])
    plugin.finish(with_fanart(items))
示例#3
0
def make_search(sf, header=None, cache_to_disc=False, update_listing=False):
    skip = plugin.request.arg('skip')
    scraper = container.scraper()
    results = scraper.search_cached(sf, skip)
    if not results:
        return False
    if isinstance(results, Details):
        if header:
            plugin.add_items(with_fanart(header))
        item = itemify_single_result(results)
        plugin.finish(items=[item], cache_to_disc=cache_to_disc, update_listing=update_listing)
        return True

    total = len(results)
    items = []
    if skip:
        skip_prev = max(skip - sf.page_size, 0)
        total += 1
        items.append({
            'label': lang(34003),
            'path': plugin.request.url_with_params(skip=skip_prev)
        })
    elif header:
        items.extend(header)
        total += len(header)
    plugin.add_items(with_fanart(items), total)
    for batch_res in batch(results):
        if abort_requested():
            break
        items = itemify_search_results(sf.section, batch_res)
        plugin.add_items(items, total)
    items = []
    if scraper.has_more:
        skip_next = (skip or 0) + sf.page_size
        items.append({
            'label': lang(34004),
            'path': plugin.request.url_with_params(skip=skip_next)
        })
    plugin.finish(items=with_fanart(items),
                  sort_methods=['unsorted', 'date', 'title', 'video_year', 'video_rating'],
                  cache_to_disc=cache_to_disc,
                  update_listing=update_listing or skip is not None)
    return True
示例#4
0
def index():
    items = [
        {"label": lang(34002), "path": plugin.url_for("global_bookmarks")},
        {"label": lang(34011), "path": plugin.url_for("global_history")},
    ]
    library_manager = container.library_manager()
    if library_manager.has_folders():
        items.append({"label": lang(34012), "path": plugin.url_for("library_items")})
    items.extend(
        {"label": tf.decorate(s.localized, bold=True, color="white"), "path": plugin.url_for("explore", section=s.name)}
        for s in Section
    )
    return with_fanart(items)
示例#5
0
def history_index(section):
    plugin.set_content("movies")
    section = Section.find(section)
    history = container.history()
    items = []
    for item in reversed(history.get(section)):
        items.append(
            {
                "label": item.title,
                "thumbnail": item.poster,
                "path": item.path,
                "is_playable": True,
                "context_menu": toggle_watched_context_menu()
                + bookmark_context_menu(item.media_id, item.section, item.title)
                + download_torrent_context_menu(item.url)
                + clear_history_context_menu(),
            }
        )
    return with_fanart(items)