YouTube has this cool thing that creates a "smart playlist" from some starting keywords. I would like to programmatically access the playlist. I've found the YouTube data API but it doesn't discuss the "disco" feature.
One of the answers below suggests using
http://www.youtube.com/disco?action_search=1&query=XXXXXXXXX
that will return some JSON with the first video to be played, and a list property. Unfortunately, the list is a 32-character hex string, whereas normal playlist ID's are 16-character hex strings. This means that the standard data API to retrieve the full playlist doesn't work.
Any suggestions?
First, I must say I I never used youtube data API, so I don't know how useful below information will be.
Let me use an example:
I wanted to create Smashing Pumpkins. I typed the artist name and clicked the "Disco!" button. Using Fiddler2 I figured out the requested url was:
www.youtube.com/disco?action_search=1&query=smashing%20pumpkins
Notice, that spaces are replaced with %20. As a response i got simple JSON response:
{"url": "\/watch?v=bhMz7x1ZaGM\u0026feature=disco\u0026playnext=1\u0026list=MLGxdCwVVULXe5-F4X_zm6wnblRsnXoPJS"}
It was a link to the first song of freshly generated Smashing Pumpkins playlist, which address was list=MLGxdCwVVULXe5-F4X_zm6wnblRsnXoPJS. All you have to do know is replacing \u0026 with & and you get a valid link.
I assume the rest magic you want to do is available via official youtube data API.
I hope my research will help you.
EDIT
Well, it looks like this playlist generated by youtube/disco is not the same type of playlist that users can generate and that is available via API. The list ID is longer than usuall and when you click "More info about playlist" you are redirected to artists profile. Based on this two facts, i guess it's impossible to retrive generated lists via API. Sorry.
#Randomblue, how exactly do you want to retrieve this playlist?
You can use the 32 char hex in this url to get a page detailing the playlist
https://www.youtube.com/playlist?list={HEX}
or in an embed playlist iframe, like this:
<iframe width="853" height="480" src="//www.youtube.com/embed/videoseries?list={HEX}" frameborder="0" allowfullscreen></iframe>
Related
Does anyone know how this website is able to get historical views data for YouTube playlists?
From my research, YouTube API doesn't even let you get the current playlist views (I might be wrong).
I am talking about the playlist views, not the views from videos that were added to the playlist (you can see the view count here for example, on the left side - on desktop).
How can we get access to this type of data?
One more time YouTube Data API v3 doesn't provide a basic feature.
I would recommend you to use my open-source YouTube operational API. Indeed by requesting the JSON document https://yt.lemnoslife.com/playlists?part=statistics&id=PLAYLIST_ID containing item["statistics"]["viewCount"] integer, your problem is solved.
You can request up to maxResults (currently 50) playlists separating playlist ids by a comma in id, example: https://yt.lemnoslife.com/playlists?part=statistics&id=PLAYLIST_ID_0,PLAYLIST_ID_1,...,PLAYLIST_ID_49
You can also request the title of the playlist by adding snippet to part, example: https://yt.lemnoslife.com/playlists?part=snippet,statistics&id=PLAYLIST_ID
I want to automatically embed my recently uploaded video from my YouTube channel in the sidebar of my website.
I got a good answer but it include user id they asked for
youtube.com/user/SomeName but in my case, it's like youtube.com/CHANNEL/name. I tried replacing "SomeName" with my channel id, but it didn't work for me
Thanks everyone for your answer. I found a pretty easy way to do this
All you need is id for your upload playlist and to find that visit google API explorer
Services > YouTube Data API v3 > youtube.channels.list
fill in the part section with "contentDetails"
and id section with youtube channel id (the one starts with UC)
scroll down and click on execute
you will find
"uploads": "UUIprTMT-TDysEDx03YMcS5Q",
in ** "relatedPlaylists"** section
copy that tag and now use this code to embed
<div style="position:relative;height:0;padding-bottom:56.25%"><iframe src="https://www.youtube.com/embed/videoseries?list=YOUR_UPLOAD_TAG" width="640" height="360" frameborder="0" style="position:absolute;width:100%;height:100%;left:0" allowfullscreen></iframe></div>
Test on fiddle
And you are done :)
You can embed youtube channels or playlists, as said here:
https://stackoverflow.com/a/30089630/7733026
Here is how to embed a channel
<iframe width="600" height="340" src="http://www.youtube.com/embed?max-results=1&controls=0&showinfo=0&rel=0&listType=user_uploads&list=YOUR_CHANNEL_NAME_HERE" frameborder="0" allowfullscreen></iframe>
To get your channel name click "My Channel" and its the line of text
after "/user/".
You can also embed playlists with this:
<iframe width="600" height="340" src="https://www.youtube.com/embed/+lastest?list=PLAYLIST_ID" frameborder="0" allowfullscreen></iframe>
Firstly, many options have been removed from the API from V2 to V3.
A few things still remain, but are not going to help unless you know that it will be used.
One is the user name. Legacy Usernames are still around for channels that are old enough, but newer ones will not have them.
This is normally the Title of the page, but the title can now be changed.
This is where the ID's come into it. Everyone has a unique ID, but can have the same Tile as another page. (even if confusing some times)
Example of an old channel is Google
https://www.youtube.com/user/Google
The "user" name is a Legacy name.
But all channels old and new will have a "Channel" as well
https://www.youtube.com/channel/UCK8sQmJBp8GCxrOtXWBpyEA
Note that it will give you an ID rather than a name.
So to get you what you are looking for, will need to be thought through.
Will the channel have a legacy user name? Do you need to show a name? or do you only want to find the last uploaded video regardless of name?
Best practice today will be to use the ID. Then with the API, get the relevant information that you need.
Step one is to call
https://www.googleapis.com/youtube/v3/channels?part=contentDetails,id,snippet&id=[THE_CHANNEL_ID]&key=[apiKey]
The contentDetails section will contain an uploads portion.
This will be the user uploads to the channel and will start with UU
Though a short cut will be to take the channel ID starting with UC and change it to UU. But I would recommend the API approach for security and peace of mind.
Then with the uploads playlist ID (the one starting with UU), you can call
https://www.googleapis.com/youtube/v3/playlistItems?part=id,snippet,contentDetails&maxResults=1&playlistId=[PLAYLIST_ID]&key=[api-key]
Normally the first in the array will be the last one in. The newest one. So setting results to 1 will give only the first in the array.
If you want to do further checks to make sure, then set results to 50 and use the contentDetails to dig the uploaded time of the video and select the newest that way.
We're successfully using the Youtube API to create a metadata-and-url xml feed that the GSA requires and pushing it to our Google Search Appliance according to the documentation
The question that we have is that we know you need to put a start url in the Content Sources > Web Crawl > Start and Block URLs page in the Admin Console. If we put in https://www.youtube.com as a start url and a follow pattern of https://www.youtube.com/watch?v=* (which all looks like all youtube videos follow) will the GSA only index whats coming from the feed or will it go out to youtube.com and index a bunch of content that isn't part of our channel? I don't see anywhere you can specify a channel for a video.
FYI, we are aware of FishBowlSolutions connector for YouTube but trying to avoid spinning up another server with TomCat just to index our YouTube videos.
You should not add the youtube-url to your Start URLs, only to your Follow Patterns. That way, the crawler will not crawl Youtube from top to bottom, but the URLs you provide in the feed will be crawled. However, if GSA finds URLs on the crawled pages, it will obviously also crawl those.
An option is to tighten the Follow Patterns. And of course you can develop a Youtube connector on Googles Adaptor Framework, which is not that hard for Java-developers!
Google CSE Search
YouTube User Panel
I haven't used GSA(I'm getting ramped up on it though, which is how I found your post), but the way I've accomplished this using Google's CSE is to index the channel, user or playlist specifically, vs. youtube in general, i.e.:
youtube dot com/user/alltrapmusic
or: youtube dot com/channel/UC_ahy2GUec7EmbWF3LGxLhQ
or: youtube dot com/playlist?list=PLsHnWFR4n5jBFYdsclaKtdWQtf2Iu8bKZ
So, in CSE, I can configure to search only that user, channel and playlist and return only results found on those three (Google CSE Search link).
I can only assume GSA works the same(as I mentioned, I have no experience with GSA); if not, my apologies.
~chipleh
p.s. - in order to find your youtube channel, go to the user link(YouTube User Panel link); there you'll find home, videos, playlists, channels, etc. Hope that helps.
For anyone else looking to use the Youtube api and push their videos to the GSA, we found that there needs to be a few changes to the feed.
The feedtype needs to be full in the xml.This tells the GSA that everything it needs to know about the content is in the xml and it doesn't need to go out and index a url.
You need to have a <content> node in the xml. We used the description coming from Youtube api as the value. This is what is displayed to the user in the search results
url attribute on the record needs to be a value that can be added to the Start and Block URL and Follow patterns in the GSA settings and it needs to be unique. These actually don't need to exist but the GSA will use this value in the xml to determine if it should be included in the index. We used a fake url and the value from Youtube video ID appended to make it unique
displayurl attribute will be the url that will be displayed in the results so it would have the actual youtube url.
Start and Block URLs should contain the general url attribute value. For us, it was the fake directory http://www.yourdomain.com/video/youtube/
Follow Pattern should contain the pattern to follow that also matches the Start URL. Since we only have videos in that directory, we're able to put the same value as the Start URL. If you are pointing to a real directory and have other content in that that you don't want to index, you may need to add whatever pattern is common to your videos.
A sample record is below. Once we updated our feed, added the Start and Block URLs, our videos appear in our search results.
<gsafeed>
<header>
<datasource>youtube</datasource>
<feedtype>full</feedtype>
</header>
<group action="add">
<record url="http://www.yourdomain.com/video/youtube/?VIDEOID" displayurl="https://www.youtube.com/watch?v=VIDEOID" mimetype="text/html">
<content><![CDATA[DESCRIPTION]]></content>
<metadata>
<meta name="Title" content="TITLE OF VIDEO"></meta>
<meta name="Published" content="2016-08-15T22:00:38.000Z"></meta>
<meta name="PhotoURL" content="https://i.ytimg.com/.."></meta>
</metadata>
</record>
</group>
</gsafeed>
In the new YouTube Google + comments system how can I retrieve comments that contain links.
For example if someone posts a link to another youtube video as follows:
http://www.youtube.com/watch?v=AZNHuFjnmUo
This gets converted to a link by the google plus system. The title of the video is shown as the text rather that the url. i.e. The html shown within the comments is this:
Francis HATES Google+
However the api for that comment only returns the title of the video which is pretty useless seeing as I want to get the link too. I am guessing that the system converts the url into an <a> tag which is stored in the database but then the api strips out the html when its requested so it only returns the videos title.
I have posted a defect here:
https://code.google.com/p/gdata-issues/issues/detail?id=5500
But that bug list seems to have very little activity going on in terms of responses to issues.
So is there another way to get the data I need?
What you can do while this bug remains is to extract the comment id and use it in the Google+ API with an activities.get request. This will return the full post with all links.
A bit cumbersome since it needs one request for each comment you want to check, but it seems to be the only way while the bug remains.
To take an example from the video you linked in the issue:
This YouTube comment returned by the API includes a YouTube link:
http://gdata.youtube.com/feeds/api/videos/rgkDKeSc-1o
/comments/z12hvvcgxznkufyo304ci1iqlnandzxjpes
You can use the z... ID in a request to the Google+ API:
https://developers.google.com/apis-explorer/#p/plus/v1/plus.activities.get?activityId=z12hvvcgxznkufyo304ci1iqlnandzxjpes
Which includes the full post including links.
Is it possible to find the context of a video in respect to any playlist that it is included in? I would like to be able to check if the videoEntry is included in a playlist and, if so, figure out the next video in the playlist.
Flickr has a lot of great photo context methods, I hope YouTube does too, I just can't find anything on it.
Well, obviously you want to know the VideoId of the video in question first, right? So say it's "4eUibFQKJqI" and it's in a playlist whose Id is "6C0464B5CC81A607" (You can easily get those Ids from your 'My Account' section in YouTube).
If I get the feed for that playlist, then the resulting xml file gives you all the information you need to check if that Video is present, and the order that you have set in 'My Account' is preserved.
So, you have two ways of analysing the results that YouTube sends you. One is to make a request to that playlist address and parsing the results using Linq-to-Sql, if you use Asp.Net, for example. Whatever language you use, it will have Xml-parsing capabilities, so it's just a case of iterating through the entries in the feed.
If you use a library for your language, it may well have a specific method to determine whether a given video is in a given playlist, but if it doesn't, it's pretty easy to query the raw xml file and get that information, as described above.
Hope that helps - it's hard to tell from your question what level you're at with this stuff... Anyway, it's all at the Developers' Guide.
http://gdata.youtube.com/feeds/api/playlists/PLAYLIST_ID?v=2
from http://code.google.com/apis/youtube/2.0/reference.html