mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
Compare commits
2 commits
343c8a1a68
...
2802c4e07a
Author | SHA1 | Date | |
---|---|---|---|
2802c4e07a | |||
241d227bff |
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gempir/go-twitch-irc/v4"
|
"github.com/gempir/go-twitch-irc/v4"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
@ -47,7 +48,16 @@ func (app *application) ConvertAndSave(fName, link string, msg twitch.PrivateMes
|
||||||
app.Send(msg.Channel, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
app.Send(msg.Channel, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rExt := result.Info.Ext
|
|
||||||
|
var rExt 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/") || strings.HasPrefix(link, "https://youtu.be/") {
|
||||||
|
rExt = "mp4"
|
||||||
|
} else {
|
||||||
|
rExt = result.Info.Ext
|
||||||
|
}
|
||||||
|
|
||||||
downloadResult, err := result.Download(context.Background(), "best")
|
downloadResult, err := result.Download(context.Background(), "best")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
|
@ -103,7 +113,16 @@ func (app *application) ConvertToMP4(link string, msg twitch.PrivateMessage) {
|
||||||
app.Send(msg.Channel, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
app.Send(msg.Channel, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rExt := result.Info.Ext
|
|
||||||
|
// For some reason youtube links return webm as result.Info.Ext but
|
||||||
|
// are in reality mp4.
|
||||||
|
var rExt string
|
||||||
|
if strings.HasPrefix(link, "https://www.youtube.com/") || strings.HasPrefix(link, "https://youtu.be/") {
|
||||||
|
rExt = "mp4"
|
||||||
|
} else {
|
||||||
|
rExt = result.Info.Ext
|
||||||
|
}
|
||||||
|
|
||||||
downloadResult, err := result.Download(context.Background(), "best")
|
downloadResult, err := result.Download(context.Background(), "best")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
|
@ -156,7 +175,16 @@ func (app *application) YafDownload(target, link, identifier string, msg twitch.
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rExt := result.Info.Ext
|
|
||||||
|
// For some reason youtube links return webm as result.Info.Ext but
|
||||||
|
// are in reality mp4.
|
||||||
|
var rExt string
|
||||||
|
if strings.HasPrefix(link, "https://www.youtube.com/") || strings.HasPrefix(link, "https://youtu.be/") {
|
||||||
|
rExt = "mp4"
|
||||||
|
} else {
|
||||||
|
rExt = result.Info.Ext
|
||||||
|
}
|
||||||
|
|
||||||
downloadResult, err := result.Download(context.Background(), "best")
|
downloadResult, err := result.Download(context.Background(), "best")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
|
@ -200,7 +228,16 @@ func (app *application) KappaDownload(target, link, identifier string, msg twitc
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rExt := result.Info.Ext
|
|
||||||
|
// For some reason youtube links return webm as result.Info.Ext but
|
||||||
|
// are in reality mp4.
|
||||||
|
var rExt string
|
||||||
|
if strings.HasPrefix(link, "https://www.youtube.com/") || strings.HasPrefix(link, "https://youtu.be/") {
|
||||||
|
rExt = "mp4"
|
||||||
|
} else {
|
||||||
|
rExt = result.Info.Ext
|
||||||
|
}
|
||||||
|
|
||||||
downloadResult, err := result.Download(context.Background(), "best")
|
downloadResult, err := result.Download(context.Background(), "best")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
|
@ -245,7 +282,16 @@ func (app *application) GofileDownload(target, link, identifier string, msg twit
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
safeFilename := fmt.Sprintf("download_%s", result.Info.Title)
|
safeFilename := fmt.Sprintf("download_%s", result.Info.Title)
|
||||||
rExt := result.Info.Ext
|
|
||||||
|
// For some reason youtube links return webm as result.Info.Ext but
|
||||||
|
// are in reality mp4.
|
||||||
|
var rExt string
|
||||||
|
if strings.HasPrefix(link, "https://www.youtube.com/") || strings.HasPrefix(link, "https://youtu.be/") {
|
||||||
|
rExt = "mp4"
|
||||||
|
} else {
|
||||||
|
rExt = result.Info.Ext
|
||||||
|
}
|
||||||
|
|
||||||
downloadResult, err := result.Download(context.Background(), "best")
|
downloadResult, err := result.Download(context.Background(), "best")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Errorln(err)
|
app.Log.Errorln(err)
|
||||||
|
|
|
@ -112,6 +112,33 @@ func (app *application) CatboxUpload(target, fileName, identifier string, msg tw
|
||||||
app.Send(target, reply, msg)
|
app.Send(target, reply, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (app *application) GetGofileServer() string {
|
||||||
|
type gofileData struct {
|
||||||
|
Server string `json:"server"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type gofileResponse struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
Data gofileData
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := http.Get("https://api.gofile.io/getServer")
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
responseData, err := io.ReadAll(response.Body)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
var responseObject gofileResponse
|
||||||
|
if err = json.Unmarshal(responseData, &responseObject); err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadServer := fmt.Sprintf("https://%s.gofile.io/uploadFile", responseObject.Data.Server)
|
||||||
|
return uploadServer
|
||||||
|
}
|
||||||
|
|
||||||
func (app *application) GofileUpload(target, path, identifier string, msg twitch.PrivateMessage) {
|
func (app *application) GofileUpload(target, path, identifier string, msg twitch.PrivateMessage) {
|
||||||
defer os.Remove(path)
|
defer os.Remove(path)
|
||||||
app.Send(target, "Uploading to gofile.io... dankCircle", msg)
|
app.Send(target, "Uploading to gofile.io... dankCircle", msg)
|
||||||
|
@ -159,7 +186,8 @@ func (app *application) GofileUpload(target, path, identifier string, msg twitch
|
||||||
form.Close()
|
form.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodPost, GOFILE_ENDPOINT, pr)
|
gofileServer := app.GetGofileServer()
|
||||||
|
req, err := http.NewRequest(http.MethodPost, gofileServer, pr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||||
os.Remove(path)
|
os.Remove(path)
|
||||||
|
|
Loading…
Reference in a new issue