thread DLSystem for mp3s

This commit is contained in:
2022-07-07 02:30:55 +00:00
parent 21dfb34baf
commit 64204ae041
3 changed files with 30 additions and 5 deletions

View File

@@ -173,6 +173,17 @@ class Macros {
prepareForConditional(conditionInterp, k); prepareForConditional(conditionInterp, k);
try { try {
var hscriptStr = Prelude.convertToHScript(conditionStr); var hscriptStr = Prelude.convertToHScript(conditionStr);
// TODO are there more properties of target that need to be added?
// Context.definedValue only returns a string so if there's a whole
// object, I don't know how to get it
conditionInterp.variables["target"] = {
threaded:
#if target.threaded
true
#else
false
#end
};
#if test #if test
Prelude.print("#if condition hscript: " + hscriptStr); Prelude.print("#if condition hscript: " + hscriptStr);
#end #end

View File

@@ -3,6 +3,9 @@ package nat.systems;
import kiss.Prelude; import kiss.Prelude;
import kiss.List; import kiss.List;
import nat.System; import nat.System;
#if target.threaded
import sys.thread.Thread;
#end
@:build(kiss.Kiss.build()) @:build(kiss.Kiss.build())
class DLSystem extends System {} class DLSystem extends System {}

View File

@@ -13,12 +13,23 @@
url (readComponent e DLURL)] url (readComponent e DLURL)]
(cond (cond
((tagsMatch e "music") ((tagsMatch e "music")
``` (localFunction :Void downloadMp3 []
youtube-dl -x --audio-format mp3 -o ${basename}.mp3 $url (ui.displayMessage "downloading $url as $basename")
``` ```
(addFiles archive e ["${basename}.mp3"])) youtube-dl -x --audio-format mp3 -o ${basename}.mp3 $url
```
(ui.displayMessage "done downloading $basename")
(addFiles archive e ["${basename}.mp3"]))
(#if target.threaded
(Thread.create downloadMp3)
{
(print "threading unavailable -- the program will freeze while downloading with youtube-dl")
(downloadMp3)
}))
(true (true
(log ui "DLSystem doesn't know what to do with $(readComponent e Tags)") (log ui "DLSystem doesn't know what to do with $(readComponent e Tags)")
(return null))) (return null)))
(addTags archive e ["dlProcessed"]))))) (addTags archive e ["dlProcessed"])))))