ytdl-web/app/views/download.html

63 lines
2.3 KiB
HTML

<div class="d-flex flex-column align-items-center">
<h1>Download Video</h1>
<h2 class="fs-4 text-muted text-center">{{.Meta.Title}}</h2>
<p style="font-size: 0.85rem">{{.Url}}</p>
<a href="{{.BasePath}}/" hx-get="{{.BasePath}}/" hx-trigger="click" hx-target="#main-content"
class="btn btn-secondary btn-sm mt-3" style="width: 30rem; max-width: 100%">
Download Another Video
</a>
</div>
{{$root := .}}
{{range $vidIndex, $video := .Videos}}
{{if not (eq $vidIndex 0)}}
<hr class="mt-5" />
{{end}}
<div class="d-flex flex-column flex-lg-row justify-content-center gap-5 mt-5">
<div class="d-flex justify-content-center">
<img src="{{$video.Meta.Thumbnail}}" alt="{{$video.Meta.Title}}" style="max-height: 25rem; max-width: 100%; margin: 0 auto" />
</div>
<div class="downloads flex-lg-grow-1">
{{range $index, $format := $video.Formats}}
{{template "format" (map "root" $root "format" $format "label" $format.Format "vidIndex" $vidIndex)}}
{{end}}
</div>
</div>
{{if gt (len $video.OtherFormats) 0}}
<div class="d-grid my-3">
<button
type="button"
class="btn btn-secondary"
data-bs-toggle="collapse"
data-bs-target="#collapse-{{$root.Meta.ID}}-{{$vidIndex}}"
aria-expanded="false"
aria-controls="collapse-{{$root.Meta.ID}}-{{$vidIndex}}"
>
See More Formats
</button>
</div>
<div id="collapse-{{$root.Meta.ID}}-{{$vidIndex}}" class="collapse">
<div class="downloads d-flex d-md-grid flex-column">
{{range $index, $format := $video.OtherFormats}}
{{$label := sprintf "ext: %s, resolution: %s, filesize: %s, note: %s" $format.Ext $format.Resolution
(filesize $format.Filesize) $format.FormatNote}}
{{template "format" (map "root" $root "format" $format "label" $label "vidIndex" $vidIndex)}}
{{end}}
</div>
</div>
{{end}}
{{end}}
{{define "format"}}
<div style="font-size: smaller">{{.label}}</div>
<div class="flex-grow-1 d-flex gap-3">
<a class="btn btn-primary flex-grow-1" download="{{.root.Meta.ID}}-{{.format.Resolution}}.{{.format.Ext}}" P
href="{{.format.Url}}">
Download (direct)
</a>
<a class="btn btn-primary flex-grow-1" download="{{.root.Meta.ID}}-{{.format.Resolution}}.{{.format.Ext}}"
href="{{.root.BasePath}}/download/proxy?url={{queryEscape .root.Url}}&format={{.format.FormatID}}&index={{.vidIndex}}">
Download (proxied)
</a>
</div>
{{end}}