From b2a4f8898095c917c956751efd78ea5f9c953f5c Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 1 Nov 2021 16:42:07 +0700 Subject: [PATCH] add re_sync_thumbs to frontend --- docs/Settings.md | 3 +++ tubearchivist/home/src/thumbnails.py | 1 - tubearchivist/home/templates/home/settings.html | 7 +++++++ tubearchivist/home/views.py | 9 +++++++++ tubearchivist/static/script.js | 11 +++++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/Settings.md b/docs/Settings.md index f0f3008..7ed1780 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -51,6 +51,9 @@ Detect the YouTube ID from filename, this accepts the default yt-dlp naming conv - Maybe start with a subset of your files to import to make sure everything goes well... - Follow the logs to monitor progress and errors: `docker-compose logs -f tubearchivist`. +## Embed thumbnails into media file +This will write or overwrite all thumbnails in the media file using the downloaded thumbnail. This is only necessary if you didn't download the files with the option *Embed Thumbnail* enabled or want to make sure all media files get the newest thumbnail. Follow the docker-compose logs to monitor progress. + ## Backup Database This will backup your metadata into a zip file. The file will get stored at *cache/backup* and will contain the necessary files to restore the Elasticsearch index formatted **nd-json** files plus a complete export of the index in a set of conventional **json** files. diff --git a/tubearchivist/home/src/thumbnails.py b/tubearchivist/home/src/thumbnails.py index 99d6a5a..017b9a8 100644 --- a/tubearchivist/home/src/thumbnails.py +++ b/tubearchivist/home/src/thumbnails.py @@ -261,7 +261,6 @@ class ThumbManager: def write_all_thumbs(video_list): """rewrite the thumbnail into media file""" - print("start video thumbnail embed process") counter = 1 for video in video_list: # loop through all videos diff --git a/tubearchivist/home/templates/home/settings.html b/tubearchivist/home/templates/home/settings.html index 306424b..93d5289 100644 --- a/tubearchivist/home/templates/home/settings.html +++ b/tubearchivist/home/templates/home/settings.html @@ -111,6 +111,13 @@ +
+

Embed thumbnails into media file.

+

Set extracted youtube thumbnail as cover art of the media file.

+
+ +
+

Backup database

Export your database to a zip file stored at cache/backup.

diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index a2e6130..fe2e2db 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -34,6 +34,7 @@ from home.tasks import ( download_single, extrac_dl, kill_dl, + re_sync_thumbs, rescan_filesystem, run_backup, run_manual_import, @@ -689,6 +690,7 @@ class PostData: "forgetIgnore": self.forget_ignore, "addSingle": self.add_single, "manual-import": self.manual_import, + "re-embed": self.re_embed, "db-backup": self.db_backup, "db-restore": self.db_restore, "fs-rescan": self.fs_rescan, @@ -840,6 +842,13 @@ class PostData: run_manual_import.delay() return {"success": True} + @staticmethod + def re_embed(): + """rewrite thumbnails into media files""" + print("start video thumbnail embed process") + re_sync_thumbs.delay() + return {"success": True} + @staticmethod def db_backup(): """backup es to zip from settings page""" diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index 2752853..9185489 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -143,6 +143,17 @@ function manualImport() { toReplace.appendChild(message); } +function reEmbed() { + var payload = JSON.stringify({'re-embed': true}); + sendPost(payload); + // clear button + var message = document.createElement('p'); + message.innerText = 'processing thumbnails'; + var toReplace = document.getElementById('re-embed'); + toReplace.innerHTML = ''; + toReplace.appendChild(message); +} + function dbBackup() { var payload = JSON.stringify({'db-backup': true}); sendPost(payload)