Increased video size to 25MB
This commit is contained in:
parent
7fda738076
commit
ec5f265793
1 changed files with 11 additions and 7 deletions
|
@ -63,7 +63,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
} else {
|
} 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)
|
log.Printf("Choice: %s | Size: %fM\n", choice.FormatID, choice.FilesizeApprox/1024/1024)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
session.ChannelTyping(message.ChannelID)
|
session.ChannelTyping(message.ChannelID)
|
||||||
|
@ -109,12 +109,12 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
continue
|
continue
|
||||||
} else if result.Info.AgeLimit < 18 && ! result.Info.IsLive {
|
} 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)
|
log.Printf("Choice: %s+%s | Size: %fM\n", videoChoice.FormatID, audioChoice.FormatID, (videoChoice.Filesize+audioChoice.Filesize)/1024/1024)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
downloadResult, err := result.Download(context.Background(), fmt.Sprintf("%s+%s", videoChoice.FormatID, audioChoice.FormatID))
|
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)
|
log.Printf("Choice: %s | Size: %fM\n", choice.FormatID, choice.FilesizeApprox/1024/1024)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
session.ChannelTyping(message.ChannelID)
|
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
|
// 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)
|
size, err := io.ReadFull(downloadResult, buf)
|
||||||
|
|
||||||
// This section is probably really bad, don't copy it. Actually, don't even look at it.
|
// 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)
|
log.Printf("Video Size: %fM", float64(size)/1024/1024)
|
||||||
|
|
||||||
var newBuf = make([]byte, size)
|
var newBuf = make([]byte, size)
|
||||||
|
@ -195,7 +195,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
continue
|
continue
|
||||||
} else {
|
} 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)
|
log.Printf("Choice: %s | Size: %fM\n", choice.FormatID, choice.Filesize/1024/1024)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
session.ChannelTyping(message.ChannelID)
|
session.ChannelTyping(message.ChannelID)
|
||||||
|
@ -237,7 +237,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
} else {
|
} 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)
|
log.Printf("Choice: %s+%s | Size: %fM\n", videoChoice.FormatID, audioChoice.FormatID, (videoChoice.FilesizeApprox+audioChoice.FilesizeApprox)/1024/1024)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
session.ChannelTyping(message.ChannelID)
|
session.ChannelTyping(message.ChannelID)
|
||||||
|
@ -262,6 +262,10 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
respond = true
|
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