fix youtu.be download

This commit is contained in:
lyx0 2024-01-11 00:49:33 +01:00
parent f4b752cc04
commit 911a0fb724
3 changed files with 5 additions and 5 deletions

View file

@ -2,7 +2,7 @@ BINARY_NAME=Nourybot-Matrix.out
dev: dev:
go build -o ${BINARY_NAME} cmd/bot/* go build -o ${BINARY_NAME} cmd/bot/*
./${BINARY_NAME} --database "./db/nourybot.db" ./${BINARY_NAME}
build: build:
go build -o ${BINARY_NAME} cmd/bot/* go build -o ${BINARY_NAME} cmd/bot/*

View file

@ -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 // For some reason youtube links return webm as result.Info.Ext but
// are in reality mp4. // 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" rExt = "mp4"
} else { } else {
rExt = result.Info.Ext 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 // For some reason youtube links return webm as result.Info.Ext but
// are in reality mp4. // 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" rExt = "mp4"
} else { } else {
rExt = result.Info.Ext rExt = result.Info.Ext

View file

@ -31,7 +31,6 @@ import (
) )
var debug = flag.Bool("debug", false, "Enable debug logs") 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") //var database = flag.String("database", "test.db", "SQLite database path")
@ -50,6 +49,7 @@ func main() {
homeserver := os.Getenv("MATRIX_HOMESERVER") homeserver := os.Getenv("MATRIX_HOMESERVER")
username := os.Getenv("MATRIX_USERNAME") username := os.Getenv("MATRIX_USERNAME")
password := os.Getenv("MATRIX_PASSWORD") password := os.Getenv("MATRIX_PASSWORD")
database := os.Getenv("SQLITE_DATABASE")
client, err := mautrix.NewClient(homeserver, "", "") client, err := mautrix.NewClient(homeserver, "", "")
if err != nil { 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 { if err != nil {
panic(err) panic(err)
} }