mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Add Tautulli database import to the settings page
This commit is contained in:
parent
c1d98ab901
commit
52d38883dc
3 changed files with 77 additions and 21 deletions
|
@ -5,6 +5,7 @@
|
||||||
<h4 class="modal-title">Import ${app} Database</h4>
|
<h4 class="modal-title">Import ${app} Database</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body" id="modal-text">
|
<div class="modal-body" id="modal-text">
|
||||||
|
% if app in ('PlexWatch', 'Plexivity'):
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
<%
|
<%
|
||||||
v = ''
|
v = ''
|
||||||
|
@ -15,26 +16,54 @@
|
||||||
%>
|
%>
|
||||||
<strong>Please ensure your ${app} database is at version ${v} or higher.</strong>
|
<strong>Please ensure your ${app} database is at version ${v} or higher.</strong>
|
||||||
</p>
|
</p>
|
||||||
|
% endif
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="db_location">Database Location</label>
|
<label for="import_database_path">Database Location</label>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-8">
|
<div class="col-xs-12">
|
||||||
<input type="text" class="form-control" id="db_location" name="db_location" value="" required>
|
<input type="text" class="form-control" id="import_database_path" name="import_database_path" value="" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="help-block">Enter the path and file name for the ${app} database you wish to import.</p>
|
<p class="help-block">Enter the full path to the ${app} database you wish to import.</p>
|
||||||
</div>
|
</div>
|
||||||
|
% if app == 'Tautulli':
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="table_name">Table Name</label>
|
<label for="table_name">Import Method</label>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-4">
|
<div class="col-xs-4">
|
||||||
<select id="table_name" class="form-control" name="table_name">
|
<select class="form-control" id="import_method" name="import_method">
|
||||||
<option value="processed">processed</option>
|
<option value="merge">Merge</option>
|
||||||
<option value="grouped">grouped</option>
|
<option value="append">Append</option>
|
||||||
|
<option value="overwrite">Oerwrite</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="help-block">The table name from which you wish to import. Only import one of these, importing both will result in duplicated data.</p>
|
<p class="help-block">Select how you would like to import the Tautulli history.</p>
|
||||||
|
<ul class="help-block" style="padding-inline-start: 15px;">
|
||||||
|
<li><strong>Merge</strong> will only add missing history from the imported database into the current database.</li>
|
||||||
|
<li><strong>Append</strong> will add all history from the imported database into the current database.
|
||||||
|
<br>Note: History will be duplicated if it is present in both databases.</li>
|
||||||
|
<li><strong>Overwrite</strong> will replace all history in the current database with the imported database.</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="import_backup_db" id="import_backup_db" value="1" checked> Backup Database
|
||||||
|
</label>
|
||||||
|
<p class="help-block">Automatically create a backup of the current database before importing.</p>
|
||||||
|
</div>
|
||||||
|
% else:
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="import_table_name">Table Name</label>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-4">
|
||||||
|
<select class="form-control" id="import_table_name" name="import_table_name">
|
||||||
|
<option value="processed">Processed</option>
|
||||||
|
<option value="grouped">Grouped</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="help-block">Select the table name from which you wish to import. Only import one of these, importing both will result in duplicated data.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="import_ignore_interval">Ignore Interval</label>
|
<label for="import_ignore_interval">Ignore Interval</label>
|
||||||
|
@ -45,6 +74,7 @@
|
||||||
</div>
|
</div>
|
||||||
<p class="help-block">Enter the minimum duration (in seconds) an item must have been active for. Set to 0 to import all.</p>
|
<p class="help-block">Enter the minimum duration (in seconds) an item must have been active for. Set to 0 to import all.</p>
|
||||||
</div>
|
</div>
|
||||||
|
% endif
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<div>
|
<div>
|
||||||
|
@ -57,22 +87,26 @@
|
||||||
<script>
|
<script>
|
||||||
// Send database path to import script
|
// Send database path to import script
|
||||||
$("#import_db").click(function() {
|
$("#import_db").click(function() {
|
||||||
var database_path = $("#db_location").val();
|
var database_path = $("#import_database_path").val();
|
||||||
var table_name = $("#table_name").val();
|
var import_method = $("#import_method").val();
|
||||||
|
var import_backup_db = $("#import_backup_db").is(':checked');
|
||||||
|
var import_table_name = $("#import_table_name").val();
|
||||||
var import_ignore_interval = $("#import_ignore_interval").val();
|
var import_ignore_interval = $("#import_ignore_interval").val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'import_database',
|
url: 'import_database',
|
||||||
data: {
|
data: {
|
||||||
app: "${app}",
|
app: "${app}",
|
||||||
database_path: database_path,
|
database_path: database_path,
|
||||||
table_name: table_name,
|
method: import_method,
|
||||||
|
backup: import_backup_db,
|
||||||
|
table_name: import_table_name,
|
||||||
import_ignore_interval: import_ignore_interval
|
import_ignore_interval: import_ignore_interval
|
||||||
},
|
},
|
||||||
cache: false,
|
cache: false,
|
||||||
async: true,
|
async: true,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
$("#status-message").html(data);
|
$("#status-message").html(data);
|
||||||
$("#db_location").val('')
|
$("#import_database_path").val('')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1321,8 +1321,9 @@
|
||||||
<h3>Database Import</h3>
|
<h3>Database Import</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="help-block">Click a button below to import an existing database from another app.</p>
|
<p class="help-block">Click a button below to import an existing database from the selected app.</p>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
|
<button class="btn btn-form toggle-app-import-modal" type="button" data-target="#app-import-modal" data-toggle="modal" data-app="tautulli">Tautulli</button>
|
||||||
<button class="btn btn-form toggle-app-import-modal" type="button" data-target="#app-import-modal" data-toggle="modal" data-app="plexwatch">PlexWatch</button>
|
<button class="btn btn-form toggle-app-import-modal" type="button" data-target="#app-import-modal" data-toggle="modal" data-app="plexwatch">PlexWatch</button>
|
||||||
<button class="btn btn-form toggle-app-import-modal" type="button" data-target="#app-import-modal" data-toggle="modal" data-app="plexivity">Plexivity</button>
|
<button class="btn btn-form toggle-app-import-modal" type="button" data-target="#app-import-modal" data-toggle="modal" data-app="plexivity">Plexivity</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3740,17 +3740,23 @@ class WebInterface(object):
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@requireAuth(member_of("admin"))
|
@requireAuth(member_of("admin"))
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def import_database(self, app=None, database_path=None, table_name=None, import_ignore_interval=0, **kwargs):
|
def import_database(self, app=None, database_path=None, method=None, backup=True,
|
||||||
""" Import a PlexWatch or Plexivity database into Tautulli.
|
table_name=None, import_ignore_interval=0, **kwargs):
|
||||||
|
""" Import a Tautulli, PlexWatch, or Plexivity database into Tautulli.
|
||||||
|
|
||||||
```
|
```
|
||||||
Required parameters:
|
Required parameters:
|
||||||
app (str): "plexwatch" or "plexivity"
|
app (str): "tautulli" or "plexwatch" or "plexivity"
|
||||||
database_path (str): The full path to the plexwatch database file
|
database_path (str): The full path to the plexwatch database file
|
||||||
table_name (str): "processed" or "grouped"
|
method (str): For Tautulli only, "merge" or "overwrite"
|
||||||
|
table_name (str): For PlexWatch or Plexivity only, "processed" or "grouped"
|
||||||
|
|
||||||
|
|
||||||
Optional parameters:
|
Optional parameters:
|
||||||
import_ignore_interval (int): The minimum number of seconds for a stream to import
|
backup (bool): For Tautulli only, true or false whether to backup
|
||||||
|
the current database before importing
|
||||||
|
import_ignore_interval (int): For PlexWatch or Plexivity only, the minimum number
|
||||||
|
of seconds for a stream to import
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
None
|
None
|
||||||
|
@ -3759,7 +3765,18 @@ class WebInterface(object):
|
||||||
if not app:
|
if not app:
|
||||||
return 'No app specified for import'
|
return 'No app specified for import'
|
||||||
|
|
||||||
if app.lower() == 'plexwatch':
|
if app.lower() == 'tautulli':
|
||||||
|
db_check_msg = database.validate_database(database=database_path)
|
||||||
|
if db_check_msg == 'success':
|
||||||
|
threading.Thread(target=database.import_tautulli_db,
|
||||||
|
kwargs={'database': database_path,
|
||||||
|
'method': method,
|
||||||
|
'backup': helpers.bool_true(backup)}).start()
|
||||||
|
return 'Import has started. Check the Tautulli logs to monitor any problems.'
|
||||||
|
else:
|
||||||
|
return db_check_msg
|
||||||
|
|
||||||
|
elif app.lower() == 'plexwatch':
|
||||||
db_check_msg = plexwatch_import.validate_database(database=database_path,
|
db_check_msg = plexwatch_import.validate_database(database=database_path,
|
||||||
table_name=table_name)
|
table_name=table_name)
|
||||||
if db_check_msg == 'success':
|
if db_check_msg == 'success':
|
||||||
|
@ -3770,6 +3787,7 @@ class WebInterface(object):
|
||||||
return 'Import has started. Check the Tautulli logs to monitor any problems.'
|
return 'Import has started. Check the Tautulli logs to monitor any problems.'
|
||||||
else:
|
else:
|
||||||
return db_check_msg
|
return db_check_msg
|
||||||
|
|
||||||
elif app.lower() == 'plexivity':
|
elif app.lower() == 'plexivity':
|
||||||
db_check_msg = plexivity_import.validate_database(database=database_path,
|
db_check_msg = plexivity_import.validate_database(database=database_path,
|
||||||
table_name=table_name)
|
table_name=table_name)
|
||||||
|
@ -3781,13 +3799,16 @@ class WebInterface(object):
|
||||||
return 'Import has started. Check the Tautulli logs to monitor any problems.'
|
return 'Import has started. Check the Tautulli logs to monitor any problems.'
|
||||||
else:
|
else:
|
||||||
return db_check_msg
|
return db_check_msg
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return 'App not recognized for import'
|
return 'App not recognized for import'
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@requireAuth(member_of("admin"))
|
@requireAuth(member_of("admin"))
|
||||||
def import_database_tool(self, app=None, **kwargs):
|
def import_database_tool(self, app=None, **kwargs):
|
||||||
if app == 'plexwatch':
|
if app == 'tautulli':
|
||||||
|
return serve_template(templatename="app_import.html", title="Import Tautulli Database", app="Tautulli")
|
||||||
|
elif app == 'plexwatch':
|
||||||
return serve_template(templatename="app_import.html", title="Import PlexWatch Database", app="PlexWatch")
|
return serve_template(templatename="app_import.html", title="Import PlexWatch Database", app="PlexWatch")
|
||||||
elif app == 'plexivity':
|
elif app == 'plexivity':
|
||||||
return serve_template(templatename="app_import.html", title="Import Plexivity Database", app="Plexivity")
|
return serve_template(templatename="app_import.html", title="Import Plexivity Database", app="Plexivity")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue