Add method to delete duplicate libraries
This commit is contained in:
@@ -879,3 +879,21 @@ class Libraries(object):
|
|||||||
return 'Unable to delete media info table cache, section_id not valid.'
|
return 'Unable to delete media info table cache, section_id not valid.'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn(u"PlexPy Libraries :: Unable to delete media info table cache: %s." % e)
|
logger.warn(u"PlexPy Libraries :: Unable to delete media info table cache: %s." % e)
|
||||||
|
|
||||||
|
def delete_duplicate_libraries(self):
|
||||||
|
from plexpy import plextv
|
||||||
|
|
||||||
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
|
# Refresh the PMS_URL to make sure the server_id is updated
|
||||||
|
plextv.get_real_pms_url()
|
||||||
|
|
||||||
|
server_id = plexpy.CONFIG.PMS_IDENTIFIER
|
||||||
|
|
||||||
|
try:
|
||||||
|
logger.debug(u"PlexPy Libraries :: Deleting libraries where server_id does not match %s." % server_id)
|
||||||
|
monitor_db.action('DELETE FROM library_sections WHERE server_id != ?', [server_id])
|
||||||
|
|
||||||
|
return 'Deleted duplicate libraries from the database.'
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn(u"PlexPy Libraries :: Unable to delete duplicate libraries: %s." % e)
|
@@ -492,7 +492,20 @@ class WebInterface(object):
|
|||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
return json.dumps({'message': 'no data received'})
|
return json.dumps({'message': 'no data received'})
|
||||||
else:
|
else:
|
||||||
return json.dumps({'message': 'Cannot refresh library while getting file sizes.'})
|
return json.dumps({'message': 'Cannot refresh library while getting file sizes.'})
|
||||||
|
|
||||||
|
@cherrypy.expose
|
||||||
|
def delete_duplicate_libraries(self):
|
||||||
|
library_data = libraries.Libraries()
|
||||||
|
|
||||||
|
result = library_data.delete_duplicate_libraries()
|
||||||
|
|
||||||
|
if result:
|
||||||
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
return json.dumps({'message': result})
|
||||||
|
else:
|
||||||
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
return json.dumps({'message': 'Unable to delete duplicate libraries from the database.'})
|
||||||
|
|
||||||
##### Users #####
|
##### Users #####
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user