better logging
Marco Andronaco andronacomarco@gmail.com
Fri, 12 Jan 2024 11:56:45 +0100
2 files changed,
11 insertions(+),
6 deletions(-)
M
invidious/cache.go
→
invidious/cache.go
@@ -35,37 +35,38 @@ return
} } -func CacheVideoDB(v Video) { +func CacheVideoDB(v Video) error { db := getDb("rw") defer db.Close() cacheVideo, err := db.Prepare(cacheVideoQuery) if err != nil { logger.Error("Could not cache video:", err) - return + return err } defer cacheVideo.Close() _, err = cacheVideo.Exec(v.VideoId, v.Title, v.Description, v.Uploader, v.Duration, v.Expire) if err != nil { logger.Error("Could not cache video:", err) - return + return err } for _, f := range v.Formats { cacheFormat, err := db.Prepare(cacheFormatQuery) if err != nil { logger.Error("Could not cache format:", err) - return + return err } defer cacheVideo.Close() _, err = cacheFormat.Exec(v.VideoId, f.Name, f.Height, f.Width, f.Url) if err != nil { logger.Error("Could not cache format:", err) - return + return err } } + return nil } func GetVideoDB(videoId string) (*Video, error) {
M
invidious/invidious.go
→
invidious/invidious.go
@@ -154,7 +154,11 @@ return c.GetVideo(videoId)
} logger.Info("Retrieved by API.") - CacheVideoDB(*video) + err = CacheVideoDB(*video) + if err != nil { + logger.Warn("Could not cache video id: ", videoId) + logger.Warn(err) + } return video, nil }