DLSystem check for youtube-dl
This commit is contained in:
@@ -161,6 +161,7 @@
|
|||||||
(archive.addSystem (new WikipediaImageSystem))
|
(archive.addSystem (new WikipediaImageSystem))
|
||||||
(archive.addSystem (new ImageAttachmentSystem))
|
(archive.addSystem (new ImageAttachmentSystem))
|
||||||
(archive.addSystem (new KeyShortcutSystem this))
|
(archive.addSystem (new KeyShortcutSystem this))
|
||||||
|
(archive.addSystem (new DLSystem))
|
||||||
|
|
||||||
// Just for testing:
|
// Just for testing:
|
||||||
// (archive.addSystem (new AttachmentSystem ["jpg" "jpeg" "png"] ->[archive e files] ~files))
|
// (archive.addSystem (new AttachmentSystem ["jpg" "jpeg" "png"] ->[archive e files] ~files))
|
||||||
|
|||||||
@@ -70,23 +70,28 @@
|
|||||||
(= ,value (readComponent e ,componentType))))
|
(= ,value (readComponent e ,componentType))))
|
||||||
,process))
|
,process))
|
||||||
|
|
||||||
(function :Array<String> tagList [archive :nat.Entry e]
|
(function :Array<String> tagList [:nat.Entry e]
|
||||||
(if (hasComponent e Tags)
|
(if (hasComponent e Tags)
|
||||||
(let [t (readComponent e Tags)]
|
(let [t (readComponent e Tags)]
|
||||||
(collect (t.keys)))
|
(collect (t.keys)))
|
||||||
[]))
|
[]))
|
||||||
|
|
||||||
(function tagsMatch [archive e tagsBoolExp]
|
(function tagsMatch [e tagsBoolExp]
|
||||||
(BoolExpInterp.eval tagsBoolExp (tagList archive e)))
|
(BoolExpInterp.eval tagsBoolExp (tagList e)))
|
||||||
|
|
||||||
(function componentsMatch [:nat.Entry e componentsBoolExp]
|
(function componentsMatch [:nat.Entry e componentsBoolExp]
|
||||||
(BoolExpInterp.eval componentsBoolExp (for =>cType cId e.components cType)))
|
(BoolExpInterp.eval componentsBoolExp (for =>cType cId e.components cType)))
|
||||||
|
|
||||||
|
(function componentsAndTagsMatch [:nat.Entry e componentsAndTagsBoolExp]
|
||||||
|
(BoolExpInterp.eval componentsAndTagsBoolExp (cast (concat (tagList e) (for =>cType cId e.components cType)))))
|
||||||
|
|
||||||
|
(defAlias &call catsMatch componentsAndTagsMatch)
|
||||||
|
|
||||||
(function addFiles [:nat.Archive archive :nat.Entry e :Array<String> files &opt leaveOriginalCopy]
|
(function addFiles [:nat.Archive archive :nat.Entry e :Array<String> files &opt leaveOriginalCopy]
|
||||||
(withWritableEntry archive e
|
(withWritableEntry archive e
|
||||||
(doFor file files
|
(doFor file files
|
||||||
(let [pathWithoutDir (haxe.io.Path.withoutDirectory file)]
|
(let [pathWithoutDir (haxe.io.Path.withoutDirectory file)]
|
||||||
(unless !(= -1 (e.files.indexOf pathWithoutDir))
|
(unless (contains e.files pathWithoutDir)
|
||||||
(let [pathInArchive (joinPath archive.archiveDir "files" pathWithoutDir)]
|
(let [pathInArchive (joinPath archive.archiveDir "files" pathWithoutDir)]
|
||||||
(unless (sys.FileSystem.exists pathInArchive)
|
(unless (sys.FileSystem.exists pathInArchive)
|
||||||
((if leaveOriginalCopy sys.io.File.copy sys.FileSystem.rename)
|
((if leaveOriginalCopy sys.io.File.copy sys.FileSystem.rename)
|
||||||
|
|||||||
@@ -62,10 +62,14 @@
|
|||||||
lastChangeSet)
|
lastChangeSet)
|
||||||
|
|
||||||
(defSelectCommand SelectByTags [tagsBoolExp (Text null)]
|
(defSelectCommand SelectByTags [tagsBoolExp (Text null)]
|
||||||
(filter archive.entries ->e (tagsMatch archive e tagsBoolExp)))
|
(filter archive.entries ->e (tagsMatch e tagsBoolExp)))
|
||||||
|
|
||||||
(defSelectCommand SelectByComponents [componentsBoolExp (Text null)]
|
(defSelectCommand SelectByComponents [componentsBoolExp (Text null)]
|
||||||
(filter archive.entries ->e (componentsMatch e componentsBoolExp)))
|
(filter archive.entries ->e (componentsMatch e componentsBoolExp)))
|
||||||
|
|
||||||
|
// TODO selectByCats
|
||||||
|
// there is currently no easy way to defAlias for every variation of a selection command,
|
||||||
|
// so Cats may be the canonical name
|
||||||
|
|
||||||
(defSelectCommand SelectByName [name (Text null)]
|
(defSelectCommand SelectByName [name (Text null)]
|
||||||
(nameSystem.getEntries name))
|
(nameSystem.getEntries name))
|
||||||
3
src/nat/components/DLURL.hx
Normal file
3
src/nat/components/DLURL.hx
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
package nat.components;
|
||||||
|
|
||||||
|
typedef DLURL = String;
|
||||||
8
src/nat/systems/DLSystem.hx
Normal file
8
src/nat/systems/DLSystem.hx
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package nat.systems;
|
||||||
|
|
||||||
|
import kiss.Prelude;
|
||||||
|
import kiss.List;
|
||||||
|
import nat.System;
|
||||||
|
|
||||||
|
@:build(kiss.Kiss.build())
|
||||||
|
class DLSystem extends System {}
|
||||||
16
src/nat/systems/DLSystem.kiss
Normal file
16
src/nat/systems/DLSystem.kiss
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
(load "../Lib.kiss")
|
||||||
|
|
||||||
|
(defNew []
|
||||||
|
// Check if youtube-dl is installed before doing anything
|
||||||
|
(let [&mut hasYTDL false]
|
||||||
|
(tryProcess "youtube-dl" [] ->error (when (contains error "You must provide at least one URL") (set hasYTDL true)))
|
||||||
|
|
||||||
|
(super
|
||||||
|
->[archive e]
|
||||||
|
(and ~hasYTDL (catsMatch e "(unless dlProcessed DLURL)"))
|
||||||
|
->[archive e &opt ui]
|
||||||
|
{
|
||||||
|
|
||||||
|
// (addFiles )
|
||||||
|
// (addTags archive e ["dlProcessed"])
|
||||||
|
})))
|
||||||
@@ -5,5 +5,5 @@
|
|||||||
:EntryProcessor processor]
|
:EntryProcessor processor]
|
||||||
[]
|
[]
|
||||||
(super
|
(super
|
||||||
(lambda [:Archive archive :Entry e] (tagsMatch archive e tagFilterString))
|
(lambda [:Archive archive :Entry e] (tagsMatch e tagFilterString))
|
||||||
processor))
|
processor))
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
(defNew []
|
(defNew []
|
||||||
(super
|
(super
|
||||||
"https://en.wikipedia.org/w/api.php"
|
"https://en.wikipedia.org/w/api.php"
|
||||||
->[archive e] (tagsMatch archive e "(and media !wikipediaProcessed)")
|
->[archive e] (tagsMatch e "(and media !wikipediaProcessed)")
|
||||||
scrapeForImages
|
scrapeForImages
|
||||||
1))
|
1))
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,10 @@
|
|||||||
(assert (hasComponent song2 Tags))
|
(assert (hasComponent song2 Tags))
|
||||||
(assert (componentsMatch song1 "(and Name Author)"))
|
(assert (componentsMatch song1 "(and Name Author)"))
|
||||||
(assert (componentsMatch song2 "(and Name Author)"))
|
(assert (componentsMatch song2 "(and Name Author)"))
|
||||||
(assert (tagsMatch archive song1 "(and song western)"))
|
(assert (tagsMatch song1 "(and song western)"))
|
||||||
(assert !(tagsMatch archive song1 "(and song religious)"))
|
(assert !(tagsMatch song1 "(and song religious)"))
|
||||||
(assert (tagsMatch archive song2 "(and song religious)"))
|
(assert (tagsMatch song2 "(and song religious)"))
|
||||||
(assert !(tagsMatch archive song2 "(and song western)"))
|
(assert !(tagsMatch song2 "(and song western)"))
|
||||||
|
|
||||||
(withWritableComponents archive song1
|
(withWritableComponents archive song1
|
||||||
[author Author
|
[author Author
|
||||||
|
|||||||
Reference in New Issue
Block a user