all repos — fixyoutube-go @ d18ac234e2bf216e84f5b922b3abfe9f4ed0c951

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

better logging
Marco Andronaco andronacomarco@gmail.com
Fri, 12 Jan 2024 11:56:45 +0100
commit

d18ac234e2bf216e84f5b922b3abfe9f4ed0c951

parent

f33a2e3dc414259fae3738ea558b32ec1731ba99

2 files changed, 11 insertions(+), 6 deletions(-)

jump to
M invidious/cache.goinvidious/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.goinvidious/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 }