def show_files(section, media_id, folder_id): scraper = container.scraper() section = Section.find(section) plugin.set_content("movies") files = scraper.get_files_cached(section, media_id, folder_id) plugin.add_items(itemify_file(f) for f in files) plugin.finish(sort_methods=["unsorted", "title", "duration", "size"])
def bookmarks_index(section): plugin.set_content("movies") section = Section.find(section) bookmarks = container.bookmarks().get(section) total = len(bookmarks) for b in batch(reversed(bookmarks)): if abort_requested(): break items = itemify_bookmarks(b) plugin.add_items(items, total) plugin.finish(sort_methods=["unsorted", "title", "video_year", "video_rating"], cache_to_disc=False)
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)
def do_search(section, name): plugin.set_content('movies') section = Section.find(section) sf = container.search_filter(section=section, name=str(name)) if not make_search(sf): notify(lang(40312) % ensure_unicode(name)) elif plugin.request.arg('new'): storage = container.search_storage() recent = storage.get('search_recent', []) if name in recent: recent.remove(name) recent.append(name) storage['search_recent'] = recent count = plugin.get_setting('search-items-count', int) if len(recent) > count: del recent[:len(recent)-count]
def show_folders(section, media_id): section = Section.find(section) scraper = container.scraper() meta_cache = container.meta_cache() meta = meta_cache.setdefault(media_id, {}) plugin.set_content("movies") folders = scraper.get_folders_cached(section, media_id) total_size = sum(f.size for f in folders) meta["total_size"] = total_size for f in folders: if len(f.files) == 1 and not meta.get("is_series"): item = itemify_file(f.files[0], can_mark_watched=1) item["label"] = tf.folder_file_title(f, f.files[0]) item["context_menu"] += library_context_menu(section, media_id, f.id) else: item = itemify_folder(f) plugin.add_item(item) plugin.finish(sort_methods=["unsorted", "title", "duration", "size"])
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)
def by_genre(section, genre): plugin.set_content("movies") section = Section.find(section) genre = Genre.find(genre) or unicode(genre) sf = container.search_filter(section, genres=[genre]) make_search(sf)