Step 5. A URL goes through the same pipeline as an upload — it just gains a download step and a source_url. - The host allowlist is checked on the parsed hostname before yt-dlp is invoked, so lookalikes and userinfo tricks are refused too - yt-dlp -J reads metadata synchronously with a 15s timeout; a timeout leaves the fields blank rather than failing the submission - Over-long tracks are refused from that metadata, before a byte is downloaded - Failed URL submissions offer Yritä uudelleen with the typed text intact; uploads cannot retry, so they offer re-upload Prefill takes track then title, and artist then creator then uploader, and leaves a field blank rather than inventing one. testdata/ytdlp-noose.json is a real dump of an ordinary upload, which has none of the music fields. Also fixes a URL-only submit being blocked by the file input's required attribute — HTML cannot express "one of these two", so the server says it. The image now takes yt-dlp from Alpine 3.24 instead of pip, which drops python3 and pip entirely; see decision 19.
64 lines
2.4 KiB
HTML
64 lines
2.4 KiB
HTML
{{define "submission-status"}}
|
|
<div class="status" {{if not .Done}}hx-get="/submit/{{.ID}}/status" hx-trigger="every 2s" hx-swap="outerHTML"{{end}}>
|
|
<p class="{{if .Failed}}error{{end}}"><strong>{{.Label}}</strong></p>
|
|
{{if .Failed}}
|
|
{{with .StatusMsg}}<p class="muted small">{{.}}</p>{{end}}
|
|
<div class="actions">
|
|
{{if .CanRetry}}
|
|
<form method="post" action="/submit/{{.ID}}/retry">
|
|
<button type="submit">Yritä uudelleen</button>
|
|
</form>
|
|
{{end}}
|
|
<form method="post" action="/submit/{{.ID}}/discard">
|
|
<button type="submit" class="danger">Poista lähetys</button>
|
|
</form>
|
|
</div>
|
|
{{if not .CanRetry}}<p class="muted small">Lataa tiedosto uudelleen, jos haluat yrittää toisen kerran.</p>{{end}}
|
|
{{else}}
|
|
<!-- Outside the form and attached to it with form=, so one button both submits the metadata
|
|
and publishes. Disabled until the audio has finished converting. -->
|
|
<button type="submit" form="meta" {{if not .Ready}}disabled{{end}}>Julkaise</button>
|
|
{{if not .Ready}}<p class="muted small">Julkaise aukeaa kun muunnos on valmis.</p>{{end}}
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|
|
|
|
{{define "saved"}}<span id="saved" class="saved">{{if .}}Tallennettu {{.}}{{end}}</span>{{end}}
|
|
|
|
{{define "content"}}
|
|
<h1>Lähetys</h1>
|
|
|
|
{{if .Data.Failed}}{{template "submission-status" .Data}}{{end}}
|
|
|
|
{{if not .Data.Failed}}
|
|
<form id="meta" method="post" action="/submit/{{.Data.ID}}/publish" class="stack"
|
|
hx-post="/submit/{{.Data.ID}}" hx-trigger="input changed delay:1.2s, change"
|
|
hx-target="#saved" hx-swap="outerHTML">
|
|
<label>Kappaleen nimi
|
|
<input name="title" value="{{.Data.Title}}" maxlength="100" required>
|
|
</label>
|
|
<label>Esittäjä
|
|
<input name="artist" value="{{.Data.Artist}}" maxlength="100" required>
|
|
</label>
|
|
<label>Genre
|
|
<select name="genre" required>
|
|
<option value="">— valitse —</option>
|
|
{{$current := .Data.Genre}}
|
|
{{range .Data.Genres}}
|
|
<option value="{{.Code}}" {{if eq .Code $current}}selected{{end}}>{{.Label}}</option>
|
|
{{end}}
|
|
</select>
|
|
</label>
|
|
<label>Esittely <span class="muted small">(vapaaehtoinen)</span>
|
|
<textarea name="description" rows="5" maxlength="2000">{{.Data.Description}}</textarea>
|
|
</label>
|
|
{{template "saved" ""}}
|
|
</form>
|
|
|
|
<p class="muted">Tiedot tallentuvat itsestään kirjoittaessasi. Nimi, esittäjä ja genre tarvitaan
|
|
ennen julkaisua.</p>
|
|
|
|
{{template "submission-status" .Data}}
|
|
{{end}}
|
|
{{end}}
|