-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Spotify OAuth support and autotagger integration #3123
Conversation
Awesome; this is a great start! We can register for a proper API key. For the tests, however, we should avoid needing to communicate with the actual Spotify API server—instead, the tests should mock the API’s responses so they can be run even without a connection to the Internet. |
Ah of course! I forgot to adjust the tests but will soon. Thanks for this awesome piece of software, by the way!
…On Sat, Jan 19, 2019, 7:59 PM Adrian Sampson ***@***.***> wrote:
Awesome; this is a great start!
We can register for a proper API key. For the tests, however, we should
avoid needing to communicate with the actual Spotify API server—instead,
the tests should mock the API’s responses so they can be run even without a
connection to the Internet.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3123 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFIKbah2bRbW_88-8Xmpu1QRmvXy8aXOks5vE-megaJpZM4aJbo6>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! This is looking good. I had only a couple of small style comments after a review. Could you please also look into documenting the new functionality for the plugin?
I've added some documentation to spotify.rst regarding the new functionality, and happy to add more if necessary. One thing I'm not quite sure about is the proper implementation of the Thanks again for the swift replies all your work on this awesome project! Edit: typo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I have just a few writing suggestions for improving the docs. Other than this, do you think this is ready to merge?
docs/plugins/spotify.rst
Outdated
@@ -67,10 +106,20 @@ in config.yaml under the ``spotify:`` section: | |||
track/album/artist fields before sending them to Spotify. Can be useful for | |||
changing certain abbreviations, like ft. -> feat. See the examples below. | |||
Default: None. | |||
- **tokenfile**: Filename of the JSON file stored in the beets configuration | |||
directory to use for caching the OAuth access token. | |||
Default: ``spotify_token.json``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm… perhaps we shouldn't even mention this option in the docs. I don't expect anyone will ever need to change it, and omitting the unnecessary options should make the docs page a little easier to read. (FWIW, we don't document tokenfile
for the other OAuth-based plugins we have.)
docs/plugins/spotify.rst
Outdated
* Back Seat Driver (Spirit Guide) -> Back Seat Driver (Spirit Guide) (source) | ||
* 2AM -> 2AM (source) | ||
[A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums, | ||
Enter search, enter Id, aBort, eDit, edit Candidates, plaY? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure having the whole candidate display is necessary here. Maybe the just the first two lines would be enough to get the idea across?
docs/plugins/spotify.rst
Outdated
library with the ``beet spotify`` command. Using the `Spotify Search API`_, | ||
any tracks that can be matched with a Spotify ID are returned, and the | ||
results can be either pasted in to a playlist or opened directly in the | ||
Spotify app. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a slightly more direct way to say this without the passive voice: "Also, the plugin can use the Spotify Search API to provide metadata matches for the importer."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part of the doc is actually referring to the beet spotify
command which lists Spotify URLs for existing library tracks, but good point about using the active voice. I've consolidated this with the portion below and it now reads:
The
spotify
plugin generates Spotify playlists from tracks in your
library with thebeet spotify
command using the Spotify Search API.
Also, the plugin can use the Spotify Album and Track APIs to provide
metadata matches for the importer.
Not sure if we even need to specifically mention that we're using the Search/Album/Track APIs, I can remove that if not.
docs/plugins/spotify.rst
Outdated
|
||
Spotify URLs and IDs may also be provided to the ``Enter release ID:`` prompt | ||
during ``beet import`` to autotag music with data from the Spotify | ||
`Album`_ and `Track`_ APIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably get away without mentioning this here—the "search by ID" functionality is a standard part of any plugin that extends the importer with a metadata backend, so the above description (and the detail below) probably covers this just fine.
This should be ready to merge assuming |
Actually, I should also add some logic to populate |
Looking good! Just one last thing: do you want to include that API key in the default configuration? If so, perhaps we should mention that it's actually optional to register for your own Spotify app; you can just use the included key unless you really want to change it. If not, then maybe we should not provide a default to force people to register with Spotify themselves. |
Yea, that client ID/secret isn't actually valid (just randomly generated strings), so I agree we should either register a dedicated Spotify app and include those creds or remove them entirely and force people to register one themselves. I noticed the Discogs plugin sets a default client ID/secret which I'm assuming is for a dedicated app, so it seems like that's the preferred approach? Not sure if we would run into issues with rate limiting or anything else with many users sharing the same app. Which option do you prefer? |
Sounds good. Let's start by offering an "official" app key and revisit (i.e., reset the key and force people to register for their own apps) if it becomes a problem. Here are credentials for an app I just registered:
|
Awesome, I changed the default to those and removed all mentions of the Spotify app from the docs (or should we still include that it's optional?). This should be ready to merge now if everything else looks good. |
Looks perfect! I'll merge this now. |
Add Spotify OAuth support and autotagger integration
Addressing #2694, I've added OAuth support for the Spotify plugin using Client Credentials Flow. This requires a registered application and Client ID/Secret to be provided via
client_id
andclient_secret
under thespotify
options in config.yaml.I've also started working on adding Spotify support for the importer (incomplete
album_for_id
andtrack_for_id
funcs included in this PR with some logic copied from the Discogs plugin), since I've come across more than a few releases that don't exist in MusicBrainz/Discogs/Beatport/Bandcamp but do in Spotify. However, I realize that the Spotify API doesn't provide certain fields like albummedia
,catalognum
, etc. like these other beets sources do. So, @sampsyo, do you think it's still worth extending the autotagger with Spotify matches, despite offering incomplete metadata?