Add optional title and description to video upload

This commit is contained in:
James Mills 2020-03-27 21:04:10 +10:00
parent 9af98b0382
commit 299df65290
No known key found for this signature in database
GPG key ID: AC4C014F1440EBD6
5 changed files with 37 additions and 14 deletions

View file

@ -209,6 +209,9 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
} }
defer file.Close() defer file.Close()
title := r.FormValue("video_title")
description := r.FormValue("video_description")
// TODO: Make collection user selectable from drop-down in Form // TODO: Make collection user selectable from drop-down in Form
// XXX: Assume we can put uploaded videos into the first collection (sorted) we find // XXX: Assume we can put uploaded videos into the first collection (sorted) we find
keys := make([]string, 0, len(a.Library.Paths)) keys := make([]string, 0, len(a.Library.Paths))
@ -266,6 +269,8 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
"-acodec", "aac", "-acodec", "aac",
"-strict", "-2", "-strict", "-2",
"-loglevel", "quiet", "-loglevel", "quiet",
"-metadata", fmt.Sprintf("title=%s", title),
"-metadata", fmt.Sprintf("comment=%s", description),
tf.Name(), tf.Name(),
); err != nil { ); err != nil {
err := fmt.Errorf("error transcoding video: %w", err) err := fmt.Errorf("error transcoding video: %w", err)
@ -413,8 +418,8 @@ func (a *App) importHandler(w http.ResponseWriter, r *http.Request) {
"-acodec", "aac", "-acodec", "aac",
"-strict", "-2", "-strict", "-2",
"-loglevel", "quiet", "-loglevel", "quiet",
"-metadata", fmt.Sprintf("title=\"%s\"", vid.Title), "-metadata", fmt.Sprintf("title=%s", vid.Title),
"-metadata", fmt.Sprintf("description=\"%s\"", vid.Description), "-metadata", fmt.Sprintf("comment=%s", vid.Description),
tf.Name(), tf.Name(),
); err != nil { ); err != nil {
err := fmt.Errorf("error transcoding video: %w", err) err := fmt.Errorf("error transcoding video: %w", err)

File diff suppressed because one or more lines are too long

View file

@ -99,7 +99,7 @@ main {
background: #282a2e; background: #282a2e;
box-shadow: 0 3px 7px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 3px 7px 0 rgba(0, 0, 0, 0.2);
overflow-x: hidden; overflow-x: hidden;
overflow-x: auto; overflow-y: auto;
} }
#playlist > a { #playlist > a {
@ -239,6 +239,18 @@ main {
.clear_both { .clear_both {
clear:both; clear:both;
} }
textarea {
border-radius:10px;
-moz-border-radius:10px;
-ms-border-radius:10px;
-o-border-radius:10px;
-webkit-border-radius:10px;
border:1px solid #ccc;
font-size:14pt;
padding:5px 10px;
}
input { input {
border-radius:10px; border-radius:10px;
-moz-border-radius:10px; -moz-border-radius:10px;

View file

@ -12,6 +12,8 @@ let file = null
const uploadForm = document.getElementById('upload-form') const uploadForm = document.getElementById('upload-form')
const videoInput = document.getElementById('video-input') const videoInput = document.getElementById('video-input')
const videoTitle = document.getElementById('video-title')
const videoDescription = document.getElementById('video-description')
const uploadMessageLabel = document.getElementById('upload-message') const uploadMessageLabel = document.getElementById('upload-message')
const uploadFileContainer = document.getElementById('upload-file') const uploadFileContainer = document.getElementById('upload-file')
const uploadFilenameLabel = document.getElementById('upload-filename') const uploadFilenameLabel = document.getElementById('upload-filename')
@ -161,6 +163,8 @@ const startUploading = () => {
const formData = new FormData() const formData = new FormData()
formData.append('video_file', file) formData.append('video_file', file)
formData.append('video_title', videoTitle.value)
formData.append('video_description', videoDescription.value)
const xhr = new XMLHttpRequest() const xhr = new XMLHttpRequest()
xhr.upload.addEventListener('progress', uploadProgress, false) xhr.upload.addEventListener('progress', uploadProgress, false)
@ -236,4 +240,4 @@ const uploadAbort = () => { // upload abort
setMessage('The upload has been canceled by the user or the browser dropped the connection.', true) setMessage('The upload has been canceled by the user or the browser dropped the connection.', true)
setProgress(0) setProgress(0)
setUploadState(false) setUploadState(false)
} }

View file

@ -9,6 +9,8 @@
<span>Click to browse or drop file here</span> <span>Click to browse or drop file here</span>
</div> </div>
<div class="upload-details"> <div class="upload-details">
<input id="video-title" type="text" placeholder="Optional title" />
<textarea id="video-description" rows="2" placeholder="Optional description"></textarea>
<div id="upload-file" class="upload-file"> <div id="upload-file" class="upload-file">
<span id="upload-filename"></span> <span id="upload-filename"></span>
<img width="20" src="/static/close-icon.png" onclick="removeFile(event)"/> <img width="20" src="/static/close-icon.png" onclick="removeFile(event)"/>