|
|
@ -6,6 +6,8 @@ import ( |
|
|
|
"fmt" |
|
|
|
"net/http" |
|
|
|
"os" |
|
|
|
"strconv" |
|
|
|
"sync" |
|
|
|
"time" |
|
|
|
"ytdlp-viewer/DirectoryIndexers" |
|
|
|
"ytdlp-viewer/PageHandlers" |
|
|
@ -14,10 +16,14 @@ import ( |
|
|
|
func main() { |
|
|
|
var path string |
|
|
|
flag.StringVar(&path, "path", "./", "the full path to the ytdlp archive (with a / suffix)") |
|
|
|
var port int |
|
|
|
flag.IntVar(&port, "port", 8000, "the port for the web panel to listen on") |
|
|
|
|
|
|
|
flag.Parse() |
|
|
|
|
|
|
|
var FL DirectoryIndexers.FileList |
|
|
|
FL.RWMutex = &sync.RWMutex{} |
|
|
|
|
|
|
|
go func() { |
|
|
|
for { |
|
|
|
resultChannel := make(chan DirectoryIndexers.FileList) |
|
|
@ -25,7 +31,11 @@ func main() { |
|
|
|
fmt.Println("Starting scanner at", path) |
|
|
|
go DirectoryIndexers.Index(path, resultChannel) |
|
|
|
|
|
|
|
FL = <-resultChannel |
|
|
|
refreshedFL := <-resultChannel |
|
|
|
FL.Lock() |
|
|
|
FL.Files = refreshedFL.Files |
|
|
|
FL.Unlock() |
|
|
|
|
|
|
|
time.Sleep(60 * time.Second) |
|
|
|
} |
|
|
|
}() |
|
|
@ -44,7 +54,7 @@ func main() { |
|
|
|
}) |
|
|
|
http.Handle("/videos/", http.StripPrefix("/videos/", http.FileServer(http.Dir(path)))) |
|
|
|
|
|
|
|
err := http.ListenAndServe(":8000", nil) |
|
|
|
err := http.ListenAndServe(":" + strconv.Itoa(port), nil) |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err) |
|
|
|
os.Exit(1) |
|
|
|