Added TikTok support
This commit is contained in:
parent
f5afb11f90
commit
c5015145b2
1 changed files with 34 additions and 0 deletions
|
@ -184,6 +184,40 @@ 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