def sync_mylist_to_library(): """ Perform a full sync of Netflix "My List" with the Kodi library by deleting everything that was previously exported """ common.info( 'Performing full sync of Netflix "My List" with the Kodi library') purge() nfo_settings = nfo.NFOSettings() nfo_settings.show_export_dialog() for videoid in api.mylist_items_switch_profiles(): execute_library_tasks(videoid, [export_item], common.get_local_string(30018), sync_mylist=False, nfo_settings=nfo_settings)
def _get_mylist_videoids(): """Get My List videoids of an chosen profile""" return api.mylist_items_switch_profiles()
def auto_update_library(sync_with_mylist, silent): """ Perform an auto update of the exported items to Kodi library, so check if there is new seasons/episodes. If sync_with_mylist is enabled the Kodi library will be also synchronized with the Netflix "My List". :param sync_with_mylist: True to enable sync with My List :param silent: don't display user interface while performing an operation :return: None """ if _is_auto_update_library_running(): return execute_lib_tasks_method = execute_library_tasks_silently if silent else execute_library_tasks common.info( 'Starting auto update library - check updates for tv shows (sync with My List is {})', sync_with_mylist) g.SHARED_DB.set_value('library_auto_update_is_running', True) g.SHARED_DB.set_value('library_auto_update_start_time', datetime.now()) try: videoids_to_update = [] # Get My List videoids of the chosen profile mylist_videoids = api.mylist_items_switch_profiles( ) if sync_with_mylist else [] # Get the list of the exported items to Kodi library exported_tvshows_videoids_values = g.SHARED_DB.get_tvshows_id_list() exported_movies_videoids_values = g.SHARED_DB.get_movies_id_list() if sync_with_mylist: # Check if tv shows have been removed from the My List for videoid_value in exported_tvshows_videoids_values: if any(videoid.value == unicode(videoid_value) for videoid in mylist_videoids): continue # The tv show no more exist in My List so remove it from library videoid = common.VideoId.from_path( [common.VideoId.SHOW, videoid_value]) execute_lib_tasks_method(videoid, [remove_item], sync_mylist=False) # Check if movies have been removed from the My List for videoid_value in exported_movies_videoids_values: if any(videoid.value == unicode(videoid_value) for videoid in mylist_videoids): continue # The movie no more exist in My List so remove it from library videoid = common.VideoId.from_path( [common.VideoId.MOVIE, videoid_value]) execute_lib_tasks_method(videoid, [remove_item], sync_mylist=False) # Add missing tv shows / movies of My List to library for videoid in mylist_videoids: if videoid.value not in exported_tvshows_videoids_values and \ videoid.value not in exported_movies_videoids_values: videoids_to_update.append(videoid) # Add the exported tv shows to be updated to the list.. tvshows_videoids_to_upd = [ common.VideoId.from_path([common.VideoId.SHOW, videoid_value]) for videoid_value in g.SHARED_DB.get_tvshows_id_list( VidLibProp['exclude_update'], False) ] # ..and avoids any duplication caused by possible unexpected errors videoids_to_update.extend( list(set(tvshows_videoids_to_upd) - set(videoids_to_update))) # Add missing tv shows/movies or update existing tv shows _update_library(videoids_to_update, exported_tvshows_videoids_values, silent) common.debug('Auto update of the library completed') g.SHARED_DB.set_value('library_auto_update_is_running', False) if not g.ADDON.getSettingBool('lib_auto_upd_disable_notification'): ui.show_notification(common.get_local_string(30220), time=5000) common.debug( 'Notify service to communicate to Kodi of update the library') common.send_signal(common.Signals.LIBRARY_UPDATE_REQUESTED) except Exception: # pylint: disable=broad-except import traceback common.error('An error has occurred in the library auto update') common.error(traceback.format_exc()) g.SHARED_DB.set_value('library_auto_update_is_running', False)