Get playlist ID from youtube video - api

Is there any way to find playlist ID of youtube video using API, like through videoID? I looked into /playlistItems endpoint but I'm not sure where I can find the playlist item ID? I've tried to look this over everywhere but I'm at lost.

I looked a bit, and the only method I can find would be limited to your own playlists and playlists on the video's channel (or other channels that you specify):
Get the video ID
If you want to check playlists on the same channel, get the channel ID from the video (see https://developers.google.com/youtube/v3/docs/videos#resource)
Get the playlists you want to check (https://developers.google.com/youtube/v3/docs/playlists/list) - either your own playlists or playlists on
Loop through and get the items on each playlist (https://developers.google.com/youtube/v3/docs/playlistItems/list as you found)
Look for the playlist item that has the same video ID as the one you're examining (https://developers.google.com/youtube/v3/docs/playlistItems#resource)
It's a bit ugly, and limited of course - maybe someone else will share a better method with us.

An alternative could be:
Since you have the video_id, get the title of the video as well.
With the title of the video, use the search:list endpoint for search playlists that matches with the query/criteria - that is, the title of the video.
Loop the results from the search request and use the code I show in my answer for check if the video_id is on the playlist.
Example:
video_id: eJjbnFZ6yA8
title: FULL MATCH - The Rock vs. Mankind – WWE Championship Match: Raw, Jan. 4, 1999
Make search to get playlists that matches the search term: "FULL MATCH - The Rock vs. Mankind – WWE Championship Match: Raw, Jan. 4, 1999"
URL:
https://youtube.googleapis.com/youtube/v3/search?part=id%2Csnippet&maxResults=50&q=FULL%20MATCH%20-%20The%20Rock%20vs.%20Mankind%20%E2%80%93%20WWE%20Championship%20Match%3A%20Raw%2C%20Jan.%204%2C%201999&type=playlist&key=[YOUR_API_KEY]
Try-it here
From the results of the search, get the playlist - for this example I took the first result I got from the search, then, I check if the video_id eJjbnFZ6yA8 is on the playlist PLAamU2iv-fSuxZrVqQIBcrrZMTCMbBt2W
URL:
https://youtube.googleapis.com/youtube/v3/playlistItems?part=id%2Csnippet&playlistId=PLAamU2iv-fSuxZrVqQIBcrrZMTCMbBt2W&videoId=eJjbnFZ6yA8&key=[YOUR_API_KEY]
Try-it here for check the results.
Keep in mind that the search:list endpoint consumes 100 quota points, so, the quota might be drain rather quickly - depending of the intensity of the search.

Related

Youtube API channel search - how to get channel ids by using video ids

I am using the Youtube API for a simple search for music in a specific genre. In the results set I get only videos ids and the part with channel ids is empty. Is there any way to generate/get the channel ids from the retrieved videos?
I have tried to look only for channels, but the result set is either completely emtpy or contains 1-2 results.
youtube.search().list(q = query,
part = "id",
#type = 'channel, video',
maxResults = max_results).execute()
I would like to get both videos and channel ids and currently I am receiving only a list of videos that match with the search query.
Yes, just request the 'snippet' part as well. The snippet section contains the channelId of the video.

Search iTunes by artist and song title

I found that I can search for a song term like so:
https://itunes.apple.com/search?media=music&entity=musicTrack&attribute=songTerm&term=xxxx
But what I really want to do is search by song title and the artist. I can't seem to find syntax that would allow for that. Is it possible? I'm doing this from inside an iOS audio streaming application so I want to keep the returned results as small as possible so as to not use up much of a person's data plan.
Basically itunes search api sucks, a lot.
I was trying to do the same, but there isn't a direct way to search by song and artist, it searches both, and if your user misspelled the name of the song or the artist, the search can give you bad results.
So my solution was basically use a prefilter first to correct that, using echonest, to search by artist name and song name, then show a dropdown (you can choose other method like "Do you mean: ...?" with links to correct url for search) and then use what Fahad says, putting first the name of the artist and then the name of the song. Don't forget to encode those.
There are a few ways of doing this, the simplest would be something like
https://itunes.apple.com/search?term=slipknot+duality
For further information regarding the iTunes Search API
you can concatinate artist name and song title using + sign inplace of space between those words as given below:
https://itunes.apple.com/search?term=the+beatles+let+it+be
in the above url "the beatles" is the artist name and "let it be" is the track name.
That's it your done.

Soundcloud API bug when filtering one user's tracks

I'm trying to filter a single SoundCloud user's tracks with a query (or even a tags/genre filter). I can get a user's tracks, but as soon as I add a query parameter, it returns all sound cloud users tracks.
This doesn't work:
SC.get('/users/00001/tracks', {q: 'Black Night'}, function(tracks) {
// returns tracks from all soundcloud users which contain 'Black Night'
// rather than the single user
});
Nor does this:
SC.get('/tracks', {user_id: '00001', q: 'Black Night'}, function(tracks) {
// returns tracks from all soundcloud users which contain 'Black Night'
// rather than the single user
});
You would first get all the songs by that specific user, for that you can use the code you used.
After that, you need to loop through all the songs you just retrieved and assign tracks[i].genre to a variable (let's say var track_genre)
Next, check if track_genre === myGenre (a parameter you give the function, which the user can choose)
If it's the case, go ahead and oEmbed the widget
I guess the main takeaway would be that you CAN access the genre of the songs you retrieved with 'SC.get' and filter on that, but you CANNOT SC.get specific genres FROM a specific user.
Anyway, that's how I just gotten around this particular problem; I'm sure there'd be better solutions, but this one works so... ;-)
soundcloud api does not work that way.
you can search All tracks by term, genre, bpm, date etc
or you can get user resources (tracks, favorites, groups, followers etc)
the best way to search inside tracks or any other user resource, is to get all results, and do the search inside the results.
Here under Subresources you can find /users/{id}/tracks - list of tracks of the user

Instagram tag search - filter for images and tags after a certain time or id

I am using the Instagram API to fetch a list of photos tagged with a certain hashtag. I've got a real-time subscription set up so it will notify me whenever new photos have been posted. However, I have to fetch the new results myself.
My problem: When I request the list of recently tagged photos, I get a large list and I don't want to process all of the results in the recent list every time I do this. The api docs say I can pass these optional parameters, but they seem counter-intuitive. They seem to be the opposite of what I would expect:
MIN_ID Return media before this min_id.
MAX_ID Return media after this max_id.
If I keep track of the most recent media id I've seen in my recent requests, how do I construct my next request to only return results newer than that id?
I've posted two photos with a test hashtag. When I use the following url (with my real access_token in it), I get back a json response listing both of those photos:
https://api.instagram.com/v1/tags/weirdtest/media/recent?access_token=xxx
The two photos have these ids:
221201236060507271_179249322
221190263853517857_179249322
How do I construct a query that returns only the newer of those two photos?
Tack the most recent ID you've seen on the end, using the MAX_ID request parameter:
https://api.instagram.com/v1/tags/weirdtest/media/recent?access_token=xxx&MAX_ID=221201236060507271_179249322
This should tell Instagram, *"The most recent photo I've seen is 221201236060507271_179249322, return only newer photos"*.

Accessing Flixster data

Is there any way of accessing the data on Flixster? Specifically, I'd like to retrieve a list of all of my movie ratings. I know you can get an rss feed of these, but it only appears to return a subset of all of the ratings.
View your Rotten Tomatoes / Flixster movie ratings by accessing this URL, first replacing USERIDHERE in the URL.
http://community.flixster.com/api/v1/users/USERIDHERE/ratings.rss
You can find out your user id by clicking to view your Profile, which will contain your unique id in the URL, such as:
http://www.flixster.com/user/USERIDHERE/
Yes, there is a new-ish Rotten-Tomatoes API at http://developer.rottentomatoes.com/docs/read/json/v10/Movie_Reviews
Here's a simple program, using the API, that I've found:
https://github.com/mmihaljevic/flixter
...and you can read her blog post for more information.
Just tested both fetching and parsing, and it still appears to work.