thread DLSystem for mp3s
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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 {}
|
||||||
|
|||||||
@@ -13,12 +13,23 @@
|
|||||||
url (readComponent e DLURL)]
|
url (readComponent e DLURL)]
|
||||||
(cond
|
(cond
|
||||||
((tagsMatch e "music")
|
((tagsMatch e "music")
|
||||||
|
(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 ${basename}.mp3 $url
|
||||||
```
|
```
|
||||||
|
(ui.displayMessage "done downloading $basename")
|
||||||
|
|
||||||
(addFiles archive e ["${basename}.mp3"]))
|
(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"])))))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user