all repos — fixyoutube-go @ 7596dca40684a2cfd7176f6ec34e3360d020900a

A better way to embed YouTube videos everywhere (inspired by FixTweet).

fix launch.json, make cache errors not fatal
Bi-Rabittoh andronacomarco@gmail.com
Wed, 27 Dec 2023 14:48:29 +0100
commit

7596dca40684a2cfd7176f6ec34e3360d020900a

parent

afe8a66478bca7add263eeae037e6f830dff0fe6

2 files changed, 13 insertions(+), 9 deletions(-)

jump to
M .vscode/launch.json.vscode/launch.json

@@ -9,7 +9,7 @@ "name": "Launch Package",

"type": "go", "request": "launch", "mode": "auto", - "program": "." + "program": "${workspaceFolder}" } ] }
M invidious/cache.goinvidious/cache.go

@@ -27,7 +27,8 @@

func getDb(mode string) *sql.DB { db, err := sql.Open("sqlite3", dbConnectionString+mode) if err != nil { - log.Fatal("Error opening database") + log.Println("Could not open DB:", err) + return nil } db.SetMaxOpenConns(1) return db

@@ -50,13 +51,14 @@ defer db.Close()

stmt, err := db.Prepare(cacheVideoQuery) if err != nil { - log.Fatal(err) + log.Println("Could not cache video:", err) + return } defer stmt.Close() _, err = stmt.Exec(v.VideoId, v.Title, v.Description, v.Uploader, v.Duration, v.Height, v.Width, v.Url) if err != nil { - log.Printf("%q: %s\n", err, cacheVideoQuery) + log.Println("Could not cache video:", err) return } }

@@ -67,15 +69,16 @@ defer db.Close()

stmt, err := db.Prepare(getVideoQuery) if err != nil { - log.Fatal(err) + log.Println("Could not get video:", err) + return nil, err } defer stmt.Close() t := &Video{} err = stmt.QueryRow(videoId).Scan(&t.VideoId, &t.Title, &t.Description, &t.Uploader, &t.Duration, &t.Height, &t.Width, &t.Url, &t.Timestamp) if err != nil { - //log.Printf("%q: %s\n", err, getVideoQuery) - return &Video{}, err + log.Println("Could not get video:", err) + return nil, err } return t, nil }

@@ -86,13 +89,14 @@ defer db.Close()

stmt, err := db.Prepare(clearQuery) if err != nil { - log.Fatal(err) + log.Println("Could not clear DB:", err) + return } defer stmt.Close() _, err = stmt.Exec() if err != nil { - log.Printf("%q: %s\n", err, cacheVideoQuery) + log.Println("Could not clear DB:", err) return } }