Spotify web-api, how to distinguish between album and single - spotify

When using the Spotify web-api to get the albums from an artist, the list of albums is very large. The list contains both Albums as Singles. Is there a way to separate them?
For example:
http://ws.spotify.com/lookup/1/?uri=spotify:artist:6VSZeMeJlVPGoR2nfB6UxD&extras=album returns the following albums:
- Born In A Storm
- You Don't Have To Stay
- Blind Man’s Bluff
- Multicoloured Angels
- Multicoloured Angels
When you open the artist in the Spotify client via spotify:artist:6VSZeMeJlVPGoR2nfB6UxD you'll see that only the first result is an actual album and the rest are just singles.

There's currently no data exposed in the Web API which would solve your problem.

Related

Google Photos API - media items without albums

I like Google Photos but I've noticed that it is lacking some basic metrics like how many media items are in my account. Also I wanted to see which of my media items are not included in any of my albums. I ended up creating a simple console app using Google Photos REST API. It uses GET /albums, then POST /mediaItems:search?albumId={id} to get each album's media items and then cross references them with a full list of media items returned by GET /mediaItems.
It worked reasonably well however I've noticed a problem with the shared items. For a shared album owned by account A, if a media item is added from another account B then its id won't be found in the list of the media items of the account A (which is not unreasonable). If such a shared media item is saved in account A its id won't match the id of the original shared media item added to the shared album (returned by POST /mediaItems:search?albumId={id}). W/out an indicator of some sort to identify if a media item belongs to another account it's challenging to filter them out. I expected to see the contributorInfo as part of the MediaItem but that attribute is not returned.
If I try to add a saved copy of the same shared item into an album using UI I get a notification message that it's already there so obviously Google Photos UI does have that info. Does anyone have any clever ideas on how to match a saved copy of a shared media item with the original? The code is available at https://github.com/pavelfomin/gphoto-manager
I ended up using ignore media items list in https://github.com/pavelfomin/gphoto-manager that I populate locally with the media items I want to ignore:
Usage: com.droidablebee.gphoto.GooglePhotoApplication [options] -token=<access token> [-Dsuppress-warnings] [-Dignore-media-items-file=<file with media items to ignore>]
--albums list all albums, sorted by name
--album-items list all items per album (use with care for large number of media items)
--items list all items (use with care for large number of media items)
--items-no-album list all items not included in any album
<access token> OAuth 2 Access Token can be obtained from https://developers.google.com/oauthplayground
use 'https://www.googleapis.com/auth/photoslibrary.readonly' as the requested scope
suppress-warnings suppress all warnings, including album media count / items mismatch
Ideally, I'd use Google Photos REST API to filter out the shared items but that does not seem to be possible at the moment.

flickr api: how to know which albums the image belong to

I am getting a list of photos using
https://api.flickr.com/services/rest/?method=flickr.photos.search
It gives a json with an array of photos.
I also want to know to which albume each photo belong to (if at all)
Because when i open https://www.flickr.com/photos/147875968#N08/44811952245/in/photostream/#hare it shows This photo is in 1 album and says Yellow Cat
Similary is there any way to know which albums this photo is in
I believe that you can use flickr.photos.getAllContexts to find the photosets to which a photo belongs.

Spotify - How to create a playlist including certain albums from an artist

The objective: I Really love discovering music so I am trying to create a playlist to discover more songs from artists a user already likes (because you know, sometimes we just add a song or two from an artist and don´t take the time to explore the rest of his/her work).
The project: copying my Spotify songs in a simple Excel doc. I am able to determine the following:
Name of the artists from which I only have 1 song
Name of the artists from which I have
between 2 and 4 songs
Name of the artists from which I have 5 or more songs
Now, based on these results/inputs I would like to create the following playlists:
"If I only have 1 song from an artist = Create a playlist with his TOP10"
"If I have between 2 and 4 songs from an artist = Create a playlist with his TOP10 and all albums these songs are from"
"If I have 5 or more songs from an artist = Create a playlist with all songs from this artist"
Is there a way to do so?
Thanks!
For your number 2, "If I have between 2 and 4 songs from an artist = Create a playlist with his TOP10 and all albums these songs are from", you'll have to do many API calls but it's pretty easy to do :
Once you have your artist id (you'll find it with this endpoint "GET https://api.spotify.com/v1/search?q={artist_name}&type=artist")
You can ask for its top ten tracks with the endpoint "GET https://api.spotify.com/v1/artists/{id}/top-tracks"
Now you have your tracks object, you can get their album id, and get Album's Tracks using this endpoint "GET https://api.spotify.com/v1/albums/{id}/tracks"
I hope it'll help you!
I'm not entirely sure if you're tied to excel, but based on this question I don't know how much research you have personally done.
To start with I would direct you to Spotify's API.
As far as implementation goes, you might want to look at using a scope to read a user's music, I would use the user-library-read one.
You could then proceed to examine the library as you've detailed above and add or replace its tracks.
Spotify's API should have any further information you need if you want to implement this.

libspotify: Duplicate search result for a given artist and album

I noticed the search result may return multiple albums for a given artist and album, and the albums have the same release year. For example, the search of artist:"Foster The People" album:Torches returns 5 albums, and 4 of them look same (same release year, same album name, same artist, and same tracks of the album) although album uri is different. Can I assume the 1st (top) one is always the most recently added or released?
Thanks,
Probably not. However, order and date added isn't relevant as long as the release year is the same.
You should check the results to see how many tracks are available to the user in each version of the album, as it can vary by region and will often vary by URI. What often happens in our catalog is that multiple versions of the same album are released to different territories but will still show up in search results.
To sum up:
Order isn't important.
You should show the user the album which has most available tracks.
You can see this in our own desktop client too. If you view the artist Rihanna in the client, you'll see a little arrow button just after the title of the album "Talk That Talk". If you click that, you'll see all of the releases of that album on Spotify. The client, by default, will only show you the one which has most available tracks.

Spotify API returns too many albums when browsing an artist

After calling sp_artistbrowse_create, and making sure it's completely loaded, I try to retrieve all of the albums by this specified artist, but it seems that those albums are not grouped properly, since I get multiple album objects with the same name. For instance, if I browse David Guetta in the Top Artists list, I get over 600 albums, most of them share the name.
Is this the correct behavior? If it is, is there an attribute I can further group by to get the real listing of that artist's albums?
Check the sp_album_type() of the albums - a lot will be singles or "appears on" albums. Also check sp_album_is_available() to see if an album is actually available.

Resources