Browse Source

Add thumbnails

master
PrivateGER 3 years ago
parent
commit
b32c1a6867
Signed by: PrivateGER GPG Key ID: CAE625C962F94C67
  1. 7
      DirectoryIndexers/DirectoryIndexer.go
  2. 2
      PageHandlers/View.go
  3. 2
      PageHandlers/templates/search.html
  4. 13
      PageHandlers/templates/view.html

7
DirectoryIndexers/DirectoryIndexer.go

@ -19,6 +19,7 @@ type FileList struct {
type VideoFile struct {
Filename string
Thumbnail string
Extension string
Title string
Id string
@ -43,7 +44,9 @@ func Index(path string, results chan FileList, oldFileList *FileList) {
var wg sync.WaitGroup
bar := progressbar.NewOptions(len(fileList),
progressbar.OptionSetDescription("Scanning files + metadata..."))
progressbar.OptionSetDescription("Scanning files + metadata..."),
progressbar.OptionShowCount(),
progressbar.OptionShowIts())
for _, video := range fileList {
wg.Add(1)
@ -61,6 +64,7 @@ func Index(path string, results chan FileList, oldFileList *FileList) {
break
default:
wg.Done()
_ = bar.Add(1)
return
}
@ -80,6 +84,7 @@ func Index(path string, results chan FileList, oldFileList *FileList) {
videoObject := VideoFile{
Filename: video.Name(),
Thumbnail: strings.TrimSuffix(video.Name(), filepath.Ext(video.Name())) + ".webp",
Extension: extension,
Title: filenameToTitle(video.Name(), extension),
Id: id,

2
PageHandlers/View.go

@ -11,6 +11,7 @@ import (
type ViewPageData struct {
Title string
Filename string
Thumbnail string
Id string
Extension string
Metadata DirectoryIndexers.Metadata
@ -45,6 +46,7 @@ func View(writer http.ResponseWriter, request *http.Request, FL *DirectoryIndexe
data := ViewPageData{
Title: video.Title,
Filename: video.Filename,
Thumbnail: video.Thumbnail,
Id: video.Id,
Extension: video.Extension,
Metadata: video.Metadata,

2
PageHandlers/templates/search.html

@ -11,6 +11,6 @@
</form>
{{range .Results}}
<a href="/view?id={{.Id}}">{{.Id}} - {{.Title}}</a><br />
<a href="/view?id={{.Id}}">{{.Title}} {{ if .Metadata.Channel }} - {{ .Metadata.Channel }} {{end}} - {{.Id}}</a><br />
{{end}}
{{end}}

13
PageHandlers/templates/view.html

@ -9,7 +9,16 @@
{{define "body"}}
<div style="max-width: 1280px">
<video class="video-js vjs-big-play-centered centeredvideo" id="player" height="720" width="1280" controls autoplay data-setup="{}">
<video
class="video-js vjs-big-play-centered centeredvideo"
id="player"
height="720"
width="1280"
controls
autoplay
data-setup="{}"
poster="/videos/{{ .Thumbnail }}"
>
<source src="/videos/{{.Filename}}">
</video>
<h1>{{.Title}}</h1>
@ -19,7 +28,7 @@
<p style="float: right">{{ .Metadata.LikeCount }} likes | {{ .Metadata.DislikeCount }} dislikes</p>
<p>{{ .Metadata.ViewCount }} views</p>
<p>Uploaded by: <a href="{{ .Metadata.UploaderURL }}">{{ .Metadata.Channel }}</a></p>
<p>Uploaded by: <a href="/search?term={{ .Metadata.Channel }}">{{ .Metadata.Channel }}</a></p>
<p>Uploaded at: <span id="uploadDate"></span></p>
<hr />

Loading…
Cancel
Save