-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Last.fm support #196
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
Last.fm support #196
Conversation
currently only played songs are added
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.
Looks good, thanks for the contribution! Left a few minor comments, feel free to address them, otherwise I'm ok to merge and do a follow up! (note: recent merges have created conflicts)
plugins/last-fm/back.js
Outdated
| const queryData = []; | ||
| params.api_sig = api_sig; | ||
| for (key in params) { | ||
| queryData.push(`${key}=${params[key]}`); |
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.
To avoid issues:
| queryData.push(`${key}=${params[key]}`); | |
| queryData.push(`${encodeURIComponent(key)}=${encodeURIComponent (params[key])}`); |
plugins/last-fm/back.js
Outdated
| const cleanupArtistName = (config, artist) => { | ||
| // removes the suffixes of the artist name for more recognition by last.fm | ||
| let { suffixesToRemove } = config; | ||
| if (suffixesToRemove === undefined) { |
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.
nit: it does not seem necessary to override the suffixes if not defined, we can just return early:
| if (suffixesToRemove === undefined) { | |
| if (suffixesToRemove === undefined) { | |
| return artist; | |
| } |
plugins/last-fm/back.js
Outdated
| duration: songInfo.songDuration, | ||
| }; | ||
| data.api_sig = createApiSig(data, config.secret); | ||
| axios.post('https://ws.audioscrobbler.com/2.0/', createFormData(data)) |
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.
nit: node-fetch is already there and could be used (but axios is well-known and widely used so no big deal and no need to change it)
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.
Ah, didn't know you could post data with node-fetch, removed axios, because there is no need for an extra dependency :)
plugins/last-fm/back.js
Outdated
| duration: songInfo.songDuration, | ||
| }; | ||
| data.api_sig = createApiSig(data, config.secret); | ||
| axios.post('https://ws.audioscrobbler.com/2.0/', createFormData(data)) |
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.
Code looks mostly the same as addScrobble so it could probably be refactored with a util function.
|
Thanks for your feedback, I have done some additional refactoring and solved the merge conflicts. |
th-ch
left a comment
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.
Code looks good, thanks for the contribution! Merging so that it can ship in the next version, will also update the yarn.lock file!
| resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" | ||
| integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== | ||
|
|
||
| axios@^0.21.1: |
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.
Not a big deal but it seems the lock file is not up-to-date (axios is not used anymore), yarn will need to be run on the project to update it!
|
any chance to see the lastfm plugin, in the ytm App? |
This adds a last.fm plugin with the following features,
When the plugin is enabled for the first time, it should ask the user to authenticate with last.fm and give permissions to YouTube music.