✨ Add timelapse thumbnails (#4370)
* Generate thumbnails by taking the last frame * Allow thumbnails to be downloaded * Update thumbnail UI * Clean up code * Ensure thumbnails get deleted with the timelapse * Clean up code * Update CSS for timelpase thumbnails * Add timestamp and show formatted date * Update thumbnail size in UI
This commit is contained in:
1 parent
19072b4b33
commit
cac56cf040
8 files changed
+3104
-11
No files matched your search
@@ -146,6 +146,13 @@ def getTimelapseData():
|
||||
for f in files:
|
||||
output = dict(f)
|
||||
output["url"] = url_for("index") + "downloads/timelapse/" + urlquote(f["name"])
|
||||
if output["thumbnail"] is not None:
|
||||
output["thumbnail"] = (
|
||||
url_for("index") + "downloads/timelapse/" + urlquote(f["thumbnail"])
|
||||
)
|
||||
else:
|
||||
output.pop("thumbnail", None)
|
||||
|
||||
finished_list.append(output)
|
||||
|
||||
result = {
|
||||
@@ -175,6 +182,7 @@ def downloadTimelapse(filename):
|
||||
def deleteTimelapse(filename):
|
||||
timelapse_folder = settings().getBaseFolder("timelapse")
|
||||
full_path = os.path.realpath(os.path.join(timelapse_folder, filename))
|
||||
thumb_path = octoprint.timelapse.create_thumbnail_path(full_path)
|
||||
if (
|
||||
octoprint.timelapse.valid_timelapse(full_path)
|
||||
and full_path.startswith(timelapse_folder)
|
||||
@@ -189,6 +197,20 @@ def deleteTimelapse(filename):
|
||||
)
|
||||
abort(500, description="Unexpected error: {}".format(ex))
|
||||
|
||||
if (
|
||||
octoprint.timelapse.valid_timelapse_thumbnail(thumb_path)
|
||||
and thumb_path.startswith(timelapse_folder)
|
||||
and os.path.exists(thumb_path)
|
||||
and not util.is_hidden_path(thumb_path)
|
||||
):
|
||||
try:
|
||||
os.remove(thumb_path)
|
||||
except Exception as ex:
|
||||
# Do not treat this as an error, log and ignore
|
||||
logging.getLogger(__file__).warning(
|
||||
"Unable to delete thumbnail {} ({})".format(thumb_path, ex)
|
||||
)
|
||||
|
||||
return getTimelapseData()
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user