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

2
PageHandlers/View.go

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

2
PageHandlers/templates/search.html

@ -11,6 +11,6 @@
</form> </form>
{{range .Results}} {{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}}
{{end}} {{end}}

13
PageHandlers/templates/view.html

@ -9,7 +9,16 @@
{{define "body"}} {{define "body"}}
<div style="max-width: 1280px"> <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}}"> <source src="/videos/{{.Filename}}">
</video> </video>
<h1>{{.Title}}</h1> <h1>{{.Title}}</h1>
@ -19,7 +28,7 @@
<p style="float: right">{{ .Metadata.LikeCount }} likes | {{ .Metadata.DislikeCount }} dislikes</p> <p style="float: right">{{ .Metadata.LikeCount }} likes | {{ .Metadata.DislikeCount }} dislikes</p>
<p>{{ .Metadata.ViewCount }} views</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> <p>Uploaded at: <span id="uploadDate"></span></p>
<hr /> <hr />

Loading…
Cancel
Save