Increased video size to 25MB

This commit is contained in:
Logan G 2023-05-05 16:47:32 -06:00
parent 7fda738076
commit ec5f265793
Signed by: logan
GPG key ID: E328528C921E7A7A

View file

@ -63,7 +63,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
continue
} else {
choice, err := getLargestFormat(result, 8*1024*1024)
choice, err := getLargestFormat(result, 25*1024*1024)
log.Printf("Choice: %s | Size: %fM\n", choice.FormatID, choice.FilesizeApprox/1024/1024)
if err == nil {
session.ChannelTyping(message.ChannelID)
@ -109,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, 8*1024*1024)
videoChoice, audioChoice, err := getLargestDashFormat(result, 25*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, 8*1024*1024)
choice, err := getLargestYTFormat(result, 25*1024*1024)
log.Printf("Choice: %s | Size: %fM\n", choice.FormatID, choice.FilesizeApprox/1024/1024)
if err == nil {
session.ChannelTyping(message.ChannelID)
@ -159,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, 8*1024*1024 + 1)
var buf = make([]byte, 25*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 <= 8*1024*1024 && err.Error() == "unexpected EOF" {
if size <= 25*1024*1024 && err.Error() == "unexpected EOF" {
log.Printf("Video Size: %fM", float64(size)/1024/1024)
var newBuf = make([]byte, size)
@ -195,7 +195,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
log.Println(err)
continue
} else {
choice, err := getLargestFormat(result, 8*1024*1024)
choice, err := getLargestFormat(result, 25*1024*1024)
log.Printf("Choice: %s | Size: %fM\n", choice.FormatID, choice.Filesize/1024/1024)
if err == nil {
session.ChannelTyping(message.ChannelID)
@ -237,7 +237,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
continue
} else {
videoChoice, audioChoice, err := getLargestDashFormat(result, 8*1024*1024)
videoChoice, audioChoice, err := getLargestDashFormat(result, 25*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)
@ -262,6 +262,10 @@ 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.")
}
}