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

@@ -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 {}

View File

@@ -13,12 +13,23 @@
url (readComponent e DLURL)]
(cond
((tagsMatch e "music")
```
youtube-dl -x --audio-format mp3 -o ${basename}.mp3 $url
```
(addFiles archive e ["${basename}.mp3"]))
(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"])))))
(addTags archive e ["dlProcessed"])))))