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 (
|
var (
|
||||||
ytdlCmd = []string{"youtube-dl"}
|
ytdlCmd = []string{"youtube-dl"}
|
||||||
videosPath = "./vids"
|
videosPath = "./vids"
|
||||||
|
videosUrl = "/vids"
|
||||||
cachePath = "./cache"
|
cachePath = "./cache"
|
||||||
dbPath = "./db.json"
|
dbPath = "./db.json"
|
||||||
approval bool = false
|
approval bool = false
|
||||||
@ -37,19 +38,27 @@ func parse() {
|
|||||||
ytcmd := ytdlCmd[0]
|
ytcmd := ytdlCmd[0]
|
||||||
flag.StringVar(&ytcmd, "ytdlcmd", ytcmd, "youtube-dl command seperated by spaces")
|
flag.StringVar(&ytcmd, "ytdlcmd", ytcmd, "youtube-dl command seperated by spaces")
|
||||||
flag.StringVar(&videosPath, "videospath", videosPath, "Path where videos are saved")
|
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(&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.BoolVar(&approval, "approval", approval, "Is approval required before allowing to watch")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if ytcmd != ytdlCmd[0] {
|
if ytcmd != ytdlCmd[0] {
|
||||||
ytdlCmd = strings.Fields(ytcmd)
|
ytdlCmd = strings.Fields(ytcmd)
|
||||||
}
|
}
|
||||||
|
os.MkdirAll(cachePath, 0755)
|
||||||
|
os.MkdirAll(videosPath, 0755)
|
||||||
|
os.MkdirAll(path.Dir(dbPath), 0755)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Println("vim-go")
|
fmt.Println("vim-go")
|
||||||
parse()
|
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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -83,7 +92,7 @@ func main() {
|
|||||||
if _, ok := seen[yturl]; !ok {
|
if _, ok := seen[yturl]; !ok {
|
||||||
seen[yturl] = struct{}{}
|
seen[yturl] = struct{}{}
|
||||||
id := d.Add(db.Item{
|
id := d.Add(db.Item{
|
||||||
Date: time.Now().String(),
|
Date: time.Now().Format("2006-01-02 15:04"),
|
||||||
URL: yturl,
|
URL: yturl,
|
||||||
Title: "Loading",
|
Title: "Loading",
|
||||||
Approved: false,
|
Approved: false,
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<td>{{ .Title }}</td>
|
<td>{{ .Title }}</td>
|
||||||
<td>
|
<td>
|
||||||
{{ if eq .Status "Done" }}
|
{{ if eq .Status "Done" }}
|
||||||
<a href="./vids/{{ .FileName }}">Watch</a>
|
<a href="{{ vids_prefix }}/{{ .FileName }}">Watch</a>
|
||||||
{{ else if eq .Status "InProgress" }}
|
{{ else if eq .Status "InProgress" }}
|
||||||
{{ .Progress }}
|
{{ .Progress }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
Loading…
Reference in New Issue
Block a user