Ejemplo n.º 1
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))
Ejemplo n.º 2
0
def toggle_auto_refresh_context_menu(section, media_id):
    not_refreshing_items = container.not_refreshing_items()
#   plugin.log.info("Media ID: %d, Expire: %r" % (media_id, container.details_cache().get_item_expire(media_id)))
    if media_id in not_refreshing_items:
        return [(lang(40323), actions.background(plugin.url_for('turn_on_auto_refresh',
                                                                section=section.filter_val, media_id=media_id)))]
    else:
        return [(lang(40324), actions.background(plugin.url_for('turn_off_auto_refresh',
                                                                section=section.filter_val, media_id=media_id)))]
Ejemplo n.º 3
0
def bookmark_context_menu(media_id, section, title):
    bookmarks = container.bookmarks()
    if media_id in bookmarks:
        return [(lang(40307), actions.background(plugin.url_for('delete_bookmark', media_id=media_id,
                                                                section=section.filter_val)))]
    else:
        return [(lang(40306), actions.background(plugin.url_for('add_bookmark', media_id=media_id,
                                                                section=section.filter_val,
                                                                title=ensure_str(title))))]
Ejemplo n.º 4
0
def library_context_menu(section, media_id, folder_id):
    library_manager = container.library_manager()
    if library_manager.has_folder(folder_id):
        return [(lang(40321), actions.background(plugin.url_for('remove_from_library',
                                                                folder_id=folder_id)))]
    else:
        return [(lang(40320), actions.background(plugin.url_for('add_to_library',
                                                                section=section.filter_val,
                                                                media_id=media_id,
                                                                folder_id=folder_id)))]
Ejemplo n.º 5
0
def mark_watched_context_menu(section, media_id, date_added=None, total_size=None):
    watched_items = container.watched_items()
    if media_id in watched_items:
        return [(lang(40302), actions.background(plugin.url_for('mark_unwatched', media_id=media_id)))]
    else:
        return [(lang(40301), actions.background(plugin.url_for('mark_watched',
                                                                section=section.filter_val,
                                                                media_id=media_id,
                                                                date_added=date_added,
                                                                total_size=total_size)))]
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
def explore(section):
    plugin.set_content("movies")
    section = Section.find(section)
    sf = container.search_filter(section)
    header = [
        {"label": lang(34000), "path": plugin.url_for("search_index", section=section.filter_val)},
        {"label": lang(34001), "path": plugin.url_for("genre_index", section=section.filter_val)}
        if section != Section.ANIME
        else None,
        {"label": lang(34002), "path": plugin.url_for("bookmarks_index", section=section.filter_val)},
        {"label": lang(34011), "path": plugin.url_for("history_index", section=section.filter_val)},
    ]
    header = [h for h in header if h is not None]
    make_search(sf, header)
Ejemplo n.º 8
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())
        ]
    )
Ejemplo n.º 9
0
def new_search(section):
    storage = container.search_storage()
    if 'search_term' in storage:
        value = storage['search_term']
    else:
        value = plugin.keyboard(heading=lang(40310))
        if not value:
            return
        storage['search_term'] = value
    plugin.redirect(plugin.url_for('do_search', section=section, name=value, new=True))
Ejemplo n.º 10
0
def itemify_file(f, **kwargs):
    """
    :type f: File
    """
    item = {
        'label': tf.file_title(f),
        'context_menu':
            refresh_context_menu(f.media_id) +
            toggle_watched_context_menu() +
            download_torrent_context_menu(f.link),
        'is_playable': True,
        'stream_info': [('video', {
            'codec': f.file_format,
            'width': f.resolution[0],
            'height': f.resolution[1],
            'duration': f.duration,
        })],
        'path': plugin.url_for('play_file', section=f.section.filter_val, media_id=f.media_id,
                               url=f.link, title=f.title, **kwargs)
    }
    return with_fanart(item)
Ejemplo n.º 11
0
def itemify_folder(f):
    """
    :type f: Folder
    :rtype: dict
    """
    item = {
        'label': tf.folder_title(f),
        'path': plugin.url_for('show_files', section=f.section.filter_val, media_id=f.media_id, folder_id=f.id),
        'context_menu':
            refresh_context_menu(f.media_id) +
            download_torrent_context_menu(f.link) +
            library_context_menu(f.section, f.media_id, f.id),
        'info': {
            'size': f.size,
        },
        'stream_info': {
            'video': {
                'width': f.fmt.width,
                'height': f.fmt.height,
            },
        }
    }
    return with_fanart(item)
Ejemplo n.º 12
0
def itemify_details(details):
    """
    :type details: Details
    :rtype: dict
    """
    item = {
        'thumbnail': details.poster,
        'path': plugin.url_for('show_folders', section=details.section.filter_val, media_id=details.media_id),
        'info': filter_dict({
            'plot': details.plot,
            'title': details.title,
            'rating': details.rating,
            'cast': details.actors,
            'studio': u" / ".join(details.studios),
            'writer': u" / ".join(details.creators),
            'premiered': details.release_date_russia or details.release_date,
            'genre': u" / ".join(unicode(g) for g in details.genres),
            'year': details.year,
            'originaltitle': u" / ".join(details.original_title),
        }),
    }
    if plugin.get_setting('use-screenshots-as-fanart', bool) and hasattr(details, 'screenshots') and details.screenshots:
        item.setdefault('properties', {})['fanart_image'] = random.choice(details.screenshots)
    return with_fanart(item)
Ejemplo n.º 13
0
def clear_history_context_menu():
    return [(lang(40315), actions.background(plugin.url_for('clear_history')))]
Ejemplo n.º 14
0
def download_torrent_context_menu(url):
    if container.torrent_client() and url:
        return [(lang(40314), actions.background(plugin.url_for('download_torrent', url=url)))]
    else:
        return []
Ejemplo n.º 15
0
def refresh_all_context_menu():
    return [(lang(40303), actions.background(plugin.url_for('refresh_all')))]
Ejemplo n.º 16
0
def refresh_context_menu(media_id):
    return [(lang(40304), actions.background(plugin.url_for('refresh', media_id=media_id)))]