diff --git a/projects/nat-archive-tool/src/nat/systems/DLSystem.hx b/projects/nat-archive-tool/src/nat/systems/DLSystem.hx index 2c0d6f5a..1c2ea8b9 100644 --- a/projects/nat-archive-tool/src/nat/systems/DLSystem.hx +++ b/projects/nat-archive-tool/src/nat/systems/DLSystem.hx @@ -3,6 +3,7 @@ package nat.systems; import kiss.Prelude; import kiss.List; import nat.System; +using StringTools; #if target.threaded import sys.thread.Thread; #end diff --git a/projects/nat-archive-tool/src/nat/systems/DLSystem.kiss b/projects/nat-archive-tool/src/nat/systems/DLSystem.kiss index 3a338f49..bb09bf88 100644 --- a/projects/nat-archive-tool/src/nat/systems/DLSystem.kiss +++ b/projects/nat-archive-tool/src/nat/systems/DLSystem.kiss @@ -9,18 +9,25 @@ ->[archive e] (and hasYTDL (catsMatch e "(unless dlProcessed DLURL)")) ->[archive e &opt ui] - (let [basename (uuid) + (let [basename "$(readComponentOr e Name (uuid))-DL" + o "\"${basename}.%(ext)s\"" + o (if (= (Sys.systemName) "Windows") + (o.replace "%" "%%") + o) url (readComponent e DLURL)] (cond ((tagsMatch e "music") + // TODO put active dl processes in a map and + // don't start new ones when re-processing (localFunction :Void downloadMp3 [] (ui.displayMessage "downloading $url as $basename") ``` - youtube-dl -x --audio-format mp3 -o ${basename}.mp3 $url + youtube-dl -x --audio-format mp3 -o $o $url ``` (ui.displayMessage "done downloading $basename") - (addFiles archive e ["${basename}.mp3"])) + (addFiles archive e ["${basename}.mp3"]) + (addTags archive e ["dlProcessed"])) (#if target.threaded (Thread.create downloadMp3) { @@ -31,5 +38,5 @@ (log ui "DLSystem doesn't know what to do with $(readComponent e Tags)") (return null))) - (addTags archive e ["dlProcessed"]))))) + ))))