|
@ -5,6 +5,7 @@ import ( |
|
|
"fmt" |
|
|
"fmt" |
|
|
"log" |
|
|
"log" |
|
|
"net/http" |
|
|
"net/http" |
|
|
|
|
|
"reflect" |
|
|
"ytdlp-viewer/DirectoryIndexers" |
|
|
"ytdlp-viewer/DirectoryIndexers" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@ -16,9 +17,9 @@ type ViewPageData struct { |
|
|
Metadata DirectoryIndexers.Metadata |
|
|
Metadata DirectoryIndexers.Metadata |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func View(writer http.ResponseWriter, request *http.Request, FL *DirectoryIndexers.FileList) { |
|
|
func View(writer http.ResponseWriter, request *http.Request, FL *DirectoryIndexers.FileList, path string) { |
|
|
FL.RLock() |
|
|
FL.Lock() |
|
|
defer FL.RUnlock() |
|
|
defer FL.Unlock() |
|
|
|
|
|
|
|
|
keys, ok := request.URL.Query()["id"] |
|
|
keys, ok := request.URL.Query()["id"] |
|
|
if !ok || len(keys[0]) < 1 { |
|
|
if !ok || len(keys[0]) < 1 { |
|
@ -30,6 +31,17 @@ func View(writer http.ResponseWriter, request *http.Request, FL *DirectoryIndexe |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// if no metadata loaded, do so
|
|
|
|
|
|
if reflect.ValueOf(FL.Files[keys[0]].Metadata).IsZero() { |
|
|
|
|
|
metadata, err := DirectoryIndexers.LoadMetadata(FL.Files[keys[0]], path) |
|
|
|
|
|
if err == nil { |
|
|
|
|
|
var fileObject DirectoryIndexers.VideoFile |
|
|
|
|
|
fileObject = FL.Files[keys[0]] |
|
|
|
|
|
fileObject.Metadata = metadata |
|
|
|
|
|
FL.Files[keys[0]] = fileObject |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
video := FL.Files[keys[0]] |
|
|
video := FL.Files[keys[0]] |
|
|
data := ViewPageData{ |
|
|
data := ViewPageData{ |
|
|
Title: video.Title, |
|
|
Title: video.Title, |
|
|