def browse_trailers(): per_page = plugin.get_setting('per-page', int) skip = plugin.request.arg('skip') scraper = get_scraper() trailers = scraper.browse_trailers(skip) items = [] if len(trailers) < per_page: skip = (skip or 1) + 1 trailers.extend(scraper.browse_trailers(skip)) total = len(trailers) if skip > 2: skip_prev = max(skip - 1, 0) total += 1 items.append({ 'label': lang(34003), 'path': plugin.request.url_with_params(skip=skip_prev) }) plugin.add_items(with_fanart(items), total) for batch_res in batch(trailers, BATCH_EPISODES_COUNT): if abort_requested(): break items = itemify_trailers(batch_res) plugin.add_items(with_fanart(items), total) items = [] if scraper.has_more: skip_next = (skip or 1) + 1 items.append({ 'label': lang(34004), 'path': plugin.request.url_with_params(skip=skip_next) }) plugin.add_items(with_fanart(items), len(items)) plugin.finish(update_listing=skip > 2)
def browse_library(): plugin.set_content('tvshows') scraper = get_scraper() library = library_items() total = len(library) for batch_ids in batch(library, BATCH_SERIES_COUNT): if abort_requested(): break series = scraper.get_series_bulk(batch_ids) items = [itemify_series(series[i], highlight_library_items=False) for i in batch_ids] plugin.add_items(with_fanart(items), total) plugin.finish(sort_methods=['unsorted', 'label'])
def browse_all_series(): plugin.set_content('tvshows') scraper = get_scraper() all_series_ids = scraper.get_all_series_ids() total = len(all_series_ids) for batch_ids in batch(all_series_ids, BATCH_SERIES_COUNT): if abort_requested(): break series = scraper.get_series_bulk(batch_ids) items = [itemify_series(series[i]) for i in batch_ids] plugin.add_items(with_fanart(items), total) plugin.finish()
def browse_favorites(): plugin.set_content('tvshows') scraper = get_scraper() library = scraper.get_favorite_series() total = len(library) for batch_ids in batch(library, BATCH_SERIES_COUNT): if abort_requested(): break series = scraper.get_series_bulk(batch_ids) items = [itemify_series(series[i]) for i in batch_ids] plugin.add_items(with_fanart(items), total) plugin.finish(sort_methods=['unsorted', 'label'])
def index(): plugin.set_content('episodes') skip = plugin.request.arg('skip') per_page = plugin.get_setting('per-page', int) scraper = get_scraper() episodes = scraper.browse_episodes(skip) if episodes and not skip: check_last_episode(episodes[0]) check_first_start() new_episodes = library_new_episodes() new_str = "(%s) " % tf.color(str( len(new_episodes)), NEW_LIBRARY_ITEM_COLOR) if new_episodes else "" total = len(episodes) header = [ { 'label': lang(40401), 'path': plugin.url_for('browse_all_series') }, { 'label': lang(40407) % new_str, 'path': plugin.url_for('browse_library'), 'context_menu': update_library_menu() }, ] items = [] if skip: skip_prev = max(skip - per_page, 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(episodes, BATCH_EPISODES_COUNT): if abort_requested(): break items = itemify_episodes(batch_res) plugin.add_items(with_fanart(items), total) items = [] if scraper.has_more: skip_next = (skip or 0) + per_page items.append({ 'label': lang(34004), 'path': plugin.request.url_with_params(skip=skip_next) }) plugin.finish(items=with_fanart(items), cache_to_disc=False, update_listing=skip is not None)
def index(): plugin.set_content('episodes') skip = plugin.request.arg('skip') per_page = plugin.get_setting('per-page', int) scraper = get_scraper() episodes = scraper.browse_episodes(skip) if episodes and not skip: check_last_episode(episodes[0]) check_first_start() new_episodes = library_new_episodes() new_str = "(%s) " % tf.color(str(len(new_episodes)), NEW_LIBRARY_ITEM_COLOR) if new_episodes else "" total = len(episodes) header = [ {'label': lang(40401), 'path': plugin.url_for('browse_all_series')}, {'label': lang(40407) % new_str, 'path': plugin.url_for('browse_library'), 'context_menu': update_library_menu()}, ] items = [] if skip: skip_prev = max(skip - per_page, 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(episodes, BATCH_EPISODES_COUNT): if abort_requested(): break items = itemify_episodes(batch_res) plugin.add_items(with_fanart(items), total) items = [] if scraper.has_more: skip_next = (skip or 0) + per_page items.append({ 'label': lang(34004), 'path': plugin.request.url_with_params(skip=skip_next) }) plugin.finish(items=with_fanart(items), cache_to_disc=False, update_listing=skip is not None)
def search(): skbd = xbmc.Keyboard() skbd.setHeading(lang(40423)) skbd.doModal() if skbd.isConfirmed(): query = skbd.getText() else: return None plugin.set_content('tvshows') scraper = get_scraper() library = scraper.search_serial(query) total = len(library) for batch_ids in batch(library, BATCH_SERIES_COUNT): if abort_requested(): break series = scraper.get_series_bulk(batch_ids) items = [itemify_series(series[i]) for i in batch_ids] plugin.add_items(with_fanart(items), total) plugin.finish(sort_methods=['unsorted', 'label'])
def _aborted(self): return abort_requested() or self.buffering_progress.is_cancelled() or \ self.playing_progress.is_cancelled()
def _aborted(self): return abort_requested() or self.buffering_progress.is_cancelled() or self.playing_progress.is_cancelled()