mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
Compare commits
No commits in common. "2802c4e07a45f7e23bfa6f5e9f6128179d7f8a24" and "343c8a1a685958b7adbcc874cc3ab3ea53de2b7e" have entirely different histories.
2802c4e07a
...
343c8a1a68
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/gempir/go-twitch-irc/v4"
|
||||
"github.com/google/uuid"
|
||||
|
@ -48,16 +47,7 @@ func (app *application) ConvertAndSave(fName, link string, msg twitch.PrivateMes
|
|||
app.Send(msg.Channel, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||
return
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
rExt := result.Info.Ext
|
||||
downloadResult, err := result.Download(context.Background(), "best")
|
||||
if err != nil {
|
||||
app.Log.Errorln(err)
|
||||
|
@ -113,16 +103,7 @@ func (app *application) ConvertToMP4(link string, msg twitch.PrivateMessage) {
|
|||
app.Send(msg.Channel, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
rExt := result.Info.Ext
|
||||
downloadResult, err := result.Download(context.Background(), "best")
|
||||
if err != nil {
|
||||
app.Log.Errorln(err)
|
||||
|
@ -175,16 +156,7 @@ func (app *application) YafDownload(target, link, identifier string, msg twitch.
|
|||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
rExt := result.Info.Ext
|
||||
downloadResult, err := result.Download(context.Background(), "best")
|
||||
if err != nil {
|
||||
app.Log.Errorln(err)
|
||||
|
@ -228,16 +200,7 @@ func (app *application) KappaDownload(target, link, identifier string, msg twitc
|
|||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||
return
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
rExt := result.Info.Ext
|
||||
downloadResult, err := result.Download(context.Background(), "best")
|
||||
if err != nil {
|
||||
app.Log.Errorln(err)
|
||||
|
@ -282,16 +245,7 @@ func (app *application) GofileDownload(target, link, identifier string, msg twit
|
|||
return
|
||||
}
|
||||
safeFilename := fmt.Sprintf("download_%s", result.Info.Title)
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
rExt := result.Info.Ext
|
||||
downloadResult, err := result.Download(context.Background(), "best")
|
||||
if err != nil {
|
||||
app.Log.Errorln(err)
|
||||
|
|
|
@ -112,33 +112,6 @@ func (app *application) CatboxUpload(target, fileName, identifier string, msg tw
|
|||
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) {
|
||||
defer os.Remove(path)
|
||||
app.Send(target, "Uploading to gofile.io... dankCircle", msg)
|
||||
|
@ -186,8 +159,7 @@ func (app *application) GofileUpload(target, path, identifier string, msg twitch
|
|||
form.Close()
|
||||
}()
|
||||
|
||||
gofileServer := app.GetGofileServer()
|
||||
req, err := http.NewRequest(http.MethodPost, gofileServer, pr)
|
||||
req, err := http.NewRequest(http.MethodPost, GOFILE_ENDPOINT, pr)
|
||||
if err != nil {
|
||||
app.Send(target, fmt.Sprintf("Something went wrong FeelsBadMan: %q", err), msg)
|
||||
os.Remove(path)
|
||||
|
|
Loading…
Reference in a new issue