spotify_actions/examples/label_recent_releases.py

33 lines
960 B
Python

# pylint: disable=missing-module-docstring, missing-function-docstring
from argparse import ArgumentParser
from datetime import date, timedelta
from spotify_actions.echo import echo_album
from spotify_actions.join import join_albums
from spotify_actions.search import search_albums_label
from spotify_actions.temporal import album_released_after
from spotify_actions.util import read_credentials
def main() -> None:
parser = ArgumentParser()
parser.add_argument("-c", "--credentials", required=True)
parser.add_argument("label", nargs="+")
cmdline = parser.parse_args()
today = date.today()
four_weeks = timedelta(days=28)
client = read_credentials(cmdline.credentials)
label_albums = [search_albums_label(client, l) for l in cmdline.label]
albums = join_albums(*label_albums)
albums_recent = album_released_after(albums, today - four_weeks)
echo_album(albums_recent)
if __name__ == "__main__":
main()