def update_library(): now = time.time() is_syncing = plugin.getProperty('openmeta_syncing_library') is_updating = plugin.getProperty('openmeta_updating_library') if is_syncing and now - int(is_syncing) < 120: plugin.log.debug('Skipping library sync') else: if plugin.get_setting('library_sync_collection', bool) == True: try: plugin.setProperty('openmeta_syncing_library', int(now)) plugin.notify('OpenMeta', 'Syncing library', plugin.get_addon_icon(), 1000) lib_tvshows.sync_trakt_collection() lib_movies.sync_trakt_collection() finally: plugin.clearProperty('openmeta_syncing_library') if is_updating and now - int(is_updating) < 120: plugin.log.debug('Skipping library update') return else: if plugin.get_setting('library_updates', bool) == True: try: plugin.setProperty('openmeta_updating_library', int(now)) plugin.notify('OpenMeta', 'Updating library', plugin.get_addon_icon(), 1000) lib_tvshows.update_library() finally: plugin.clearProperty('openmeta_updating_library')
def update_library_from_settings(): now = time.time() if plugin.yesno('OpenMeta', 'Would you like to update the library now?'): try: plugin.setProperty('openmeta_updating_library', int(now)) plugin.notify('OpenMeta', 'Updating library', plugin.get_addon_icon(), 500) lib_tvshows.update_library() finally: plugin.clearProperty('openmeta_updating_library')
def tv_batch_add_to_library(): tv_batch_file = plugin.get_setting('tv_batch_add_file_path', unicode) if xbmcvfs.exists(tv_batch_file): try: f = open(xbmc.translatePath(tv_batch_file), 'r') r = f.read() f.close() ids = r.split('\n') except: plugin.notify('TV shows', 'not found', plugin.get_addon_icon(), 3000) library_folder = lib_tvshows.setup_library( plugin.get_setting('tv_library_folder', unicode)) ids_index = 0 for id in ids: if id == None or id == 'None': pass elif ',' in id: csvs = id.split(',') for csv in csvs: if csv == None or csv == 'None': pass elif str(csv).startswith('tt') and csv != '': tvdb_id = get_tvdb_id_from_imdb_id(csv) else: tvdb_id = csv show = TVDB[int(tvdb_id)] lib_tvshows.batch_add_tvshows_to_library( library_folder, show) else: if id == None or id == 'None' or id == '': pass elif str(id).startswith('tt'): tvdb_id = get_tvdb_id_from_imdb_id(id) else: tvdb_id = id try: show = TVDB[int(tvdb_id)] lib_tvshows.batch_add_tvshows_to_library( library_folder, show) except: # plugin.notify('Failed to add', '%s' % id, plugin.get_addon_icon(), 3000) xbmc.log('Failed to add' + '%s' % id, xbmc.LOGERROR) ids_index += 1 os.remove(xbmc.translatePath(tv_batch_file)) lib_tvshows.update_library() return True