Compare commits
No commits in common. "c5015145b2e72d336dc1388445cec79b4e9d096d" and "186d3b306964aadbb13af6d3f3950ad4db781106" have entirely different histories.
c5015145b2
...
186d3b3069
2 changed files with 2 additions and 39 deletions
|
@ -33,7 +33,7 @@ func getLargestFormat(input goutubedl.Result, sizeLimit float64) (format goutube
|
||||||
} else {
|
} else {
|
||||||
size = input.Formats()[i].Filesize
|
size = input.Formats()[i].Filesize
|
||||||
}
|
}
|
||||||
if size <= sizeLimit && input.Formats()[i].VCodec != "h265" { // Discord can't embed HEVC
|
if size <= sizeLimit {
|
||||||
return input.Formats()[i], nil
|
return input.Formats()[i], nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,6 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
choice, err := getLargestFormat(result, 8*1024*1024)
|
choice, err := getLargestFormat(result, 8*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)
|
|
||||||
downloadResult, err := result.Download(context.Background(), choice.FormatID)
|
downloadResult, err := result.Download(context.Background(), choice.FormatID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
@ -117,7 +116,6 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
choice, err := getLargestYTFormat(result, 8*1024*1024)
|
choice, err := getLargestYTFormat(result, 8*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)
|
|
||||||
downloadResult, err := result.Download(context.Background(), choice.FormatID)
|
downloadResult, err := result.Download(context.Background(), choice.FormatID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -150,8 +148,7 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
session.ChannelTyping(message.ChannelID)
|
downloadResult, err := result.Download(context.Background(), result.Formats()[0].FormatID) // Insta only has one possible format to download :(
|
||||||
downloadResult, err := result.Download(context.Background(), "best") // Insta only has one possible format to download :(
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
continue
|
continue
|
||||||
|
@ -184,40 +181,6 @@ func messageCreate(session *discordgo.Session, message *discordgo.MessageCreate)
|
||||||
downloadResult.Close()
|
downloadResult.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
respond = true
|
|
||||||
} else if output, _ := regexp.MatchString("(http.*tiktok\\.com/\\@.*)", url); output {
|
|
||||||
log.Println("TikTok detected.")
|
|
||||||
|
|
||||||
response.Content = response.Content + fmt.Sprintf("\n<%s>", regexp.MustCompile("http.*tiktok\\.com").ReplaceAllString(url, "https://proxitok.pussthecat.org"))
|
|
||||||
|
|
||||||
result, err := goutubedl.New(context.Background(), url, goutubedl.Options{})
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
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)
|
|
||||||
downloadResult, err := result.Download(context.Background(), choice.FormatID)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
//session.ChannelMessageSend(message.ChannelID, err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Files = append(response.Files, &discordgo.File {
|
|
||||||
Name: fmt.Sprintf("%s.%s", result.Info.ID, choice.Ext),
|
|
||||||
ContentType: "text/plain", // This is of course not true, but Discord doesn't give a shit
|
|
||||||
Reader: downloadResult,
|
|
||||||
})
|
|
||||||
|
|
||||||
defer downloadResult.Close()
|
|
||||||
} else {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
respond = true
|
respond = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue