Find the playlists a video is in via Youtube API - api

I want to know which playlists contain a certain video. The opposite is easy: find which video's are in a playlist, but I don't want that.
I can already have YT do this via the following route, but that's stupid and slow:
get channelId from video data (videos?id=...)
get playlists from channelId (playlists?channelId=...)
loop through all playlists and find all their videos (playlistItems?playlistId=...)
Like I said: stupid and slow. These steps are possible, because I only want playlists authored by the video's author. (Otherwise I'd have to download all of YT.)
What I'm looking for, sort of, is a request: playlists?videoId=..., but of course that doesn't exist.
Is there a better way than my 3 steps?
PS. I've created the script to use my 3 steps, but it's A LOT of requests. That and the playlists don't seem to have usable playlist ID's... I need the ID that the browser uses to show the playlist GUI style.

As of now, the Youtube API does not support a call like this, and in my opinion never will. This is probably an intentional decision by Youtube to hide the playlists, even the YT Analytics API doesn't show how many lists use your video.
It seems the way you do it is the only workaround - in case you only need the playlists for one specific user.

Related

Youtube API getting Watch Later Playlist

as in one answer here:
Youtube Data API v3 PlaylistItems update not working for Watch Later playlists
There was a change that I can't use playlistitems.list from YT API v3 to retrive Watch Later and Watch History playlists from my channel:
https://developers.google.com/youtube/v3/revision_history#september-15-2016
TLDR:
"Requests to retrieve playlist details (playlists.list) for a channel's watch history or watch later playlist will return an empty list after September 12, 2016. Requests to retrieve playlist items (playlistItems.list) in either of those playlists will also return an empty list after that time. This is true for the new values, HL and WL, as well as for any watch history or watch later playlist IDs that your API Client may have already stored."
Is there any other way to programmatically get my Watch Later playlist other than manual scraping?
(By manual scraping I mean traversing http to login, getting into my playlist and manually parsing DOM to get links and snippets of videos in the list.)
Thanks
(Copied from here: https://stackoverflow.com/a/47117301/147507)
If I was in your position, I'd just work my requirement around it, avoiding this. You can go back to v2 or do some other stuff like scraping the website, but if the YouTube API is explicitly preventing these to be available to third parties, it might seem you could get into legal trouble.
Note that the v2 API provided separate feeds for a channel's favorite
videos, watch history, and watch later playlist. The v3 API uses
playlists and playlist items to represent all of these concepts.
From: https://developers.google.com/youtube/v3/guides/implementation/playlists
You also use the channels.list method to get the playlist IDs for a
channel's watch history playlist, watch later playlist, uploaded
videos and liked videos. Liked videos are videos that the channel
owner rated positively

YouTube search API for videos in a specific channel often gives no results

I'm using the YouTube search.list API to look for all videos on a specific channel:
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&channelId=my-channel-id&key=my-public-key
(I can't give specifics due to privacy I'm afraid.)
So this works well for common YouTube channels, but only sometimes works for certain personal ones, often returning no results.
What happens with personal ones is: the first call you make returns the videos, but if you refresh the browser it returns with no results (but no errors either).
I found these two live issues regarding inconsistent search results, but my problem seems a bit different (no query, just a specific channel ID).
Any idea what's going on? I can't find differences between the channels that return results consistently and those that don't. It's almost as if Google is throttling certain search results. The same thing happens if I'm authorised rather than using a public key.
An alternative approach to getting all of the videos in a channel (ideally in a single call) would also be acceptable.
So to answer my own question, you can use the activities.list API to get all videos in a channel, which seems more reliable than search:
https://www.googleapis.com/youtube/v3/activities?part=snippet%2CcontentDetails&channelId=my-channel-id&key=my-public-key
You need to include the 'contentDetails' part as it contains the video ID.
Update
Another way is to use the "uploads" playlist (see this SO answer). This is better than activities, as activities include things other than video uploads, and the API doesn't provide a way to filter.
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=my-uploads-playlist-id&key=my-public-key

Retrieve spotify album covers of currently played songs

Hej,
I'd like to retrieve the cover artworks of my current listenings and put it in a way like this:
[http://codepen.io/motorlatitude/pen/hipIl][1]
I found a couple of solution on how to get the album covers in general, but not for my recent listenings only.
Thanks! :)
The Spotify Web API has an endpoint for returning the cover artwork of a given album, see the images property in the information return in Get Album.
However, Spotify doesn't expose recent listenings, so you'll need to get that information somehow. Some people use Last.FM API, that can give you this information if you scrobble to Last.fm from Spotify or any music player.

Can I retrieve Youtube playlist views through the Youtube API?

I asked in this question how to see how many views a Youtube playlist has. Unfortunately, it has been removed from the UI. Can I retrieve Youtube playlist views through the Youtube API?
For now, I think, there is no way to get round it in API requests. According to YouTube's Playlist Documentation, it does not provide a statistics parameter which is responsible for providing various stats about videos. I was also looking for a similar use case and I came across this question. Maybe someone else can find a (hackable-)way along the way.

Vimeo - videos.getChannels

How can I efficiently retrieve a list of channels that a Vimeo video is listed in from the Advanced Vimeo API?
The Advanced Vimeo API provides the methods channels.addVideo and channels.removeVideo for managing the channels a video belongs to. Also, the channels.getVideos method is provided for retrieving the list of videos belonging to a channel.
However, there is no videos.getChannels method. This means that in order to find all the channels a video is included in one would need to call channels.getVideos (possibly more than once if the channel has more than 50 videos) for each channel of interest. This seems terribly inefficient.
From what I have seen so far it has not been implemented into v1, but will be added into v2. I am still looking to see if there is an alternative
edit*
take a look at this page because they have this method vimeo.channels.getAll
VIMEO
I know this will get you a list of channels, from there I dont know if you can compare that to the video to make a list of channels that the video is in. I'm still looking.