thread DLSystem for mp3s
This commit is contained in:
@@ -173,6 +173,17 @@ class Macros {
|
||||
prepareForConditional(conditionInterp, k);
|
||||
try {
|
||||
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
|
||||
Prelude.print("#if condition hscript: " + hscriptStr);
|
||||
#end
|
||||
|
||||
@@ -3,6 +3,9 @@ package nat.systems;
|
||||
import kiss.Prelude;
|
||||
import kiss.List;
|
||||
import nat.System;
|
||||
#if target.threaded
|
||||
import sys.thread.Thread;
|
||||
#end
|
||||
|
||||
@:build(kiss.Kiss.build())
|
||||
class DLSystem extends System {}
|
||||
|
||||
@@ -13,12 +13,23 @@
|
||||
url (readComponent e DLURL)]
|
||||
(cond
|
||||
((tagsMatch e "music")
|
||||
(localFunction :Void downloadMp3 []
|
||||
(ui.displayMessage "downloading $url as $basename")
|
||||
```
|
||||
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
|
||||
(log ui "DLSystem doesn't know what to do with $(readComponent e Tags)")
|
||||
(return null)))
|
||||
|
||||
(addTags archive e ["dlProcessed"])))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user