This commit is contained in:
parent
995fc6ceea
commit
35d76f4ead
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
*.db3
|
*.db3
|
||||||
|
*.db3-*
|
||||||
*.bak*
|
*.bak*
|
||||||
/downloads/
|
/downloads/
|
||||||
/temp/
|
/temp/
|
||||||
|
46
main.go
46
main.go
@ -1,25 +1,31 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"github.com/playwright-community/playwright-go"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
//var err error
|
var err error
|
||||||
//var onlyInstall = flag.Bool("install", false, "install the required browser and do nothing else")
|
var onlyInstall = flag.Bool("install", false, "install the required browser and do nothing else")
|
||||||
//flag.Parse()
|
flag.Parse()
|
||||||
//
|
|
||||||
//options := &playwright.RunOptions{
|
options := &playwright.RunOptions{
|
||||||
// Browsers: []string{"firefox"},
|
Browsers: []string{"firefox"},
|
||||||
//}
|
}
|
||||||
//err = playwright.Install(options)
|
err = playwright.Install(options)
|
||||||
//if err != nil {
|
if err != nil {
|
||||||
// log.Panicf("error installing playwright: %v", err)
|
log.Panicf("error installing playwright: %v", err)
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//if *onlyInstall {
|
if *onlyInstall {
|
||||||
// return
|
return
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//db := openDatabase()
|
db := openDatabase()
|
||||||
//defer db.Close()
|
defer db.MustClose()
|
||||||
//
|
|
||||||
//sleepTimeStr := os.Getenv("VIVAPLUS_SLEEPTIME")
|
//sleepTimeStr := os.Getenv("VIVAPLUS_SLEEPTIME")
|
||||||
//sleepTime := 15
|
//sleepTime := 15
|
||||||
//if sleepTimeStr != "" {
|
//if sleepTimeStr != "" {
|
||||||
@ -65,5 +71,5 @@ func main() {
|
|||||||
// log.Printf("Sleeping %d minutes until next run", sleepTime)
|
// log.Printf("Sleeping %d minutes until next run", sleepTime)
|
||||||
// time.Sleep(time.Duration(sleepTime) * time.Minute)
|
// time.Sleep(time.Duration(sleepTime) * time.Minute)
|
||||||
//}
|
//}
|
||||||
serveWebview()
|
serveWebview(db)
|
||||||
}
|
}
|
||||||
|
1
migrations/5_add_watch_state.sql
Normal file
1
migrations/5_add_watch_state.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE videos ADD COLUMN watch_state TEXT;
|
0
res/index.html
Normal file
0
res/index.html
Normal file
@ -3,4 +3,5 @@ package main
|
|||||||
type VideoInfoVM struct {
|
type VideoInfoVM struct {
|
||||||
Title string
|
Title string
|
||||||
Description string
|
Description string
|
||||||
|
Thumbnail string
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<div class="video-box">
|
<div class="video-box">
|
||||||
<h2>{{.Title}}</h2>
|
<h2>{{.Title}}</h2>
|
||||||
<div>{{.Description}}</div>
|
<div>{{.Description}}</div>
|
||||||
|
<img src="{{.Thumbnail}}" alt="Thumbnail" />
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
41
webview.go
41
webview.go
@ -1,28 +1,47 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gitea.seeseepuff.be/seeseemelk/mysqlite"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func serveWebview() {
|
func serveWebview(db *mysqlite.Db) {
|
||||||
addr := "localhost:8081"
|
addr := "localhost:8081"
|
||||||
|
|
||||||
log.Printf("Listening on %s", addr)
|
log.Printf("Listening on %s", addr)
|
||||||
http.Handle("/static/", http.StripPrefix("/static/", staticFileServer()))
|
http.Handle("/static/", http.StripPrefix("/static/", staticFileServer()))
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", serveIndex(db))
|
||||||
vm := VideoInfoVM{
|
http.HandleFunc("/video/", serveVideo(db))
|
||||||
Title: "Foo",
|
|
||||||
Description: "Lorem Ipsum sed dolor...",
|
|
||||||
}
|
|
||||||
err := renderTemplate(w, "index", vm)
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
err := http.ListenAndServe(addr, nil)
|
err := http.ListenAndServe(addr, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func serveIndex(db *mysqlite.Db) func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// Query the database for the oldest unwatched episode
|
||||||
|
var title, description, thumbnail string
|
||||||
|
err := db.Query(`SELECT title, description, thumbnail FROM videos WHERE (watch_state IS NULL OR watch_state != 'watched') ORDER BY upload_date, episode LIMIT 1`).ScanSingle(&title, &description, &thumbnail)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "No unwatched episodes found", http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
vm := VideoInfoVM{
|
||||||
|
Title: title,
|
||||||
|
Description: description,
|
||||||
|
Thumbnail: thumbnail,
|
||||||
|
}
|
||||||
|
err = renderTemplate(w, "index", vm)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func serveVideo(db *mysqlite.Db) func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user