From 911a0fb724e8812aac4923302f9b03e3d2dbbb6f Mon Sep 17 00:00:00 2001 From: lyx0 <66651385+lyx0@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:49:33 +0100 Subject: [PATCH] fix youtu.be download --- Makefile | 2 +- cmd/bot/download.go | 4 ++-- cmd/bot/main.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2eea27e..ce7e24f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ BINARY_NAME=Nourybot-Matrix.out dev: go build -o ${BINARY_NAME} cmd/bot/* - ./${BINARY_NAME} --database "./db/nourybot.db" + ./${BINARY_NAME} build: go build -o ${BINARY_NAME} cmd/bot/* diff --git a/cmd/bot/download.go b/cmd/bot/download.go index f3b3d32..ed312fd 100644 --- a/cmd/bot/download.go +++ b/cmd/bot/download.go @@ -48,7 +48,7 @@ func (app *application) YafDownload(evt *event.Event, link, uuid string) { // For some reason youtube links return webm as result.Info.Ext but // are in reality mp4. - if strings.HasPrefix(link, "https://www.youtube.com/") { + if strings.HasPrefix(link, "https://www.youtube.com/") || strings.HasPrefix(link, "https://youtu.be/") { rExt = "mp4" } else { rExt = result.Info.Ext @@ -88,7 +88,7 @@ func (app *application) GofileDownload(evt *event.Event, link string) { } // For some reason youtube links return webm as result.Info.Ext but // are in reality mp4. - if strings.HasPrefix(link, "https://www.youtube.com/") { + if strings.HasPrefix(link, "https://www.youtube.com/") || strings.HasPrefix(link, "https://youtu.be/") { rExt = "mp4" } else { rExt = result.Info.Ext diff --git a/cmd/bot/main.go b/cmd/bot/main.go index 8ab4e29..f741847 100644 --- a/cmd/bot/main.go +++ b/cmd/bot/main.go @@ -31,7 +31,6 @@ import ( ) var debug = flag.Bool("debug", false, "Enable debug logs") -var database = flag.String("database", "./db/nourybot.db", "SQLite database path") //var database = flag.String("database", "test.db", "SQLite database path") @@ -50,6 +49,7 @@ func main() { homeserver := os.Getenv("MATRIX_HOMESERVER") username := os.Getenv("MATRIX_USERNAME") password := os.Getenv("MATRIX_PASSWORD") + database := os.Getenv("SQLITE_DATABASE") client, err := mautrix.NewClient(homeserver, "", "") if err != nil { @@ -115,7 +115,7 @@ func main() { }) - cryptoHelper, err := cryptohelper.NewCryptoHelper(app.MatrixClient, []byte("meow"), *database) + cryptoHelper, err := cryptohelper.NewCryptoHelper(app.MatrixClient, []byte("meow"), database) if err != nil { panic(err) }