Update library_id from top level info page

* Calls update first time loading the page
This commit is contained in:
Jonathan Wong 2015-10-19 21:18:18 -07:00
commit fc43f4773a
4 changed files with 37 additions and 10 deletions

View file

@ -502,6 +502,24 @@ DOCUMENTATION :: END
'library_id': "${data['library_id']}" };
}
}
if ("${config['update_library_ids']}" == "1") {
$('#history_table').before('<div id="update_mssage" style="text-align: center"> \
<i class="fa fa-refresh fa-spin"></i> Updating library ids in the database. This could take a few minutes depending on the size of your database. \
<br /> \
The history table will refresh automatically when complete. Please wait... \
</div>')
$.ajax({
url: 'update_library_ids',
type: 'post',
cache: false,
async: true,
data: { },
complete: function (xhr, status) {
$('#update_mssage').remove();
history_table.draw();
}
});
}
}
</script>
% elif data['type'] == 'show' or data['type'] == 'artist':

View file

@ -609,15 +609,6 @@ def dbcheck():
c_db.execute(
'ALTER TABLE session_history_metadata ADD COLUMN library_title TEXT'
)
logger.debug(u"Updating library_id's in database. Please wait...")
from plexpy import datafactory
data_factory = datafactory.DataFactory()
result = data_factory.update_library_ids()
if result:
logger.debug(u"Updated all library_id's in database.")
else:
logger.debug(u"Unable to update library_id's in database.")
# Upgrade users table from earlier versions
try:

View file

@ -210,6 +210,7 @@ _CONFIG_DEFINITIONS = {
'TWITTER_ON_BUFFER': (int, 'Twitter', 0),
'TWITTER_ON_WATCHED': (int, 'Twitter', 0),
'UPDATE_DB_INTERVAL': (int, 'General', 24),
'UPDATE_LIBRARY_IDS': (int, 'General', 1),
'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1),
'VIDEO_LOGGING_ENABLE': (int, 'Monitoring', 1),
'XBMC_ENABLED': (int, 'XBMC', 0),

View file

@ -774,7 +774,8 @@ class WebInterface(object):
query = None
config = {
"pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER
"pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER,
"update_library_ids": plexpy.CONFIG.UPDATE_LIBRARY_IDS
}
if source == 'history':
@ -1471,3 +1472,19 @@ class WebInterface(object):
if servers:
cherrypy.response.headers['Content-type'] = 'application/json'
return servers
@cherrypy.expose
def update_library_ids(self, **kwargs):
logger.debug(u"Updating library_id's in database.")
data_factory = datafactory.DataFactory()
result = data_factory.update_library_ids()
if result:
plexpy.CONFIG.UPDATE_LIBRARY_IDS = 0
plexpy.CONFIG.write()
logger.debug(u"Updated all library_id's in database.")
return "Library ids updated."
else:
logger.debug(u"Unable to update library_id's in database.")
return "Unable to update library ids in database."