From 8f0c6ed139325a39e627a1a2d1ca71182b6adaf6 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Tue, 16 May 2017 16:49:53 +0100 Subject: [PATCH] torrent creation functionality --- magic.json.default | 1 + source/app.d | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/magic.json.default b/magic.json.default index c031c63..81f292b 100644 --- a/magic.json.default +++ b/magic.json.default @@ -1,6 +1,7 @@ { "ffmpeg" : "/usr/bin/ffmpeg", "sox" : "/usr/bin/sox", + "mktorrent" : "/usr/bin/mktorrent", "app_secret" : "your_secret", "app_id" : "your_id", diff --git a/source/app.d b/source/app.d index 203e45a..3aff56f 100644 --- a/source/app.d +++ b/source/app.d @@ -99,6 +99,7 @@ int main(string[] args) string choice; while (choice != "n" && choice != "y") { write("Generate spectrals? [y/n] "); + stdout.flush; choice = readln().chomp; } if (choice == "y") { @@ -106,11 +107,28 @@ int main(string[] args) "-x", "3000", "-y", "513", "-z", "120", "-w", "Kaiser", "-o", "SpecFull.png"]); auto zoom = execute([magic["sox"].str, dirName~"/01 "~tracks[0]["title"].str~".flac", "-n", "remix", "1", "spectrogram", "-X", "500", "-y", "1025", "-z", "120", "-w", "Kaiser", "-S", "0:30", "-d", "0:04", "-o", "SpecZoom.png"]); - if (full.status != 0 || zoom.status != 0) { + if (full.status != 0 || zoom.status != 0) writeln("Generating spectrals failed! Is sox configured properly?"); - } else { + else writeln("SpecFull.png and SpecZoom.png written."); - } + } + + choice = null; + while (choice != "n" && choice != "y") { + write("Create .torrent file? [y/n] "); + stdout.flush; + choice = readln().chomp; + } + if (choice == "y") { + write("Announce URL: "); + stdout.flush; + string announce = readln().chomp; + + auto t = execute([magic["mktorrent"].str, "-l", "20", "-a", announce, dirName]); + if (t.status != 0) + writeln("Creating .torrent file failed! Is mktorrent configured properly?"); + else + writeln("'"~dirName~".torrent' created."); } writeln("All done, exiting.");