diff --git a/migrations/000011_alter_libraries_table_options.up.down.sql b/migrations/000011_alter_libraries_table_options.down.sql
similarity index 100%
rename from migrations/000011_alter_libraries_table_options.up.down.sql
rename to migrations/000011_alter_libraries_table_options.down.sql
diff --git a/migrations/000019_alter_libraries_table_command.down.sql b/migrations/000019_alter_libraries_table_command.down.sql
new file mode 100644
index 0000000..f88eea8
--- /dev/null
+++ b/migrations/000019_alter_libraries_table_command.down.sql
@@ -0,0 +1,3 @@
+ALTER TABLE libraries
+DROP IF EXISTS transcode_command,
+DROP IF EXISTS health_command;
diff --git a/migrations/000019_alter_libraries_table_command.up.sql b/migrations/000019_alter_libraries_table_command.up.sql
new file mode 100644
index 0000000..b813289
--- /dev/null
+++ b/migrations/000019_alter_libraries_table_command.up.sql
@@ -0,0 +1,3 @@
+ALTER TABLE libraries
+ADD transcode_command bigint REFERENCES ffmpeg_commands(id),
+ADD health_command bigint REFERENCES ffmpeg_commands(id);
diff --git a/server/libraries.go b/server/libraries.go
index 1daf58f..29912a7 100644
--- a/server/libraries.go
+++ b/server/libraries.go
@@ -5,17 +5,21 @@ import (
"fmt"
"log/slog"
"net/http"
+ "strconv"
"git.lastassault.de/speatzle/morffix/constants"
"github.com/jackc/pgx/v5"
)
type LibrariesData struct {
- Libraries []Library
+ Libraries []Library
+ FfmpegCommands []FfmpegCommand
}
type Library struct {
ID string `db:"id"`
+ HealthCommand *int `db:"health_command"`
+ TranscodeCommand *int `db:"transcode_command"`
Name string `db:"name"`
Path string `db:"path"`
Enable bool `db:"enable"`
@@ -40,7 +44,7 @@ func handleLibraries(w http.ResponseWriter, r *http.Request) {
}
}
- rows, err := db.Query(r.Context(), "SELECT id, name, path, enable, scan_new_queue_health, scan_changed_queue_health, scan_new_queue_transcode, scan_changed_queue_transcode, health_ok_queue_transcode, transcode_replace, transcode_path FROM libraries")
+ rows, err := db.Query(r.Context(), "SELECT * FROM libraries")
if err != nil {
slog.ErrorContext(r.Context(), "Query Libraries", "err", err)
http.Error(w, "Error Query Libraries: "+err.Error(), http.StatusInternalServerError)
@@ -54,6 +58,20 @@ func handleLibraries(w http.ResponseWriter, r *http.Request) {
}
data.Libraries = libraries
+ rows, err = db.Query(r.Context(), "SELECT id, name, data FROM ffmpeg_commands")
+ if err != nil {
+ slog.ErrorContext(r.Context(), "Query Ffmpeg Commands", "err", err)
+ http.Error(w, "Error Ffmpeg Commands: "+err.Error(), http.StatusInternalServerError)
+ return
+ }
+ ffmpegCommands, err := pgx.CollectRows[FfmpegCommand](rows, pgx.RowToStructByName[FfmpegCommand])
+ if err != nil {
+ slog.ErrorContext(r.Context(), "Collect Ffmpeg Commands", "err", err)
+ http.Error(w, "Error Collect Ffmpeg Commands: "+err.Error(), http.StatusInternalServerError)
+ return
+ }
+ data.FfmpegCommands = ffmpegCommands
+
buf := bytes.Buffer{}
err = templates.ExecuteTemplate(&buf, constants.LIBRARIES_TEMPLATE_NAME, data)
if err != nil {
@@ -84,9 +102,21 @@ func createLibrary(r *http.Request) error {
scan_changed_queue_transcode := r.FormValue("scan_changed_queue_transcode") == "on"
health_ok_queue_transcode := r.FormValue("health_ok_queue_transcode") == "on"
+ var health_command *int = nil
+ var transcode_command *int = nil
+
+ h, err := strconv.Atoi(r.FormValue("health_command"))
+ if err == nil {
+ health_command = &h
+ }
+ t, err := strconv.Atoi(r.FormValue("transcode_command"))
+ if err == nil {
+ transcode_command = &t
+ }
+
slog.Info("Got Library Create", "name", name, "path", path, "enable", enable)
- _, err = db.Exec(r.Context(), "INSERT INTO Libraries (name, path, enable, scan_new_queue_health, scan_changed_queue_health, scan_new_queue_transcode, scan_changed_queue_transcode, health_ok_queue_transcode, transcode_replace, transcode_path) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)", name, path, enable, scan_new_queue_health, scan_changed_queue_health, scan_new_queue_transcode, scan_changed_queue_transcode, health_ok_queue_transcode, transcode_replace, transcode_path)
+ _, err = db.Exec(r.Context(), "INSERT INTO Libraries (name, path, enable, scan_new_queue_health, scan_changed_queue_health, scan_new_queue_transcode, scan_changed_queue_transcode, health_ok_queue_transcode, transcode_replace, transcode_path, health_command, transcode_command) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12)", name, path, enable, scan_new_queue_health, scan_changed_queue_health, scan_new_queue_transcode, scan_changed_queue_transcode, health_ok_queue_transcode, transcode_replace, transcode_path, health_command, transcode_command)
if err != nil {
return fmt.Errorf("Inserting Library: %w", err)
}
diff --git a/tmpl/library.tmpl b/tmpl/library.tmpl
index 1ae79a0..64477ec 100644
--- a/tmpl/library.tmpl
+++ b/tmpl/library.tmpl
@@ -6,6 +6,18 @@
+
+
+
+