Compare commits
No commits in common. "294e68db7de30cd7f317952e2662dcd46c32cbe9" and "7fda7380766089c197c9cde27fc6e8c890fae243" have entirely different histories.
294e68db7d
...
7fda738076
1 changed files with 7 additions and 13 deletions
|
@ -13,8 +13,6 @@ import (
|
|||
"mvdan.cc/xurls/v2" // Peak lazy
|
||||
)
|
||||
|
||||
const MaxSize = 25*1024*1024
|
||||
|
||||
// This function will be called every time a new message is created on any channel that the authenticated bot has access to.
|
||||
func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate) {
|
||||
// Ignore all messages created by the bot itself
|
||||
|
@ -65,7 +63,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
|||
|
||||
continue
|
||||
} else {
|
||||
choice, err := getLargestFormat(result, MaxSize)
|
||||
choice, err := getLargestFormat(result, 8*1024*1024)
|
||||
log.Printf("Choice: %s | Size: %fM\n", choice.FormatID, choice.FilesizeApprox/1024/1024)
|
||||
if err == nil {
|
||||
session.ChannelTyping(message.ChannelID)
|
||||
|
@ -111,12 +109,12 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
|||
continue
|
||||
} else if result.Info.AgeLimit < 18 && ! result.Info.IsLive {
|
||||
/*
|
||||
videoChoice, audioChoice, err := getLargestDashFormat(result, MaxSize)
|
||||
videoChoice, audioChoice, err := getLargestDashFormat(result, 8*1024*1024)
|
||||
log.Printf("Choice: %s+%s | Size: %fM\n", videoChoice.FormatID, audioChoice.FormatID, (videoChoice.Filesize+audioChoice.Filesize)/1024/1024)
|
||||
if err == nil {
|
||||
downloadResult, err := result.Download(context.Background(), fmt.Sprintf("%s+%s", videoChoice.FormatID, audioChoice.FormatID))
|
||||
*/
|
||||
choice, err := getLargestYTFormat(result, MaxSize)
|
||||
choice, err := getLargestYTFormat(result, 8*1024*1024)
|
||||
log.Printf("Choice: %s | Size: %fM\n", choice.FormatID, choice.FilesizeApprox/1024/1024)
|
||||
if err == nil {
|
||||
session.ChannelTyping(message.ChannelID)
|
||||
|
@ -161,11 +159,11 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
|||
|
||||
|
||||
// Test to see if the result is more than 8MB through the tried and true method of downloading it into a 8MB slice and seeing if it errors out
|
||||
var buf = make([]byte, MaxSize + 1)
|
||||
var buf = make([]byte, 8*1024*1024 + 1)
|
||||
size, err := io.ReadFull(downloadResult, buf)
|
||||
|
||||
// This section is probably really bad, don't copy it. Actually, don't even look at it.
|
||||
if size <= MaxSize && err.Error() == "unexpected EOF" {
|
||||
if size <= 8*1024*1024 && err.Error() == "unexpected EOF" {
|
||||
log.Printf("Video Size: %fM", float64(size)/1024/1024)
|
||||
|
||||
var newBuf = make([]byte, size)
|
||||
|
@ -197,7 +195,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
|||
log.Println(err)
|
||||
continue
|
||||
} else {
|
||||
choice, err := getLargestFormat(result, MaxSize)
|
||||
choice, err := getLargestFormat(result, 8*1024*1024)
|
||||
log.Printf("Choice: %s | Size: %fM\n", choice.FormatID, choice.Filesize/1024/1024)
|
||||
if err == nil {
|
||||
session.ChannelTyping(message.ChannelID)
|
||||
|
@ -239,7 +237,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
|||
|
||||
continue
|
||||
} else {
|
||||
videoChoice, audioChoice, err := getLargestDashFormat(result, MaxSize)
|
||||
videoChoice, audioChoice, err := getLargestDashFormat(result, 8*1024*1024)
|
||||
log.Printf("Choice: %s+%s | Size: %fM\n", videoChoice.FormatID, audioChoice.FormatID, (videoChoice.FilesizeApprox+audioChoice.FilesizeApprox)/1024/1024)
|
||||
if err == nil {
|
||||
session.ChannelTyping(message.ChannelID)
|
||||
|
@ -264,10 +262,6 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
|||
*/
|
||||
|
||||
respond = true
|
||||
} else if output, _ := regexp.MatchString("(http.*clips\\.twitch\\.tv/\\.*)", url); output {
|
||||
//TODO: Finish
|
||||
//Twitch doesn't report filesize (makes too much sense I guess).
|
||||
log.Println("Twitch clip detected.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue