Check exported file exists

This commit is contained in:
JonnyWong16 2020-08-03 14:22:21 -07:00
parent de2e2ee962
commit b872cce2a4
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 9 additions and 3 deletions

View file

@ -90,10 +90,12 @@ export_table_options = {
"targets": [5], "targets": [5],
"data": "complete", "data": "complete",
"createdCell": function (td, cellData, rowData, row, col) { "createdCell": function (td, cellData, rowData, row, col) {
if (cellData === 1) { if (cellData === 0 ) {
$(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>');
} else if (cellData === 1 && rowData['exists']) {
$(td).html('<button class="btn btn-xs btn-dark btn-download" data-id="' + rowData['row_id'] + '"><i class="fa fa-file-download fa-fw"></i> Download</button>'); $(td).html('<button class="btn btn-xs btn-dark btn-download" data-id="' + rowData['row_id'] + '"><i class="fa fa-file-download fa-fw"></i> Download</button>');
} else { } else {
$(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>'); $(td).html('<button class="btn btn-xs btn-dark" data-id="' + rowData['row_id'] + '" disabled><i class="fa fa-question-circle fa-fw"></i> Not Found</button>');
} }
}, },
"width": "7%" "width": "7%"

View file

@ -904,6 +904,7 @@ def export(section_id=None, rating_key=None, file_format='json'):
section_id=section_id, section_id=section_id,
rating_key=rating_key, rating_key=rating_key,
media_type=media_type, media_type=media_type,
file_format=file_format,
filename=filename) filename=filename)
if not export_id: if not export_id:
logger.error("Tautulli Exporter :: Failed to export '%s'", filename) logger.error("Tautulli Exporter :: Failed to export '%s'", filename)
@ -999,6 +1000,8 @@ def get_export_datatable(section_id=None, rating_key=None, kwargs=None):
rows = [] rows = []
for item in result: for item in result:
media_type_title = item['media_type'].title() media_type_title = item['media_type'].title()
filepath = os.path.join(plexpy.CONFIG.EXPORT_DIR, item['filename'])
exists = helpers.cast_to_int(os.path.isfile(filepath))
row = {'row_id': item['row_id'], row = {'row_id': item['row_id'],
'timestamp': item['timestamp'], 'timestamp': item['timestamp'],
@ -1008,7 +1011,8 @@ def get_export_datatable(section_id=None, rating_key=None, kwargs=None):
'media_type_title': media_type_title, 'media_type_title': media_type_title,
'file_format': item['file_format'], 'file_format': item['file_format'],
'filename': item['filename'], 'filename': item['filename'],
'complete': item['complete'] 'complete': item['complete'],
'exists': exists
} }
rows.append(row) rows.append(row)