def view_all(self): ''' Display all managed movies, which are selectable and lead to options. Also provides additional options at bottom of menu ''' STR_NO_MANAGED_MOVIES = utils.getlocalizedstring(32008) STR_REMOVE_ALL_MOVIES = utils.getlocalizedstring(32009) STR_MOVE_ALL_BACK_TO_STAGED = utils.getlocalizedstring(32010) STR_BACK = utils.getlocalizedstring(32011) STR_MANAGED_MOVIES = utils.getlocalizedstring(32012) managed_movies = self.dbh.get_content_items(status='managed', mediatype='movie', order='Title') if not managed_movies: xbmcgui.Dialog().ok(utils.ADDON_NAME, STR_NO_MANAGED_MOVIES) return lines = [str(x) for x in managed_movies] lines += [STR_REMOVE_ALL_MOVIES, STR_MOVE_ALL_BACK_TO_STAGED, STR_BACK] ret = xbmcgui.Dialog().select( '{0} - {1}'.format(utils.ADDON_NAME, STR_MANAGED_MOVIES), lines) if ret >= 0: if ret < len(managed_movies): for i, item in enumerate(managed_movies): if ret == i: self.options(item) break elif lines[ret] == STR_REMOVE_ALL_MOVIES: self.remove_all(managed_movies) elif lines[ret] == STR_MOVE_ALL_BACK_TO_STAGED: self.move_all_to_staged(managed_movies) elif lines[ret] == STR_BACK: return
def add_all_with_metadata(self): ''' Add all tvshow items with nfo file to library''' STR_ADDING_ALL_TV_SHOW_ITEMS_WITH_METADATA = utils.getlocalizedstring( 32061) STR_ALL_TV_SHOW_ITEMS_WITH_METADATA_ADDED = utils.getlocalizedstring( 32062) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_ADDING_ALL_TV_SHOW_ITEMS_WITH_METADATA) staged_tv_items = self.dbh.get_content_items(status='staged', mediatype='tvshow', order='Show_Title') # content menaget precisa retornar episode_nfo[0] for index, item in enumerate(staged_tv_items): percent = 100 * index / len(staged_tv_items) if os.path.exists(item.episode_nfo[0]): progress_dialog.update(percent, line2=item.show_title, line3=item.episode_title_with_id) xbmc.sleep(200) item.add_to_library() progress_dialog.update(percent, line2=' ', line3=' ') progress_dialog.close() utils.notification(STR_ALL_TV_SHOW_ITEMS_WITH_METADATA_ADDED)
def view(self): ''' Display all blocked items, which are selectable and lead to options. Also provides additional options at bottom of menu ''' # TODO?: change blocked movie/episode to just blocked path # TODO?: make blocked episode match on both episode AND show # TODO: add blocked types: plugin, path # TODO: add blocked keywords, let you choose type # TODO: intialize blocked list with known bad items STR_BACK = utils.getlocalizedstring(32011) STR_BLOCKED_ITEMS = utils.getlocalizedstring(32098) STR_NO_BLOCKED_ITEMS = utils.getlocalizedstring(32119) blocked_items = self.dbh.get_blocked_items() if not blocked_items: xbmcgui.Dialog().ok(utils.ADDON_NAME, STR_NO_BLOCKED_ITEMS) return lines = [ '{0} - [B]{1}[/B]'.format(x.localize_type(), x['value']) for x in blocked_items ] lines += [STR_BACK] ret = xbmcgui.Dialog().select( '{0} - {1}'.format(utils.ADDON_NAME, STR_BLOCKED_ITEMS), lines) if ret >= 0: if ret < len(blocked_items): # managed item for index, item in enumerate(blocked_items): if ret == index: self.options(item) break elif lines[ret] == STR_BACK: return
def options(self, item): ''' Provide options for a single managed movie in a dialog window ''' # TODO: add rename option # TODO: add reload metadata option STR_REMOVE = utils.getlocalizedstring(32017) STR_MOVE_BACK_TO_STAGED = utils.getlocalizedstring(32018) STR_BACK = utils.getlocalizedstring(32011) STR_MANAGED_MOVIE_OPTIONS = utils.getlocalizedstring(32019) lines = [STR_REMOVE, STR_MOVE_BACK_TO_STAGED, STR_BACK] ret = xbmcgui.Dialog().select( '{0} - {1} - {2}'.format(utils.ADDON_NAME, STR_MANAGED_MOVIE_OPTIONS, item.movie_title), lines) if ret >= 0: if lines[ret] == STR_REMOVE: item.remove_from_library() item.delete() return self.view_all() elif lines[ret] == STR_MOVE_BACK_TO_STAGED: item.remove_from_library() item.set_as_staged() return self.view_all() elif lines[ret] == STR_BACK: return self.view_all() return self.view_all()
def sync_single_movie(self, title, year, link_stream_path): ''' Sync single movie path and stage item ''' STR_ITEM_IS_ALREADY_STAGED = utils.getlocalizedstring(32103) STR_ITEM_IS_ALREADY_MANAGED = utils.getlocalizedstring(32104) STR_MOVIE_STAGED = utils.getlocalizedstring(32105) # Add synced directory to database self.dbh.add_synced_dir(title, link_stream_path, 'single-movie') # Check for duplicate in database if self.dbh.path_exists(path=link_stream_path, status='staged', mediatype='movie'): utils.notification(STR_ITEM_IS_ALREADY_STAGED) elif self.dbh.path_exists(path=link_stream_path, status='managed', mediatype='movie'): utils.notification(STR_ITEM_IS_ALREADY_MANAGED) else: # Add item to database self.dbh.add_content_item( MovieItem( title=title, year=year, link_stream_path=link_stream_path, mediatype='movie', ).returasjson(), 'movie') utils.notification( '%s: %s' % (STR_MOVIE_STAGED, utils.title_with_color(title, year)))
def view_shows(self): ''' Display all managed tvshows, which are selectable and lead to options. Also provides additional options at bottom of menu ''' STR_NO_MANAGED_TV_SHOWS = utils.getlocalizedstring(32020) STR_REMOVE_ALL_TV_SHOWS = utils.getlocalizedstring(32021) STR_MOVE_ALL_TV_SHOWS_BACK_TO_STAGED = utils.getlocalizedstring(32022) STR_BACK = utils.getlocalizedstring(32011) STR_MANAGED_TV_SHOWS = utils.getlocalizedstring(32023) managed_tvshows = self.dbh.get_all_shows('managed') if not managed_tvshows: xbmcgui.Dialog().ok(utils.ADDON_NAME, STR_NO_MANAGED_TV_SHOWS) return lines = ['[B]{}[/B]'.format(x) for x in managed_tvshows] lines += [ STR_REMOVE_ALL_TV_SHOWS, STR_MOVE_ALL_TV_SHOWS_BACK_TO_STAGED, STR_BACK ] ret = xbmcgui.Dialog().select( '{0} - {1}'.format(utils.ADDON_NAME, STR_MANAGED_TV_SHOWS), lines) if ret >= 0: if ret < len(managed_tvshows): for show_title in managed_tvshows: if managed_tvshows[ret] == show_title: self.view_seasons(show_title) break elif lines[ret] == STR_REMOVE_ALL_TV_SHOWS: self.remove_all() elif lines[ret] == STR_MOVE_ALL_TV_SHOWS_BACK_TO_STAGED: self.move_all_to_staged() elif lines[ret] == STR_BACK: return
def remove_all(self): ''' Remove all synced directories ''' STR_REMOVE_ALL_SYNCED_DIRS = utils.getlocalizedstring(32086) STR_ALL_SYNCED_DIRS_REMOVED = utils.getlocalizedstring(32087) STR_ARE_YOU_SURE = utils.getlocalizedstring(32088) if xbmcgui.Dialog().yesno( '{0} - {1}'.format(utils.ADDON_NAME, STR_REMOVE_ALL_SYNCED_DIRS), STR_ARE_YOU_SURE): self.dbh.remove_all_synced_dirs() utils.notification(STR_ALL_SYNCED_DIRS_REMOVED)
def remove_all(self): ''' Remove all staged tvshow items ''' STR_REMOVING_ALL_TV_SHOWS = utils.getlocalizedstring(32024) STR_ALL_TV_SHOW_REMOVED = utils.getlocalizedstring(32025) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_TV_SHOWS) self.dbh.remove_from(status='staged', mediatype='tvshow', show_title=None, directory=None) progress_dialog.close() utils.notification(STR_ALL_TV_SHOW_REMOVED)
def add_all(items): ''' Add all staged movies to library ''' STR_ADDING_ALL_MOVIES = utils.getlocalizedstring(32042) STR_ALL_MOVIES_ADDED = utils.getlocalizedstring(32043) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_ADDING_ALL_MOVIES) for index, item in enumerate(items): percent = 100 * index / len(items) progress_dialog.update(int(percent), item.movie_title) item.add_to_library() progress_dialog.close() utils.notification(STR_ALL_MOVIES_ADDED)
def remove_all(self): ''' Remove all staged movies ''' STR_REMOVING_ALL_MOVIES = utils.getlocalizedstring(32013) STR_ALL_MOVIES_REMOVED = utils.getlocalizedstring(32014) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_MOVIES) self.dbh.remove_from(status='staged', mediatype='movie', show_title=None, directory=None) progress_dialog.close() utils.notification(STR_ALL_MOVIES_REMOVED)
def generate_all_metadata(items): ''' Generate metadata items for all staged movies ''' STR_GENERATING_ALL_MOVIE_METADATA = utils.getlocalizedstring(32046) STR_ALL_MOVIE_METADTA_CREATED = utils.getlocalizedstring(32047) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_GENERATING_ALL_MOVIE_METADATA) for index, item in enumerate(items): percent = 100 * index / len(items) progress_dialog.update(int(percent), item.movie_title) item.create_metadata_item() progress_dialog.close() utils.notification(STR_ALL_MOVIE_METADTA_CREATED)
def remove_all(items): ''' Remove all managed movies from library ''' STR_REMOVING_ALL_MOVIES = utils.getlocalizedstring(32013) STR_ALL_MOVIES_REMOVED = utils.getlocalizedstring(32014) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_MOVIES) for index, item in enumerate(items): percent = 100 * index / len(items) progress_dialog.update(int(percent), item.movie_title) item.remove_from_library() item.delete() progress_dialog.close() utils.notification(STR_ALL_MOVIES_REMOVED)
def localize_type(self): ''' Localizes tags used for identifying mediatype ''' if not self._localized_type: if self['type'] == 'movie': # Movies self._localized_type = utils.getlocalizedstring(32109) elif self['type'] == 'tvshow': # TV Shows self._localized_type = utils.getlocalizedstring(32108) elif self['type'] == 'single-movie': # Single Movie self._localized_type = utils.getlocalizedstring(32116) elif self['type'] == 'single-tvshow': # Single TV Show self._localized_type = utils.getlocalizedstring(32115) else: self._localized_type = self['type'] return self._localized_type
def remove_all_episodes(self, show_title): ''' Remove all episodes from the specified show ''' STR_REMOVING_ALL_x_EPISODES = utils.getlocalizedstring( 32032) % show_title STR_ALL_x_EPISODES_REMOVED = utils.getlocalizedstring( 32033) % show_title progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_x_EPISODES) self.dbh.remove_from(status='staged', mediatype='tvshow', show_title=show_title, directory=None) progress_dialog.close() utils.notification(STR_ALL_x_EPISODES_REMOVED)
def localize_type(self): ''' Localize tags used for identifying mediatype ''' if not self._localized_type: if self['type'] == 'movie': # Movie return utils.getlocalizedstring(32102) elif self['type'] == 'tvshow': # TV Show return utils.getlocalizedstring(32101) elif self['type'] == 'keyword': # Keyword return utils.getlocalizedstring(32113) elif self['type'] == 'episode': # Episode return utils.getlocalizedstring(32114) else: self._localized_type = self['type'] return self._localized_type
def add_all_with_metadata(items): ''' Add all movies with nfo files to the library ''' # TODO: Remove code duplication with MovieItem.add_to_library_if_metadata STR_ADDING_ALL_MOVIES_WITH_METADATA = utils.getlocalizedstring(32044) STR_ALL_MOVIES_WITH_METADTA_ADDED = utils.getlocalizedstring(32045) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_ADDING_ALL_MOVIES_WITH_METADATA) for index, item in enumerate(items): percent = 100 * index / len(items) if os.path.exists(item.movie_nfo[0]): progress_dialog.update(int(percent), item.movie_title) item.add_to_library() progress_dialog.close() utils.notification(STR_ALL_MOVIES_WITH_METADTA_ADDED)
def options(self, item): ''' Provide options for a single synced directory in a dialog window ''' # TODO: Remove all from plugin # TODO: Rename label STR_REMOVE = utils.getlocalizedstring(32017) STR_SYNCED_DIR_OPTIONS = utils.getlocalizedstring(32085) STR_BACK = utils.getlocalizedstring(32011) lines = [STR_REMOVE, STR_BACK] ret = xbmcgui.Dialog().select( '{0} - {1} - {2}'.format(utils.ADDON_NAME, STR_SYNCED_DIR_OPTIONS, item['label']), lines) if ret >= 0: if lines[ret] == STR_REMOVE: self.dbh.remove_synced_dir(item['dir']) elif lines[ret] == STR_BACK: pass self.view()
def options(self, item): ''' Provide options for a single blocked item in a dialog window ''' STR_REMOVE = utils.getlocalizedstring(32017) STR_BACK = utils.getlocalizedstring(32011) STR_BLOCKED_ITEM_OPTIONS = utils.getlocalizedstring(32099) lines = [STR_REMOVE, STR_BACK] ret = xbmcgui.Dialog().select( '{0} - {1} - {2}'.format(utils.ADDON_NAME, STR_BLOCKED_ITEM_OPTIONS, item['value']), lines) if ret >= 0: if lines[ret] == STR_REMOVE: self.dbh.remove_blocked(item['value'], item['type']) return self.view() elif lines[ret] == STR_BACK: return self.view() return self.view()
def read_all_metadata(self): ''' Read metadata for all staged tvshow items ''' STR_READING_ALL_TV_SHOW_METADATA = utils.getlocalizedstring(32145) STR_ALL_TV_SHOW_METADATA_READ = utils.getlocalizedstring(32146) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_READING_ALL_TV_SHOW_METADATA) staged_tv_items = self.dbh.get_content_items(status='staged', mediatype='tvshow', order='Show_Title') for index, item in enumerate(staged_tv_items): percent = 100 * index / len(staged_tv_items) progress_dialog.update(percent, line2=item.show_title) xbmc.sleep(200) # item.read_metadata_item() progress_dialog.close() utils.notification(STR_ALL_TV_SHOW_METADATA_READ)
def generate_all_episodes_metadata(items): ''' Generate metadata items for all episodes in show ''' STR_GENERATING_ALL_x_METADATA = utils.getlocalizedstring(32077) STR_ALL_x_METADATA_CREATED = utils.getlocalizedstring(32078) show_title = items[0].show_title progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_GENERATING_ALL_x_METADATA % show_title) for index, item in enumerate(items): percent = 100 * index / len(items) progress_dialog.update(percent, line2=item.show_title, line3=item.episode_title_with_id) xbmc.sleep(200) item.create_metadata_item() progress_dialog.close() utils.notification(STR_ALL_x_METADATA_CREATED % show_title)
def remove_episodes(items): ''' Remove all episodes in specified show from library ''' STR_REMOVING_ALL_x_EPISODES = utils.getlocalizedstring(32032) STR_ALL_x_EPISODES_REMOVED = utils.getlocalizedstring(32033) show_title = items[0].show_title progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_x_EPISODES % show_title) for index, item in enumerate(items): percent = 100 * index / len(items) progress_dialog.update(percent, line2=item.show_title, line3=item.episode_title_with_id) item.remove_from_library() item.delete() progress_dialog.close() utils.notification(STR_ALL_x_EPISODES_REMOVED % show_title)
def add_all_shows(self): ''' Add all tvshow items to library ''' STR_ADDING_ALL_TV_SHOWS = utils.getlocalizedstring(32059) STR_ALL_TV_SHOWS_ADDED = utils.getlocalizedstring(32060) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_ADDING_ALL_TV_SHOWS) staged_tv_items = self.dbh.get_content_items(status='staged', mediatype='tvshow', order='Show_Title') for index, item in enumerate(staged_tv_items): percent = 100 * index / len(staged_tv_items) progress_dialog.update(percent, line2=item.show_title, line3=item.episode_title_with_id) xbmc.sleep(200) item.add_to_library() progress_dialog.close() utils.notification(STR_ALL_TV_SHOWS_ADDED)
def update_movies(self): ''' Update all synced movie directories ''' STR_FINDING_ITEMS_TO_REMOVE = utils.getlocalizedstring(32090) STR_FINDING_ITEMS_TO_ADD = utils.getlocalizedstring(32092) STR_i_TO_REMOVE_i_TO_STAGE_PROCEED = utils.getlocalizedstring(32093) STR_REMOVING_ITEMS = utils.getlocalizedstring(32094) STR_STAGING_ITEMS = utils.getlocalizedstring(32095) STR_ALL_ITEMS_UPTODATE = utils.getlocalizedstring(32121) STR_SUCCESS = utils.getlocalizedstring(32122) progressdialog = xbmcgui.DialogProgressBG() progressdialog.create(utils.ADDON_NAME) try: all_items = [] movie_dirs = self.dbh.get_synced_dirs(synced_type='movie') single_movie_dirs = self.dbh.get_synced_dirs( synced_type='single-movie') total_num_dirs = len(movie_dirs + single_movie_dirs) for index, synced_dir in enumerate(movie_dirs): progressdialog.update(percent=99 * index / total_num_dirs, message=synced_dir['label']) all_items += self.get_movies_in_directory(synced_dir['dir']) for index, synced_dir in enumerate(single_movie_dirs): progressdialog.update(percent=99 * (index + len(movie_dirs)) / total_num_dirs, message=synced_dir['label']) all_items.append({ 'file': synced_dir['dir'], 'label': synced_dir['label'], 'mediatype': 'movie' }) # Find managed paths not in dir_items, and prepare to remove progressdialog.update(percent=99, message=STR_FINDING_ITEMS_TO_REMOVE) all_paths = [x['file'] for x in all_items] paths_to_remove = self.find_paths_to_remove(all_paths, mediatype='movie') # Find dir_items not in managed_items or staged_items, and prepare to add progressdialog.update(percent=99, message=STR_FINDING_ITEMS_TO_ADD) items_to_stage = self.find_items_to_stage(all_items) # Prompt user to remove & stage if paths_to_remove or items_to_stage: if xbmcgui.Dialog().yesno( utils.ADDON_NAME, STR_i_TO_REMOVE_i_TO_STAGE_PROCEED % (len(paths_to_remove), len(items_to_stage))): if paths_to_remove: progressdialog.update(percent=99, message=STR_REMOVING_ITEMS) self.remove_paths(paths_to_remove) if items_to_stage: progressdialog.update(percent=99, message=STR_STAGING_ITEMS) self.stage_items(items_to_stage) # TODO: update/clean managed folder xbmcgui.Dialog().ok(utils.ADDON_NAME, STR_SUCCESS) else: xbmcgui.Dialog().ok(utils.ADDON_NAME, STR_ALL_ITEMS_UPTODATE) finally: progressdialog.close()
def remove_all(self): ''' Remove all managed tvshow items from library ''' STR_REMOVING_ALL_TV_SHOWS = utils.getlocalizedstring(32024) STR_ALL_TV_SHOWS_REMOVED = utils.getlocalizedstring(32025) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_TV_SHOWS) managed_tv_items = self.dbh.get_content_items(status='managed', mediatype='tvshow', order='Show_Title') for index, item in enumerate(managed_tv_items): percent = 100 * index / len(managed_tv_items) progress_dialog.update(percent, line2=item.show_title, line3=item.episode_title_with_id) item.remove_from_library() item.delete() progress_dialog.close() utils.notification(STR_ALL_TV_SHOWS_REMOVED)
def add_all_episodes(items): ''' Add all episodes from specified show to library ''' STR_ADDING_ALL_x_EPISODES = utils.getlocalizedstring(32071) STR_ALL_x_EPISODES_ADDED = utils.getlocalizedstring(32072) show_title = items[0].show_title progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_ADDING_ALL_x_EPISODES % show_title) for index, item in enumerate(items): percent = 100 * index / len(items) progress_dialog.update(percent, line2=item.show_title, line3=item.episode_title_with_id) xbmc.sleep(200) item.add_to_library() progress_dialog.close() utils.notification(STR_ALL_x_EPISODES_ADDED % show_title)
def move_episodes_to_staged(items): ''' Remove all managed episodes in specified show from library, and add them to staged ''' STR_MOVING_ALL_x_EPISODES_BACK_TO_STAGED = utils.getlocalizedstring( 32034) STR_ALL_x_EPISODES_MOVED_TO_STAGED = utils.getlocalizedstring(32035) show_title = items[0].show_title progress_dialog = xbmcgui.DialogProgress() progress_dialog.create( utils.ADDON_NAME, STR_MOVING_ALL_x_EPISODES_BACK_TO_STAGED % show_title) for index, item in enumerate(items): percent = 100 * index / len(items) progress_dialog.update(percent, line2=item.show_title, line3=item.episode_title_with_id) xbmc.sleep(200) item.remove_from_library() item.set_as_staged() progress_dialog.close() utils.notification(STR_ALL_x_EPISODES_MOVED_TO_STAGED % show_title)
def rename_episodes_using_metadata(items): ''' Rename all episodes in show using nfo files ''' STR_RENAMING_x_EPISODES_USING_METADATA = utils.getlocalizedstring( 32075) STR_x_EPISODES_RENAMED_USING_METADATA = utils.getlocalizedstring(32076) show_title = items[0].show_title progress_dialog = xbmcgui.DialogProgress() progress_dialog.create( utils.ADDON_NAME, STR_RENAMING_x_EPISODES_USING_METADATA % show_title) for index, item in enumerate(items): percent = 100 * index / len(items) progress_dialog.update(percent, line2=item.show_title, line3=item.episode_title_with_id) xbmc.sleep(200) # TODO: fix rename_using_metadata() current is not used # item.rename_using_metadata() progress_dialog.close() utils.notification(STR_x_EPISODES_RENAMED_USING_METADATA % show_title)
def view_episodes(self, show_title, season_number): ''' Displays all managed episodes in the specified show, which are selectable and lead to options. Also provides additional options at bottom of menu ''' STR_NO_MANAGED_x_EPISODES = utils.getlocalizedstring( 32028) % show_title STR_REMOVE_ALL_EPISODES = utils.getlocalizedstring(32029) STR_MOVE_ALL_EPISODES_BACK_TO_STAGED = utils.getlocalizedstring(32030) STR_BACK = utils.getlocalizedstring(32011) STR_MANAGED_x_EPISODES = utils.getlocalizedstring(32031) % show_title managed_episodes = self.dbh.get_content_items( status='managed', mediatype='tvshow', order='Show_Title', show_title=show_title, season_number=season_number) if not managed_episodes: xbmcgui.Dialog().ok(utils.ADDON_NAME, STR_NO_MANAGED_x_EPISODES) return self.view_shows() lines = [str(x) for x in managed_episodes] lines += [ STR_REMOVE_ALL_EPISODES, STR_MOVE_ALL_EPISODES_BACK_TO_STAGED, STR_BACK ] ret = xbmcgui.Dialog().select( '{0} - {1}'.format(utils.ADDON_NAME, STR_MANAGED_x_EPISODES), lines) if ret >= 0: if ret < len(managed_episodes): # managed item for i, item in enumerate(managed_episodes): if ret == i: return self.episode_options(item, season_number) elif lines[ret] == STR_REMOVE_ALL_EPISODES: self.remove_episodes(managed_episodes) return self.view_shows() elif lines[ret] == STR_MOVE_ALL_EPISODES_BACK_TO_STAGED: self.move_episodes_to_staged(managed_episodes) return self.view_shows() elif lines[ret] == STR_BACK: return self.view_seasons(show_title) return self.view_seasons(show_title)
def move_all_to_staged(items): ''' Remove all managed movies from library, and add them to staged ''' STR_MOVING_ALL_MOVIES_BACK_TO_STAGED = utils.getlocalizedstring(32015) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_MOVING_ALL_MOVIES_BACK_TO_STAGED) for index, item in enumerate(items): percent = 100 * index / len(items) progress_dialog.update(int(percent), item.movie_title) item.remove_from_library() item.set_as_staged() progress_dialog.close() utils.notification(STR_MOVING_ALL_MOVIES_BACK_TO_STAGED)
def move_all_to_staged(self): ''' Remove all managed tvshow items from library, and add them to staged ''' STR_MOVING_ALL_TV_SHOWS_BACK_TO_STAGED = utils.getlocalizedstring( 32026) STR_ALL_TV_SHOWS_MOVED_TO_STAGED = utils.getlocalizedstring(32027) progress_dialog = xbmcgui.DialogProgress() progress_dialog.create(utils.ADDON_NAME, STR_MOVING_ALL_TV_SHOWS_BACK_TO_STAGED) managed_tv_items = self.dbh.get_content_items(status='managed', mediatype='tvshow', order='Show_Title') for index, item in enumerate(managed_tv_items): percent = 100 * index / len(managed_tv_items) progress_dialog.update(percent, line2=item.show_title, line3=item.episode_title_with_id) xbmc.sleep(200) item.remove_from_library() item.set_as_staged() progress_dialog.close() utils.notification(STR_ALL_TV_SHOWS_MOVED_TO_STAGED)