Skip to content

Commit

Permalink
More predicates.
Browse files Browse the repository at this point in the history
  • Loading branch information
smimram committed May 31, 2023
1 parent 76e16cd commit 2b8ca49
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/libs/medialib.liq
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,19 @@ def medialib(~persistency=null(), directories=[])
end
end

def find(~artist=null(), ~artist_contains=null())
def find(~artist=null(), ~artist_contains=null(), ~genre=null(), ~title=null(), ~title_contains=null(), ~predicate=(fun(m)->true))
def p(m)
(null.defined(artist) ? m["artist"] == null.get(artist) : true)
and
(null.defined(artist_contains) ? string.contains(substring=null.get(artist_contains), m["artist"]) : true)
and
(null.defined(genre) ? m["genre"] == null.get(genre) : true)
and
(null.defined(title) ? m["title"] == null.get(title) : true)
and
(null.defined(title_contains) ? string.contains(substring=null.get(title_contains), m["title"]) : true)
and
predicate(m)
end
l = list.filter(fun (fm) -> p(snd(fm)), db())
l = list.map(fst, l)
Expand Down

0 comments on commit 2b8ca49

Please sign in to comment.