mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -07:00
Add file_format to exports table
This commit is contained in:
parent
5468676811
commit
de2e2ee962
5 changed files with 38 additions and 18 deletions
|
@ -50,7 +50,7 @@ export_table_options = {
|
|||
$(td).html(cellData);
|
||||
}
|
||||
},
|
||||
"width": "10%",
|
||||
"width": "7%",
|
||||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
|
@ -61,22 +61,33 @@ export_table_options = {
|
|||
$(td).html(cellData);
|
||||
}
|
||||
},
|
||||
"width": "10%",
|
||||
"width": "7%",
|
||||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [3],
|
||||
"data": "file_format",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
if (cellData !== '') {
|
||||
$(td).html(cellData);
|
||||
}
|
||||
},
|
||||
"width": "7%",
|
||||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [4],
|
||||
"data": "filename",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
if (cellData !== '') {
|
||||
$(td).html(cellData);
|
||||
}
|
||||
},
|
||||
"width": "60%",
|
||||
"width": "55%",
|
||||
"className": "no-wrap"
|
||||
},
|
||||
{
|
||||
"targets": [4],
|
||||
"targets": [5],
|
||||
"data": "complete",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
if (cellData === 1) {
|
||||
|
@ -85,7 +96,7 @@ export_table_options = {
|
|||
$(td).html('<button class="btn btn-xs btn-dark" data-id="' + rowData['row_id'] + '" disabled><i class="fa fa-spinner fa-spin fa-fw"></i> Processing</button>');
|
||||
}
|
||||
},
|
||||
"width": "10%"
|
||||
"width": "7%"
|
||||
}
|
||||
],
|
||||
"drawCallback": function (settings) {
|
||||
|
@ -96,5 +107,10 @@ export_table_options = {
|
|||
"preDrawCallback": function(settings) {
|
||||
var msg = "<i class='fa fa-refresh fa-spin'></i> Fetching rows...";
|
||||
showMsg(msg, false, false, 0)
|
||||
},
|
||||
"rowCallback": function (row, rowData, rowIndex) {
|
||||
if (rowData['complete'] !== 1) {
|
||||
$(row).addClass('current-activity-row');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -336,6 +336,7 @@ DOCUMENTATION :: END
|
|||
<th align="left" id="timestamp">Exported At</th>
|
||||
<th align="left" id="media_type_title">Media Type</th>
|
||||
<th align="left" id="rating_key">Rating Key</th>
|
||||
<th align="left" id="file_format">Format</th>
|
||||
<th align="left" id="filename">Filename</th>
|
||||
<th align="left" id="complete">Download</th>
|
||||
</tr>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# This file is part of Tautulli.
|
||||
# This file is part of Tautulli.
|
||||
#
|
||||
# Tautulli is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -792,7 +792,7 @@ def dbcheck():
|
|||
c_db.execute(
|
||||
'CREATE TABLE IF NOT EXISTS exports (id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
||||
'timestamp INTEGER, section_id INTEGER, rating_key INTEGER, media_type TEXT, '
|
||||
'filename TEXT, complete INTEGER DEFAULT 0)'
|
||||
'file_format TEXT, filename TEXT, complete INTEGER DEFAULT 0)'
|
||||
)
|
||||
|
||||
# Upgrade sessions table from earlier versions
|
||||
|
|
|
@ -845,7 +845,7 @@ MEDIA_TYPES = {
|
|||
}
|
||||
|
||||
|
||||
def export(section_id=None, rating_key=None, output_format='json'):
|
||||
def export(section_id=None, rating_key=None, file_format='json'):
|
||||
timestamp = helpers.timestamp()
|
||||
|
||||
if not section_id and not rating_key:
|
||||
|
@ -857,8 +857,8 @@ def export(section_id=None, rating_key=None, output_format='json'):
|
|||
elif rating_key and not str(rating_key).isdigit():
|
||||
logger.error("Tautulli Exporter :: Export called with invalid rating_key '%s'.", rating_key)
|
||||
return
|
||||
elif output_format not in ('json', 'csv'):
|
||||
logger.error("Tautulli Exporter :: Export called but invalid output_format '%s' provided.", output_format)
|
||||
elif file_format not in ('json', 'csv'):
|
||||
logger.error("Tautulli Exporter :: Export called but invalid file_format '%s' provided.", file_format)
|
||||
return
|
||||
|
||||
plex = Plex(plexpy.CONFIG.PMS_URL, plexpy.CONFIG.PMS_TOKEN)
|
||||
|
@ -870,7 +870,7 @@ def export(section_id=None, rating_key=None, output_format='json'):
|
|||
media_type = library.type
|
||||
library_title = library.title
|
||||
filename = 'Library - {} [{}].{}.{}'.format(
|
||||
library_title, section_id, helpers.timestamp_to_YMDHMS(timestamp), output_format)
|
||||
library_title, section_id, helpers.timestamp_to_YMDHMS(timestamp), file_format)
|
||||
items = library.all()
|
||||
|
||||
elif rating_key:
|
||||
|
@ -889,7 +889,7 @@ def export(section_id=None, rating_key=None, output_format='json'):
|
|||
media_type = 'photo album'
|
||||
|
||||
filename = '{} - {} [{}].{}.{}'.format(
|
||||
media_type.title(), item_title, rating_key, helpers.timestamp_to_YMDHMS(timestamp), output_format)
|
||||
media_type.title(), item_title, rating_key, helpers.timestamp_to_YMDHMS(timestamp), file_format)
|
||||
|
||||
items = [item]
|
||||
|
||||
|
@ -915,11 +915,11 @@ def export(section_id=None, rating_key=None, output_format='json'):
|
|||
with ThreadPool(processes=4) as pool:
|
||||
result = pool.map(part, items)
|
||||
|
||||
if output_format == 'json':
|
||||
if file_format == 'json':
|
||||
with open(filepath, 'w', encoding='utf-8') as outfile:
|
||||
json.dump(result, outfile, indent=4, ensure_ascii=False, sort_keys=True)
|
||||
|
||||
elif output_format == 'csv':
|
||||
elif file_format == 'csv':
|
||||
flatten_result = helpers.flatten_dict(result)
|
||||
flatten_attrs = helpers.flatten_dict(attrs)
|
||||
with open(filepath, 'w', encoding='utf-8', newline='') as outfile:
|
||||
|
@ -931,13 +931,14 @@ def export(section_id=None, rating_key=None, output_format='json'):
|
|||
logger.info("Tautulli Exporter :: Successfully exported to '%s'", filepath)
|
||||
|
||||
|
||||
def set_export_state(timestamp, section_id, rating_key, media_type, filename):
|
||||
def set_export_state(timestamp, section_id, rating_key, media_type, file_format, filename):
|
||||
keys = {'timestamp': timestamp,
|
||||
'section_id': section_id,
|
||||
'rating_key': rating_key,
|
||||
'media_type': media_type}
|
||||
|
||||
values = {'filename': filename}
|
||||
values = {'file_format': file_format,
|
||||
'filename': filename}
|
||||
|
||||
db = database.MonitorDatabase()
|
||||
try:
|
||||
|
@ -976,6 +977,7 @@ def get_export_datatable(section_id=None, rating_key=None, kwargs=None):
|
|||
'exports.section_id',
|
||||
'exports.rating_key',
|
||||
'exports.media_type',
|
||||
'exports.file_format',
|
||||
'exports.filename',
|
||||
'exports.complete'
|
||||
]
|
||||
|
@ -1004,6 +1006,7 @@ def get_export_datatable(section_id=None, rating_key=None, kwargs=None):
|
|||
'rating_key': item['rating_key'],
|
||||
'media_type': item['media_type'],
|
||||
'media_type_title': media_type_title,
|
||||
'file_format': item['file_format'],
|
||||
'filename': item['filename'],
|
||||
'complete': item['complete']
|
||||
}
|
||||
|
|
|
@ -6480,10 +6480,10 @@ class WebInterface(object):
|
|||
@cherrypy.tools.json_out()
|
||||
@requireAuth(member_of("admin"))
|
||||
@addtoapi()
|
||||
def export_metadata(self, section_id=None, rating_key=None, output_format='json', **kwargs):
|
||||
def export_metadata(self, section_id=None, rating_key=None, file_format='json', **kwargs):
|
||||
threading.Thread(target=exporter.export,
|
||||
kwargs={'section_id': section_id,
|
||||
'rating_key': rating_key,
|
||||
'output_format': output_format}).start()
|
||||
'file_format': file_format}).start()
|
||||
return {'result': 'success',
|
||||
'message': 'Metadata export has started. Check the logs to monitor any problems.'}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue