The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

spotify-cli.pl - Script to interact with Spotify API in various ways.

SYNOPSIS

    perl bin/spotify-cli.pl -i

DESCRIPTION

This script allows you to interact with Spotify API in multiple different ways. Providing you with a convinent way to query Spotify API by either the set of predefined commands or inline requests.

OPTIONS

-c, --client-id=Spotify App Client ID

Your registered Spotify Application Client ID Can be set as environment variable client_id

-s, --client-secret=Spotify APP Client Secret

Your registered Spotify Application Client Secret Can be set as environment variable client_secret

-t, --access-token=Spotify Client Access Token

Optional, if passed there will be no need to obtain token and requests can be directly called using it. Can be set as environment variable access_token

-i, --interactive

If exists it will run this script in interactive mode, where it will continuously wait for a command to perform. However manual handling for Authentication process.

-w, --web-server

If exists it will make the script run in interactive mode, with an HTTP Webserver running in background listening to port 80 on localhost. So it can process Spotify callback GET requests automatically. and can be extended to receive commands. Note: define http://localhost/callback as a Redirect URI in your Spotify App settings. Also if running in Docker, then run container with -p 127.0.0.1:80:80/tcp option.

-l debug, --log-level=info

Log level used. with default being Info.

COMMANDS

Available Commands:

CMD => p uri(optional) device_id(optional)

Play - Player -> start_a_users_playback

CMD => pu

Pause - Player -> pause_a_users_playback

CMD => n

Next - Player -> skip_users_playback_to_next_track

CMD => b

Previous - Player -> skip_users_playback_to_previous_track

CMD => ff seconds

FastForward the current playing track with the passed.

CMD => set_s second

Set the current playing track position to the passed second.

CMD => sh (true)|false

Toggle Shuffle for current Playback context.

CMD => c

Current Track - Player -> get_information_about_the_users_current_playback

CMD => d

Available Devices - Player -> get_a_users_available_devices

CMD => d_select name|ID 1|(0)/play

Selects a device, That will be used for Player API during this session.

CMD => t device_id

Transfer playback to device and start playing.

CMD => v volume_percent

Sets the current active device's volume.

CMD => l

Like the current playing song.

CMD => ul

Remove the current playing song from Liked.

CMD => f

Current track Audio Features.

CMD => fc_dance dance_level(0.6)

Find in Current Contenxt Track with more than the passed danceablitiy leve.

CMD => g

Get a list of available recommendation genres

CMD => i (tracks)|artists s|(m)|l count(2) offset(0)

Get your top tracks | artists. where time_range => s:short_term, m:medium_term, l:long_term

CMD => seed_t ID|(current)

add the track as a seed track (will keep latest selected 2 only)

CMD => seed_a ID|(current)

add the artist as a seed track (will keep latest selected 2 only)

CMD => rng genre(reggae) (auto)|manual acousticness danceability energy instrumentalness liveness loudness speechiness tempo valence

Get you a random track based on passed Genre, Tracks and Artists used as seed, Auto for them to be your top tracks and artists. and manual for selected seeded ones. Also accepts constrains on track features.

CMD => me

Current user Info.

CMD => s string

Search for a track

CMD => pl_ls

List user's playlists.

CMD => pl_add playlist_name public:(true)|false "Description"

Creates a new playlist for user.

CMD => pl_select 1|0(playit?) name|ID

Selects a playlist, passing a second parameter will play it too.

CMD => atp playlistID(default selected)

Adds the current playing track to a playlist. If no PlaylistID passed it will use selected.

CMD => rfp playlistID(default selected)

Removes the current playing track from a playlist. If no PlaylistID passed it will use selected.

CMD => api_name method_name %args

Generic - Where it will take first argument as API name, second would be the method name. And whaterve comes after that would be a key value arguments.