diff --git a/.gitignore b/.gitignore index d7e0653..349a46f 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,7 @@ discord-exploits discord-exploits-linux-32bit discord-exploits-linux-64bit + +*.mp4 + +*.jpeg diff --git a/exploits.go b/exploits.go index 1d76c09..151a59b 100644 --- a/exploits.go +++ b/exploits.go @@ -2,10 +2,10 @@ package main import ( "fmt" - "github.com/Schmenn/discord-exploits/exploits" - "github.com/Schmenn/discord-exploits/modules" "os" "strings" + "github.com/Schmenn/discord-exploits/exploits" + "github.com/Schmenn/discord-exploits/modules" ) var ( @@ -27,6 +27,7 @@ func main() { fmt.Println("mode: " + mode) initCommand(inputFile, mode) + } func handleArgs(args []string, quiet *bool) { @@ -64,7 +65,7 @@ func handleArgs(args []string, quiet *bool) { } -func initCommand(inputFile string, mode string) { +/*func initCommand(inputFile string, mode string) { inputFile = strings.ToLower(inputFile) switch strings.ToLower(mode) { case "e": @@ -73,7 +74,7 @@ func initCommand(inputFile string, mode string) { exploits.RunExpandingVideoTask(inputFile) fmt.Println("completed task.") } else { - fmt.Println("File is not a webm, check -h") + fmt.Println("File is not a webm or mp4, check -h") } case "n": if strings.HasSuffix(inputFile, ".webm") { @@ -101,3 +102,81 @@ func initCommand(inputFile string, mode string) { } } } +*/ + +func initCommand(inputFile string, mode string) { + inputFile = strings.ToLower(inputFile) + + if strings.HasSuffix(inputFile, ".webm") { + + switch mode { + case "e": + fmt.Println("editing video.") + exploits.RunExpandingVideoTask(inputFile) + fmt.Println("completed task.") + case "n": + fmt.Println("editing video.") + exploits.RunNegativeVideoTask(inputFile) + fmt.Println("completed task.") + case "0", "v": + fmt.Println("editing video.") + exploits.RunZeroVideoTask(inputFile) + fmt.Println("completed task.") + default: + fmt.Println("the mode doesn't match the file") + } + + } else if strings.HasSuffix(inputFile, ".mp4") { + + switch mode { + case "e": + fmt.Println("transcoding video from mp4 to webm") + out := modules.Transcode(inputFile, "webm") + fmt.Println("finished transcoding video from mp4 to webm") + fmt.Println("editing video.") + exploits.RunExpandingVideoTask(out) + fmt.Println("completed task.") + os.Remove(out) + + case "n": + fmt.Println("transcoding video from mp4 to webm") + out := modules.Transcode(inputFile, "webm") + fmt.Println("finished transcoding video from mp4 to webm") + fmt.Println("editing video.") + exploits.RunNegativeVideoTask(out) + fmt.Println("completed task.") + os.Remove(out) + + case "0", "v": + fmt.Println("transcoding video from mp4 to webm") + out := modules.Transcode(inputFile, "webm") + fmt.Println("finished transcoding video from mp4 to webm") + fmt.Println("editing video.") + exploits.RunZeroVideoTask(out) + fmt.Println("completed task.") + os.Remove(out) + + default: + fmt.Println("the mode doesn't match the file") + } + + } else if strings.HasSuffix(inputFile, "png") { + fmt.Println("editing photo.") + exploits.RunVirusImageTask(inputFile) + fmt.Println("completed task.") + } else if strings.HasSuffix(inputFile, "jpg") { + fmt.Println("transcoding image from jpg to png") + out := modules.Transcode(inputFile, "png") + fmt.Println("finished transcoding image from jpg to png") + fmt.Println("editing photo.") + exploits.RunVirusImageTask(out) + fmt.Println("completed task.") + } else if strings.HasSuffix(inputFile, "jpeg") { + fmt.Println("transcoding image from jpeg to png") + out := modules.Transcode(inputFile, "png") + fmt.Println("finished transcoding image from jpeg to png") + fmt.Println("editing photo.") + exploits.RunVirusImageTask(out) + fmt.Println("completed task.") + } +} diff --git a/modules/ffmpeg-check.go b/modules/ffmpeg-check.go new file mode 100644 index 0000000..0ed9832 --- /dev/null +++ b/modules/ffmpeg-check.go @@ -0,0 +1,16 @@ +package modules + +import ( + "os/exec" +) + +// CheckForFFmpeg looks for ffmpeg in the path +func CheckForFFmpeg() string { + path, err := exec.LookPath("ffmpeg") + + if err != nil { + panic(err) + } + + return path +} diff --git a/modules/transcode-to-webm.go b/modules/transcode-to-webm.go new file mode 100644 index 0000000..5258f46 --- /dev/null +++ b/modules/transcode-to-webm.go @@ -0,0 +1,16 @@ +package modules + +import( + "os/exec" +) + +//Transcode transcodes video to webm +func Transcode (input string, to string) string { + path := CheckForFFmpeg() + output := CreateName(to) + + cmd := exec.Command(path, "-i", input, output) + err := cmd.Run() + Check(err) + return output +}