package views
import (
"fmt"
"go.fifitido.net/ytdl-web/pkg/ytdl/metadata"
)
type DownloadsViewModel struct {
Url string
Meta *metadata.Metadata
}
templ videoFormatView(vm *DownloadsViewModel, vidIndex int, format metadata.Format, label string) {
{{ filename := fmt.Sprintf("%s-%s.%s", vm.Meta.ID, format.Resolution, format.Ext) }}
{{
thumbnail := video.Meta.Thumbnail
thumbnailAlt := video.Meta.ID
if video.Meta.Title != nil {
thumbnailAlt = *video.Meta.Title
}
}}
if thumbnail != nil {
}
for _, format := range video.Formats {
@videoFormatView(vm, index, format, format.Format)
}
if len(video.OtherFormats) > 0 {
{{ collapseId := fmt.Sprintf("collapse-%s-%d", vm.Meta.ID, index) }}
for _, format := range video.OtherFormats {
{{ label := fmt.Sprintf("ext: %s, resolution: %s, filesize: %d, note: %s", format.Ext, format.Resolution, format.Filesize, format.FormatNote) }}
@videoFormatView(vm, index, format, label)
}
}
}
css downloads() {
display: grid;
grid-template-columns: minmax(auto, max-content) auto;
gap: 1.5rem;
align-items: center;
}
css fullWidth() {
grid-column: span 2;
}
templ Downloads(vm *DownloadsViewModel) {
{{ videos := GetVideosFromMetadata(vm.Meta) }}
@Layout() {