Add more search options, and a temporal filter
This commit is contained in:
@ -1,6 +1,4 @@
|
||||
"""
|
||||
Find an album using the `spotify_actions` API and echo its contents.
|
||||
"""
|
||||
# pylint: disable=missing-module-docstring, missing-function-docstring
|
||||
|
||||
from argparse import ArgumentParser
|
||||
|
||||
@ -9,9 +7,9 @@ from spotify_actions.search import search_albums
|
||||
from spotify_actions.util import read_credentials
|
||||
|
||||
|
||||
def main() -> None: # pylint: disable=missing-function-docstring
|
||||
def main() -> None:
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("-f", "--config", required=True)
|
||||
parser.add_argument("-c", "--credentials", required=True)
|
||||
parser.add_argument("search_string")
|
||||
|
||||
cmdline = parser.parse_args()
|
32
examples/label_recent_releases.py
Normal file
32
examples/label_recent_releases.py
Normal file
@ -0,0 +1,32 @@
|
||||
# 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()
|
Reference in New Issue
Block a user