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 videoids_tasks.items():
             # 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()
     return True
 def import_library(self, path):
     """
     Imports an already existing exported STRM library into the add-on library database,
     allows you to restore an existing library, by avoiding to recreate it from scratch.
     This operations also update the missing tv shows seasons and episodes, and automatically
     converts old STRM format type from add-on version 0.13.x or before 1.7.0 to new format.
     """
     # If set ask to user if want to export NFO files
     nfo_settings = nfo.NFOSettings()
     nfo_settings.show_export_dialog()
     LOG.info('Start importing Kodi library')
     remove_folders = []  # List of failed imports paths to be optionally removed
     remove_titles = []  # List of failed imports titles to be optionally removed
     # Start importing STRM files
     folders = get_library_subfolders(FOLDER_NAME_MOVIES, path) + get_library_subfolders(FOLDER_NAME_SHOWS, path)
     with ui.ProgressDialog(True, max_value=len(folders)) as progress_bar:
         for folder_path in folders:
             folder_name = os.path.basename(G.py2_decode(xbmc.translatePath(folder_path)))
             progress_bar.set_message(folder_name)
             try:
                 videoid = self.import_videoid_from_existing_strm(folder_path, folder_name)
                 if videoid is None:
                     # Failed to import, add folder to remove list
                     remove_folders.append(folder_path)
                     remove_titles.append(folder_name)
                     continue
                 # Successfully imported, Execute the task
                 for index, total_tasks, title in self.execute_library_task(videoid,
                                                                            self.export_item,
                                                                            nfo_settings=nfo_settings,
                                                                            notify_errors=True):
                     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('Import library interrupted by User')
                     return
                 if self.monitor.abortRequested():
                     LOG.warn('Import library interrupted by Kodi')
                     return
             except ImportWarning:
                 # Ignore it, something was wrong in STRM file (see _import_videoid in library_jobs.py)
                 pass
             progress_bar.perform_step()
             progress_bar.set_wait_message()
             delay_anti_ban()
     ret = self._import_library_remove(remove_titles, remove_folders)
     request_kodi_library_update(scan=True, clean=ret)