Add negation filters
This commit is contained in:
parent
447eb4120a
commit
6ecb62431e
|
@ -354,7 +354,6 @@ def downloadSong(destination, filename, entry, dlid, dldesc):
|
|||
if download_url is None:
|
||||
continue
|
||||
|
||||
print(entry)
|
||||
download_filename = filename.format(
|
||||
genre=entry["genre"],
|
||||
artist=entry["artist"],
|
||||
|
@ -625,7 +624,13 @@ def download(_filters, _id, _desc, _limit, _file_structure):
|
|||
for information_filter in song_information_filters:
|
||||
filter_field = information_filter[0].lower()
|
||||
filter_value = information_filter[1].lower()
|
||||
if re.match("^~", filter_value):
|
||||
if re.match("^!", filter_value):
|
||||
filter_value = filter_value.replace("!", "")
|
||||
if filter_value in song[filter_field].lower():
|
||||
pending_information_filters.append(False)
|
||||
else:
|
||||
pending_information_filters.append(True)
|
||||
elif re.match("^~", filter_value):
|
||||
filter_value = filter_value.replace("~", "")
|
||||
if filter_value in song[filter_field].lower():
|
||||
pending_information_filters.append(True)
|
||||
|
@ -725,6 +730,13 @@ def search(_filters):
|
|||
For example, to match all songs with "Word" in their titles:
|
||||
--filter title ~word
|
||||
|
||||
A filter can be negated by adding an exclamation mark ("!") to the beginning of the
|
||||
"<value>". Note that "!" must be escaped or single-quoted under BASH.
|
||||
|
||||
\b
|
||||
For example, to match all songs except those by Yes as their artist:
|
||||
--filter artist '!Yes'
|
||||
|
||||
Instrument filters allow selection of the presence of instruments. If an instrument
|
||||
fitler is given, only songs which contain parts for the given instrument(s) will be
|
||||
shown.
|
||||
|
@ -781,7 +793,13 @@ def search(_filters):
|
|||
for information_filter in song_information_filters:
|
||||
filter_field = information_filter[0].lower()
|
||||
filter_value = information_filter[1].lower()
|
||||
if re.match("^~", filter_value):
|
||||
if re.match("^!", filter_value):
|
||||
filter_value = filter_value.replace("!", "")
|
||||
if filter_value in song[filter_field].lower():
|
||||
pending_information_filters.append(False)
|
||||
else:
|
||||
pending_information_filters.append(True)
|
||||
elif re.match("^~", filter_value):
|
||||
filter_value = filter_value.replace("~", "")
|
||||
if filter_value in song[filter_field].lower():
|
||||
pending_information_filters.append(True)
|
||||
|
|
Loading…
Reference in New Issue