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
Use a DOM-injcted file for deezer.com for better data #1735
Use a DOM-injcted file for deezer.com for better data #1735
Conversation
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.
First up - good job - using internal API's can give more info and better stability ;)
Some comments - I'm not a deezer user so have unable to test
src/connectors/deezer-dom-inject.js
Outdated
} | ||
|
||
function lastfmifyArtists(item) { | ||
|
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.
Extra space
src/connectors/deezer-dom-inject.js
Outdated
} | ||
|
||
function getArtistsnamesByRole(item, roleId) { | ||
|
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.
Extra spacing
src/connectors/deezer-dom-inject.js
Outdated
return title; | ||
} | ||
|
||
let artists = getArtistsnamesByRole(item, '5'); // featured artists only |
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.
Could we define 0 and 5 as variables to give more context.
src/connectors/deezer-dom-inject.js
Outdated
.filter(removeDublicateArtists); | ||
} | ||
|
||
function removeDublicateArtists(artist, index, artists) { |
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.
Typo
src/connectors/deezer-dom-inject.js
Outdated
return item.ART_NAME; | ||
} | ||
|
||
return getArtistsList(artists); |
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.
Why call this? this returns a list right?
Thanks a lot for your feedback! I've removed the extra newlines, fixed the typo and added two constants for the values used by deezer to seperate main artists from featured artists.
The parameter is an array of artistnames and the return value is a string containing the artistnames in a list, example: ['Kilroy', 'John Doe', 'The Ramblers'] -> 'Kilroy, John Doe & The Ramblers' And, of course, it would be good to get agreement of other deezer users. |
Any other Deezer uses able to comment? |
I'm using the injected connector for several thousand scrobbles now with great success. But recently I've found some inconsistencies in the deezer API responses. First I implemented fixes/workarounds, but it was starting to get quite complicated and in the end I think it is not worth the hassle. My updated code is not longer trying to make sense of the featured artists information in the API response. It is now using the ART_NAME property which is a simple string. |
We can always iterate and your solution already looks much more elegant :) |
Thanks! |
After I'd adapted the deezer connector for the new layout some days ago I was not very happy with the result, so I have build this new connector which is using the internal (unofficial) deezer api. I believe this is better for various reasons:
Not DOM-dependent, it is working out of the box with the old and the new (... and future) page layout.
The internal api is stable since three years, probably longer.
More complete data as the albumname and the songId (used as uniqueId) are not available in the DOM but through the api.
The data provided by the api distinguishes between main artists and featured artists. When the old connector is submitting an ugly list of comma-seperated artistnames, the new connecter is building a more lastm-conform representation by adding the featured artists to the title. Examples:
old: https://www.last.fm/music/Tyler,+The+Creator,+Rex+Orange+County,+Anna+Of+The+North/_/Boredom (3899 scrobbles)
new: https://www.last.fm/music/Tyler,+the+Creator/_/Boredom+(feat.+Rex+Orange+County+&+Anna+Of+The+North) (12.9K scrobbles)
old: https://www.last.fm/music/Underworld,+Iggy+Pop/_/Bells+&+Circles (317 scrobbles)
new: https://www.last.fm/music/Underworld+&+Iggy+Pop/_/Bells+&+Circles (3664 scrobbles)
I'm using this for a week now and I'm very pleased with the results :-)
I'm not sure if the retry-loop in initConnector() is necessary, it was never executed so far. Maybe the core source is taking care that the page is ready before injecting?