playlist link on status page

This commit is contained in:
Carl Pearson
2024-10-22 06:19:34 -06:00
parent f3496eefe3
commit b900507430
2 changed files with 19 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ import (
"ytdlp-site/database"
"ytdlp-site/ffmpeg"
"ytdlp-site/media"
"ytdlp-site/originals"
"ytdlp-site/ytdlp"
)
@@ -71,6 +72,16 @@ func getOriginalId(db *gorm.DB, filename string) (uint, error) {
return 0, fmt.Errorf("no media found")
}
// playlistId, ok
func getPlaylistId(db *gorm.DB, origId uint) (uint, bool) {
var orig originals.Original
result := db.Where("id = ?", origId).First(&orig)
if result.Error == nil && result.RowsAffected == 1 {
return orig.PlaylistID, orig.Playlist
}
return 0, false
}
func StatusGet(c echo.Context) error {
ytdlpStdout, _, err := ytdlp.Run("--version")
@@ -121,6 +132,10 @@ func StatusGet(c echo.Context) error {
originalId, err := getOriginalId(database.Get(), entry.Name)
if err == nil {
m["original_id"] = fmt.Sprintf("%d", originalId)
playlistId, ok := getPlaylistId(database.Get(), originalId)
if ok {
m["playlist_id"] = fmt.Sprintf("%d", playlistId)
}
}
}

View File

@@ -36,8 +36,10 @@
<div class="progress-wrapper">
<progress value="{{.value}}" max="{{.max}}">{{.value}}%</progress>
{{.name}} {{.size}} MiB
{{ if ne .original_id "" }}
<a href="/video/{{.original_id}}">{{.original_id}}</a>
{{ if ne .playlist_id "" }}
<a href="/p/{{.playlist_id}}">Playlist {{.playlist_id}}</a>
{{ else if ne .original_id "" }}
<a href="/video/{{.original_id}}">Video {{.original_id}}</a>
{{end}}
</div>
{{ end }}