I've noticed normal channel IDs have "UC" at the start while automatically generated ones have "HC". Normal playlists have "PL" but special ones, like uploaded or favourite videos, have "UU" and "FL", which however doesn't apply to autogenerated channels, they have "LP". That's what I've found so far. Is there any list of all these prefixes with their meaning?
Edit: Playlists based on a specific video begin with "RD"+the video ID.
There is not a guideline and they may always change. I strongly suggest not to depend on them but the pure API methods.
Related
I've recently made a Python program using the Youtube api v3 where, given a playlist id, it fetches certain information from every video in the playlist. However, through both the output of this code and this post on Google, it's pretty clear that information on videos that were either privated or deleted is not available through the Youtube api.
Is there an alternative program or resource that I can use to extract information from these unavailable videos, in particular their video ids?
The only solution I can think of now is to access the HTML of the display Youtube and search through it for certain strings (like "[deleted video]") and to then extract the id corresponding to that string. But, I've never dealt with HTML and, if I understand HTML correctly, I'd have to load a new page for every 50 videos in the playlist, which for playlists with thousands of videos, becomes rather inefficient and laborious.
I was hoping to use something like PyTube, but that couldn't handle unavailable videos either.
Edit
Here is the code that extracts the video ids:
from googleapiclient.discovery import build
api_key = "AI~~~" #get from yt (private key)
yt = build("youtube", "v3", developerKey = api_key)
plst_id = "PLorw3mfu-J0ipF4Ss0XgR8IxcwP-JzNKC" #unique yt playlist id
plst_req = yt.playlistItems().list( #request for info from yt api
part = "contentDetails",
playlistId = plst_id,
maxResults = 50
)
plst = plst_req.execute()
vid_ids = [] #available video ids taken from current playlist
for vid in plst['items']:
vid_ids.append(vid['contentDetails']['videoId'])
print(vid_ids)
print(plst['pageInfo']['totalResults'])
The first line printed contains the video ids of every available video in the playlist. The second line printed gives the number of videos in the playlist, including available and unavailable ones.
The playlist used in the code above is given here. It contains 10 total videos, of which one of them is unavailable.
In this case, the output is (with a valid api key)
['bv_cEeDlop0', 'mRKTOZmX2cE', '5ACvKdx1nns', 'wSNhP8b_Avo', 's56cHgokPlE', 'E4IHMWnQiMw', 'sCDkPShADSc', 'EVwgeUVVDYU', 'Z8Mqw0b9ADs']
10
Youtube still treats unavailable videos as an element of the playlist, but does not give out it's video id. In this particular instance, the video id of the unavailable video is "t83zUmjr05I", which is not hard to find manually: copy the link address of the deleted video and extract the part after the "v=".
But, on a larger scale manual extraction becomes tedious.
Here's a permanent fix to that!
You can try tube_dl.
pip install tube_dl
It uses modular approach and is up to date
More about this can be found at : https://github.com/shekharchander/tube_dl/
Maybe, the playlist module can help you with that. It uses regex to grab all video IDs not JSON. Please let me know if the problem is fixed or not, I will update module accordingly.
Edit
Here's the working code
from tube_dl import Playlist
p = Playlist('https://youtube.com/playlist?list=PLorw3mfu-J0ipF4Ss0XgR8IxcwP-JzNKC').videos
print(p)
I have two "Live streaming/live broadcast saved playlists" in following youtube channel --> https://www.youtube.com/user/swaminarayanlive.
I am trying to retrieve all the "live streaming / live broadcast playlists" of a channel using new youtube v3 api by using the below link-->
https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCBkNpeyvBO2TdPGVC_PsPUA&key={YOUR_API_KEY}
here i can get the info of playlists which are not live streams or live broadcast. and not able to get the same for the live one.
Please help me how can i get that for live one using youtube v3 api
I was researching another issue with the API when finding this, and when I saw that this was never resolved, I decided to look into it. It turns out that this is related to that other issue.
The YouTube API v3 lacks support for saved playlists. The channel swaminarayanlive did not create the playlists, only saved them from the channel BhujMandir.
The workaround in your case would be to retrieve the playlists of BhujMandir and extract the response snippets with "title" parameters containing the word "Live".
You would need to go through the pages and search each one for this, since there is a limit to how many results an API response can show at once. Currently it's 50.
So, you would use the following to get the first page of playlistItems:
GET https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCVItNtUctAknegvmYcMhUQg&maxResults=50&key={YOUR_API_KEY}
This will return an API response containing the properties "kind" (which will have the value "youtube#playlistListResponse") and "etag". If there are more than 50 results, there will also be a "nextPageToken" property. (On a page that is not the first, there would also be a "prevPageToken" property.)
After these properties, there are two blocks. One called "pageInfo", containing info about how many results (playlists) there are and how many are shown per page, and one block called "items", containing the resulting playlistItems.
You would look through the items block for any playlistItem with a title property (which is a string) containing the substring "Live" and get the id properties of those. You would then look on the next page by using the nextPageToken's value in a new HTTP request, like so:
GET https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCVItNtUctAknegvmYcMhUQg&maxResults=50&pageToken=[nextPageToken_value_here]&key={YOUR_API_KEY}
As of now, the two playlists you're looking for are on the pages with tokens CJYBEAA and CMgBEAA.
I think that where is the {YOUR_API_KEY} you should change this code and insert the name of your application program interface
There is no specification available for the possible values of the fields "type", "object_type" and "from_type" in the documentation of the Activity API.
I was hoping to retrieve activities for some events like:
Removing a video from a playlist
Adding a video to a playlist after having removed it from the same playlist (no activity in that case)
Adding a playlist
Editing a video (rename/change description or any other edit)
My question is :
Is there any way to retrieve those events with the Activity API? Is there any full specification for the "type" fields?
API types I know are for example :
user.addVideoToPlaylist
user.postVideo
user.startLiveStream
user.addComment
The documentation URL: http://www.dailymotion.com/doc/api/obj-activity.html
You are right by saying that the documentation is lacking on this front. We're going to remedy this situation in the near future. In the meantime, here is the current list of activity types available for you to use.
For users:
user.postVideo
user.addVideoToPlaylist
user.rateVideo
user.bookmarkVideo
user.addComment
user.joinGroup
user.addVideoToGroup
user.subscribeUser
user.likeVideo
user.startLiveStream
user.subscribeChannel
For groups:
group.memberJoin
group.videoAdd
group.noteAdd
For playlists:
playlist.videoAdd
For channels/categories:
channel.featuredVideo
So I am playing around with the YouTube API v3 for a web app I am building. I've got the basics down, but I am searching through documentation trying to find a way to filter a returned video list based on a channelID. However this doesn't seem to be possible. Is there way to write a request similar to this pseudocode below:
https://www.googleapis.com/youtube/v3/videos?part=snippet&
// and a second value that would imply with channelID=UCn8zNIfYAQNdrFRrr8oibKw
This seems like a logical function to have in the API. However, I can't seem to find any name/value pair in the documentation to support this theory.
The closest I can seem to find is the onBehalfOfContentOwner name/value pair for the video.list request (but it requires me to be the uploader of the video?) as outlined here
Anyways if someone can answer definitively if this is possible (if yes a link to docs or example I can use) as I've poured over docs looking for this functionality with no luck.
Any help would be much appreciated!
Your link refers to a video search.
1) First, you need to retrieve the channel info for the channelID (e.g. UCn8zNIfYAQNdrFRrr8oibKw).
See: https://developers.google.com/youtube/v3/docs/channels
Get the part:
"contentDetails": {
"relatedPlaylists": {
"likes": string,
"favorites": string,
"uploads": string,
"watchHistory": string,
"watchLater": string
}
2) Then use the "uploads": string, to retrieve the videos, being the user uploaded videos, which is a playlist.
For retrieving playlists see: https://developers.google.com/youtube/v3/docs/playlists .
Use the api call search.list, for example:
GET https://www.googleapis.com/youtube/v3/search?channelId=ASADKAHWSDA&type=video&key={YOUR_API_KEY}
in the query parameters specified the resource type = video because you want the videos of this channel. As cited here https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list
The type parameter restricts a search query to only retrieve a particular type of resource. The value is a comma-separated list of resource types. (string)
The resource can be anything a video, playlist, subscriber, etc. Hope this help.
When we view the YouTube page, and click Music, we are able to see them on different genre's like "Rap", "Rock", "Country", etc.
How can I retrieve this data (the genre-wise listing of videos) using the YouTube Apis.?
One way to do this is using the Topics API integration with V3 of the API. Take a look at the videos.list() API call. Plug in these values:
part: topicDetails
id: fWNaR-rxAic
fields: items/topicDetails/topicIds
The ID of that video corresponds to Carly Rae Jepsen's "Call Me Maybe". When you look at the JSON response, you'll see a list of topic IDs:
[ "/m/015f7",
"/m/0h55y27",
"/m/0gkxzs6",
"/m/064t9" ]
These are Freebase machine IDs. You would then make a Freebase API call to retrieve information about that particular topic. For instance, /m/064t9 corresponds to "Pop Music".
Thise method won't work for 100% of videos on YouTube; Metallica's "Whiskey in a Jar" only returns topics for the song and the band, however, Britney Spear's "I Want to Go" correctly returns a machine ID for "Pop Music".
The reason for this is that the Topic is often machine generated, not human curated (though we do quality checks). We did a Google I/O talk about how this works. The good news is that once you DO have a machine ID, it's very easy to find other videos by topic ID. Our samples demonstrate how to do this.
In freebase you can ask for music genre mids. For example in: http://www.freebase.com/search?query=rock you get that /m/06by7 = rock. With this id you do a query on youtube and get videos regarding this genre;
Try it https://developers.google.com/youtube/v3/docs/search/list#try-it with this conditions:
part: snippet
topicId: /m/06by7
For anyone wondering about this now (2017) freebase is deprecated and so instead you should use the list currently provided here: https://gist.github.com/stpe/2951130dfc8f1d0d1a2ad736bef3b703
Ikai Lan is still correct that the part is topicDetails to get this information from the API.