Implement inverse filtering for albums
This commit is contained in:
parent
1799672084
commit
19d22d1428
@ -11,10 +11,17 @@ from spotipy import Spotify
|
|||||||
from .util import chunk, exhaust, parse_release_date
|
from .util import chunk, exhaust, parse_release_date
|
||||||
|
|
||||||
|
|
||||||
def album_filter_label(albums: Iterable[SimplifiedAlbum], label: str) -> Iterable[SearchAlbum]:
|
def album_filter_label(
|
||||||
"Filter albums that match an exact label string"
|
albums: Iterable[SimplifiedAlbum], label: str, include: bool = True
|
||||||
|
) -> Iterable[SimplifiedAlbum]:
|
||||||
|
"""
|
||||||
|
Filter albums based on the label.
|
||||||
|
|
||||||
|
If `include`, yield labels that match the provided string (typical filter behavior).
|
||||||
|
Otherwise, yield only those albums that don't match the label.
|
||||||
|
"""
|
||||||
for album in albums:
|
for album in albums:
|
||||||
if album.label == label:
|
if (album.label == label) == include:
|
||||||
yield album
|
yield album
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user