Implement inverse filtering for albums

This commit is contained in:
Bradlee Speice 2021-09-18 00:11:37 -04:00
parent 1799672084
commit 19d22d1428

View File

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