mirror of
https://github.com/jwilsson/spotify-web-api-php.git
synced 2026-04-27 07:55:49 +03:00
[GH-ISSUE #227] Query about dealing with sort-of duplicates returned by getArtistAlbums #161
Labels
No labels
bug
docs
enhancement
enhancement
enhancement
feedback wanted
good first issue
help wanted
help wanted
help wanted
invalid
pull-request
question
question
upstream
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotify-web-api-php#161
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Apr 4, 2021).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/227
Hi Jonathan,
I hope you're well.
This isn't so much an issue, but more of a query asking for coding advice, so I understand if you confirm you can't help since I am asking about something unrelated to your PHP wrapper.
I am using the API like this:
The
hrefvalue returned by the API is this:https://api.spotify.com/v1/artists/5yO8MmDV2hnMbiIoZGZMGr/albums?offset=0&limit=50&include_groups=appears_on&market=GBThe API doesn't return exact duplicates, but it does return the same album names twice, such as:
For each pair of albums returned, with the same name, some of the attributes are different, such as:
However, various attributes are the same for each pair, e.g.
I'd like to work out how to strip out the sort-of duplicates, but I realise they're not exactly duplicates, but if records returned have the same name, release_date, total_tracks and artists, then, maybe use that as a way to identify duplicates, and then somehow strip out the "duplicate" record, though how to work out which of the pair is the duplicate is tricky!
Also, given the above example, would it be possible to then remove the duplicates so that instead of the
totalrecord value returned by the API being 11, the actual record, minus "duplicates" would be 6.I realise that's asking a lot, but if you have any time or advice or pointers to provide guidance please, it'd be much appreciated.
Thank you!
Jim
@jwilsson commented on GitHub (Apr 5, 2021):
Hey Jim!
Thanks! I trust you're doing well too.
Like you're saying, it not really related to the API wrapper but it was a fun challenge to figure out so I decided to take a stab at it :)
I think this should work, it might not be the fastest solution but it should get the job done:
If you have any other more general PHP/programming questions, hit me up at my email. It's in my profile.
Cheers,
Jonathan
@ghost commented on GitHub (Apr 5, 2021):
Hi Jonathan. I'm doing very well, thank you :-)
Wow - that works like a charm - thank you very much indeed for taking the time to solve that challenge.
Hopefully some time in the next 20 years I'll finish this hobby project I'm working on and can send you the link once it's live.
Thanks again, and I'll email next time if I have a PHP / programming question.
Jim