make prefix configurable
This commit is contained in:
parent
bc5fa6c666
commit
74d23a5ad8
15
main.go
15
main.go
@ -26,6 +26,7 @@ const port = 8080
|
||||
var (
|
||||
ytdlCmd = []string{"youtube-dl"}
|
||||
videosPath = "./vids"
|
||||
videosUrl = "/vids"
|
||||
cachePath = "./cache"
|
||||
dbPath = "./db.json"
|
||||
approval bool = false
|
||||
@ -37,19 +38,27 @@ func parse() {
|
||||
ytcmd := ytdlCmd[0]
|
||||
flag.StringVar(&ytcmd, "ytdlcmd", ytcmd, "youtube-dl command seperated by spaces")
|
||||
flag.StringVar(&videosPath, "videospath", videosPath, "Path where videos are saved")
|
||||
flag.StringVar(&videosUrl, "videosurl", videosUrl, "Prefix of the url, i.e. https://domain.com/<this var>/<video filename>")
|
||||
flag.StringVar(&cachePath, "cachepath", cachePath, "Path where temporary download files are saved")
|
||||
flag.StringVar(&dbPath, "datapath", dbPath, "Path where downloaded info is saved")
|
||||
flag.StringVar(&dbPath, "dbpath", dbPath, "Path where downloaded info is saved")
|
||||
flag.BoolVar(&approval, "approval", approval, "Is approval required before allowing to watch")
|
||||
flag.Parse()
|
||||
if ytcmd != ytdlCmd[0] {
|
||||
ytdlCmd = strings.Fields(ytcmd)
|
||||
}
|
||||
os.MkdirAll(cachePath, 0755)
|
||||
os.MkdirAll(videosPath, 0755)
|
||||
os.MkdirAll(path.Dir(dbPath), 0755)
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("vim-go")
|
||||
parse()
|
||||
tmpl, err := template.New("page").Parse(page)
|
||||
tmpl := template.New("page")
|
||||
tmpl = tmpl.Funcs(map[string]any{
|
||||
"vids_prefix": func() string { return videosUrl },
|
||||
})
|
||||
tmpl, err := tmpl.Parse(page)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -83,7 +92,7 @@ func main() {
|
||||
if _, ok := seen[yturl]; !ok {
|
||||
seen[yturl] = struct{}{}
|
||||
id := d.Add(db.Item{
|
||||
Date: time.Now().String(),
|
||||
Date: time.Now().Format("2006-01-02 15:04"),
|
||||
URL: yturl,
|
||||
Title: "Loading",
|
||||
Approved: false,
|
||||
|
@ -28,7 +28,7 @@
|
||||
<td>{{ .Title }}</td>
|
||||
<td>
|
||||
{{ if eq .Status "Done" }}
|
||||
<a href="./vids/{{ .FileName }}">Watch</a>
|
||||
<a href="{{ vids_prefix }}/{{ .FileName }}">Watch</a>
|
||||
{{ else if eq .Status "InProgress" }}
|
||||
{{ .Progress }}
|
||||
{{ else }}
|
||||
|
Loading…
Reference in New Issue
Block a user