def start_clean_kodi_library(self):
     if not self.scan_in_progress and not self.clean_in_progress:
         LOG.debug('Start Kodi library clean')
         self.clean_in_progress = True  # Set as in progress (avoid wait "started" callback it comes late)
         self.clean_awaiting = False
         common.clean_library(False)
     else:
         self.clean_awaiting = True
Ejemplo n.º 2
0
 def _update_library(self, videoids_tasks, exp_tvshows_videoids_values,
                     show_prg_dialog, show_nfo_dialog, clear_on_cancel):
     # If set ask to user if want to export NFO files (override user custom NFO settings for videoids)
     nfo_settings_override = None
     if show_nfo_dialog:
         nfo_settings_override = nfo.NFOSettings()
         nfo_settings_override.show_export_dialog()
     # Get the exported tvshows, but to be excluded from the updates
     excluded_videoids_values = G.SHARED_DB.get_tvshows_id_list(
         VidLibProp['exclude_update'], True)
     # Start the update operations
     with ui.ProgressDialog(show_prg_dialog,
                            max_value=len(videoids_tasks)) as progress_bar:
         for videoid, task_handler in iteritems(videoids_tasks):
             # Check if current videoid is excluded from updates
             if int(videoid.value) in excluded_videoids_values:
                 continue
             # Get the NFO settings for the current videoid
             if not nfo_settings_override and int(
                     videoid.value) in exp_tvshows_videoids_values:
                 # User custom NFO setting
                 # it is possible that the user has chosen not to export NFO files for a specific tv show
                 nfo_export = G.SHARED_DB.get_tvshow_property(
                     videoid.value, VidLibProp['nfo_export'], False)
                 nfo_settings = nfo.NFOSettings(nfo_export)
             else:
                 nfo_settings = nfo_settings_override or nfo.NFOSettings()
             # Execute the task
             for index, total_tasks, title in self.execute_library_task(
                     videoid,
                     task_handler,
                     nfo_settings=nfo_settings,
                     notify_errors=show_prg_dialog):
                 label_partial_op = ' ({}/{})'.format(
                     index + 1, total_tasks) if total_tasks > 1 else ''
                 progress_bar.set_message(title + label_partial_op)
             if progress_bar.is_cancelled():
                 LOG.warn(
                     'Auto update of the Kodi library interrupted by User')
                 if clear_on_cancel:
                     self.clear_library(True)
                 return False
             if self.monitor.abortRequested():
                 LOG.warn(
                     'Auto update of the Kodi library interrupted by Kodi')
                 return False
             progress_bar.perform_step()
             progress_bar.set_wait_message()
             delay_anti_ban()
     common.clean_library(show_prg_dialog)
     return True
Ejemplo n.º 3
0
 def clear_library(self, show_prg_dialog=True):
     """
     Delete all exported items to the library
     :param show_prg_dialog: if True, will be show a progress dialog window
     """
     LOG.info('Start deleting exported library items')
     # This will clear all the add-on library data, to prevents possible inconsistencies when for some reason
     # such as improper use of the add-on, unexpected error or other has broken the library database data or files
     with ui.ProgressDialog(show_prg_dialog, common.get_local_string(30245), max_value=3) as progress_dlg:
         progress_dlg.perform_step()
         progress_dlg.set_wait_message()
         G.SHARED_DB.purge_library()
         for folder_name in [FOLDER_NAME_MOVIES, FOLDER_NAME_SHOWS]:
             progress_dlg.perform_step()
             progress_dlg.set_wait_message()
             section_root_dir = common.join_folders_paths(get_library_path(), folder_name)
             common.delete_folder_contents(section_root_dir, delete_subfolders=True)
     # Clean the Kodi library database
     common.clean_library(show_prg_dialog)