partial fix for DLSystem

This commit is contained in:
2022-07-08 19:22:01 +00:00
parent ae59afb5ae
commit cb6991bfe8
2 changed files with 12 additions and 4 deletions

View File

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

View File

@@ -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"])))))
))))