Add Library and Transcode Options

This commit is contained in:
Samuel Lorch 2024-06-22 21:01:20 +02:00
parent cdc94d551d
commit 249a415cee
12 changed files with 134 additions and 20 deletions

View file

@ -17,13 +17,14 @@ type LibraryData struct {
}
type File struct {
ID int `db:"id"`
Path string `db:"path"`
Size int64 `db:"size"`
Status constants.FileStatus `db:"status"`
Health constants.FileHealth `db:"health"`
MD5 []byte `db:"md5"`
UpdatedAt time.Time `db:"updated_at"`
ID int `db:"id"`
Path string `db:"path"`
Size int64 `db:"size"`
Status constants.FileStatus `db:"status"`
Health constants.FileHealth `db:"health"`
Transcode constants.FileTranscode `db:"transcode"`
MD5 []byte `db:"md5"`
UpdatedAt time.Time `db:"updated_at"`
}
type FileDisplay struct {
@ -32,6 +33,7 @@ type FileDisplay struct {
Size int64
Status string
Health string
Transcode string
MD5 string
UpdatedAt string `db:"updated_at"`
}
@ -65,7 +67,7 @@ func handleLibrary(w http.ResponseWriter, r *http.Request) {
// TODO
}
rows, err := db.Query(r.Context(), "SELECT id, path, size, status, health, md5, updated_at FROM files where library_id = $1", id)
rows, err := db.Query(r.Context(), "SELECT id, path, size, status, health, transcode, md5, updated_at FROM files where library_id = $1", id)
if err != nil {
slog.ErrorContext(r.Context(), "Query Files", "err", err)
http.Error(w, "Error Query Files: "+err.Error(), http.StatusInternalServerError)
@ -85,6 +87,7 @@ func handleLibrary(w http.ResponseWriter, r *http.Request) {
Size: files[i].Size,
Status: files[i].Status.String(),
Health: files[i].Health.String(),
Transcode: files[i].Transcode.String(),
MD5: fmt.Sprintf("%x", files[i].MD5),
UpdatedAt: files[i].UpdatedAt.Format(time.DateTime),
})