Giter VIP home page Giter VIP logo

spotify-next's Introduction

spotify-next

License

A small program making it easier to filter out music on Spotify.

asciicast

Installation

  1. Create an application in the Spotify API dashboard. Add a redirect URI pointing to http://localhost:4321/login. The port 4321 is configured in the .spotify-next.json config file (see usage).

  2. If you have coursier, this will install the app in your current working directory:

coursier bootstrap com.kubukoz:spotify-next_3:1.4.0 -o spotify-next

# now you can run the app like this:
./spotify-next --help

Build from source

Alternatively, if you want a fresh-out-of-the-oven version, you can build it from source:

  1. sbt stage

This will create a launcher at ./target/universal/stage/bin/spotify-next.

Usage

The application requires some configuration (e.g. the client ID for the Spotify Web API). It's stored in a file at $XDG_CONFIG_HOME/spotify-next/config.json or $HOME/.config/spotify-next/config.json (whichever works first). When you first run the application, or if that file is deleted, the application will ask and attempt to create one.

The configuration defines the port for the embedded HTTP server used for authentication. The server will only start when the login flow is triggered, and stop afterwards.

$ ./spotify-next --help

Usage:
    spotify-next login
    spotify-next skip
    spotify-next drop
    spotify-next forward
    spotify-next jump
    spotify-next s
    spotify-next d
    spotify-next f
    spotify-next j
    spotify-next repl

spotify-next: Gather great music.

Options and flags:
    --help
        Display this help text.
    --version, -v
        Print the version number and exit.

Subcommands:
    login
        Log into Spotify
    skip
        Skip to next track without any changes
    drop
        Drop current track from the current playlist and skip to the next track
    forward
        Fast forward the current track by a percentage of its length (10% by default)
    jump
        Fast forward the current track to the next section
    s
        Alias for `skip`
    d
        Alias for `drop`
    f
        Alias for `forward`
    j
        Alias for `jump`
    repl
        Run application in interactive mode

You can run the login command to be prompted for authorization, or you can rely on the fallback mechanism of all API calls - when one fails with 401 Unauthorized, you'll see the response and be prompted to log in. The call will be retried once after you successfully log in.

The application automatically saves the token to the configuration file after successful logins.

spotify-next's People

Contributors

kubukoz avatar mergify[bot] avatar peter-lavigne avatar scala-steward avatar toshihidetagami avatar valencik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

spotify-next's Issues

New command for viewing playlist

Something like q or p could work - for example, given this state:

image

we would show

Crushed - Parkway Drive
All Ngiht - Camo & Krooked
Toi - Worakls
Future Club - Perturbator
Bass Inside - AC Slater

The current song could be either in bold or with (currently playing). So basically the current song and up to 2 before/after (possibly configurable).

Dropping a song isn't immediately reflected since 1.3.0

In 1.3.0, I flipped the order of actions in drop: first we play the next song, then we delete the one playing previously.

This seems to have a negative effect on the UX: the Spotify Desktop app doesn't notice the deletion of a song from a playlist unless one of these happens:

  • you open a different page and go back to the playlist
  • the song being deleted is the one being played.

That's unfortunate, but the change was required to ensure consistent behavior between Sonos API and Spotify API controlled playback.

It would be nice to find a workaround that will ensure the Spotify app reloads the track list and doesn't show the deleted tracks anymore.

Replace `Console` with a logger

Having a logger would allow us to customize the levels of information being logged in debug/production mode more easily. We already have logback and slf4j in the dependencies because http4s brings them.

I think for the time being (while http4s is pulling in these logging libraries) the best course of action is to follow what we did in https://github.com/pitgull/pitgull: use https://github.com/valskalla/odin with an slf4j bridge.

If odin is to be used, that's blocked by its migration to Cats Effect 3. We also need to upgrade all other deps here to CE3 final before that happens: this would be just http4s and decline-effect.

Feature: jump by sections

Use https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-audio-analysis to find the analysis of the currently playing song.

We can cache this eternally for every given song, but probably an expiration of ~5 minutes and/or a size bound would be good enough. The cache needs to be keyed and can't just be "the current song" because we aren't notified of manual song changes by the user and other devices.

For the initial version, we can fetch the features of the song being played on-demand: when the user first uses f (or a different command, if jumping by sections gets a different key than fast-forward), we will get the current playing song's features and jump to the beginning of the next known section. We'll put the features into the cache and possibly get them from that cache next time. For now, no caching is planned.

Feature: auto-select playback control

Currently, the playback control mode is selected on startup and remains that way until the app's exit: if there's a Sonos API at localhost:5005, we use it - otherwise, we call the Spotify API directly.

This could be improved - we have an infallible way of checking whether we should be using Sonos: the Player API.

{
  "device" : {
    "id" : null,
    "is_active" : true,
    "is_private_session" : false,
//here
    "is_restricted" : true,
//
    "name" : "Living Room",
    "type" : "Speaker",
    "volume_percent" : 8
  },
  //...
}

New command for moving song

It would fetch the configured ID of the target playlist (or ask to select one, if not set - or if an appropriate flag is provided) and try to add the song to it, then perform the rest of the drop functionality.

I think for starters the selection of the target playlist could consist of enumerating all of the user's playlists (except the one currently playing) along with their IDs, and taking any valid playlist ID as input (as long as the user has edit rights for the playlist). For phase 1, we can skip the list and just have an input here.

Use full auth flow

Currently, we're using the implicit auth flow, which only gives us tokens that are valid for an hour. A different solution should be used, so that the user doesn't have to reauthenticate every hour.

  • Store refresh tokens (#6)
  • Use refresh tokens

Feature: persist deleted songs

When using d, you will see the ID and name of the removed track. It would be nice to keep that information stored somewhere in case the user wants to find a song they deleted a while ago (spotify doesn't seem to provide this information).

I think a size-bounded log file would be okay for this, possibly stored next to the config. This would assume we move the config as in #116.

Scala 3 checklist

  • decline (awaiting 3.x release)
  • removing circe-literal
  • better-monadic-for replacement: looks like we don't have any recursion in for, so it's not a problem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.