I am trying to port a application developed using version 2 API of google youtube to version 3.
How can I get title of a playlist using version 3 API? We could get the title of playlist using version 2. However, title I get when I query playlist's snippet is different from what it is shown on the youtube website.
Is there any difference in Version 3?
I am using .NET API library from Google. if this helps.
Can anyone please help?
EDITED: 20-MAY-2014
Sorry for the delay in response. I tried using Version 3 API from Google and when I am trying to get playlists using
var channelsListRequest = youtubeService.Channels.List("snippet,contentDetails");
after setting channelsListRequest.ForUserName, i call var channelsListResponse = await channelsListRequest.ExecuteAsync();
From the response, I would then get the playlist list sent using:
foreach (var channel in channelsListResponse.Items)
{
var uploadsListId = channel.ContentDetails.RelatedPlaylists.Uploads;
var nextPageToken = "";
while (nextPageToken != null)
{
var playlistRequest = youtubeService.Playlists.List("id,snippet,contentDetails,status,player");
playlistRequest.Id = uploadsListId;
playlistRequest.MaxResults = 50;
playlistRequest.PageToken = nextPageToken;
var playlistListResponse = await playlistRequest.ExecuteAsync();
if (playlistListResponse.Items.Count > 0)
MessageBox.Show(playlistListResponse.Items[0].Snippet.Title);
}
The messagebox displays the comment that was added when creating playlist. However, when I view in youtube using a browser, the playlist title is displayed properly.
Please try the following link, and change the play
https://www.googleapis.com/youtube/v3/playlists?part=snippet%2Clocalizations&id=" + playlistId + "&fields=items(localizations%2Csnippet%2Flocalized%2Ftitle)&key=" + KEY;
Implementation and Migration Guide: https://developers.google.com/youtube/v3/guides/implementation
I am new to the YouTube API implementation, so please use the Implementation and Migration Guide above for more information, but from what I have discovered myself using the API Explorer: https://developers.google.com/apis-explorer/#p/youtube/v3/. Is that you need to use youtube.playlists.list(snippet,[id]). Replace [id] with the ID of your playlist.
Related
As YouTube official documentation about implement and immigrate to API V3, they said:
YouTube Data API (v2) functionality: Retrieve video recommendations
The v3 API does not retrieve a list that only contains videos recommended for the current API user. However, you can use the v3 API to find recommended videos by calling the activities.list method and setting the home parameter value to true.
But now the parameter home has been deprecated too.
Currently, when I set the home parameter to true, I only retrieve the recently uploaded video in the channel: Popular video in YouTube. There are no video with snippet.type=recommendation at all.
I need to show recommended videos of authenticated user in new feed, but seem like this feature is completely deprecated by YouTube.
Anyone has solution for that?
Thanks first!
Unfortunately, I can't find any documentation or example about this feature. It seems that this has been deprecated. However, you may check this documentation with sample JSON structure that shows the format of a activities resource such as recommendation:
"recommendation": {
"resourceId": {
"kind": string,
"videoId": string,
"channelId": string,
},
Hope this helps!
I found this youtubes search api. All we need to do is put a video id in the relatedToVideoId and it'll giveout a list of videos related to it.
The docs for the api include a way to test the request. code samples there show how to set 'mine' for an authenticated request.
youtube activities
This is android sample code. it would need to be in some background thread. The setmine = true on the channelList response is like the home (I think). Was not sure if your implementation was for the web or an app.
this is android code:
YouTube youtube = new YouTube.Builder(transport, jsonFactory,
credential).setApplicationName(getString(R.string.app_name))
.build();
YouTube.Activities.List activities;
ActivityListResponse activityListResponse = null;
List<ActivityData> activitiesData = new ArrayList<ActivityData>();
try {
/*
* Now that the user is authenticated, the app makes a
* channels list request to get the authenticated user's
* channel. Returned with that data is the playlist id for
* the uploaded videos.
* https://developers.google.com/youtube
* /v3/docs/channels/list
*/
ChannelListResponse clr = youtube.channels().list("contentDetails")
.setMine(true).execute();
activities = youtube.activities().list("id,snippet,subscriberSnippet");
activities.setChannelId(clr.getItems().get(0).getId());
activities.setMaxResults((long) 50);
activityListResponse = activities.execute();
ArrayList<String> subscriptionListIdentifier = new ArrayList<String>()
,listTitles = new ArrayList<String>()
,listThumbnails = new ArrayList<String>();
List<Activity> results = activityListResponse.getItems();
for (Activity activity : results) {
listTitles.add(activity.getSnippet().getTitle());
listThumbnails.add(activity.getSnippet().getThumbnails().getDefault().getUrl());
subscriptionListIdentifier.add(activity.getId());
//if ("public".equals(playlist.getStatus()
// .getPrivacyStatus())) {
ActivityData data = new ActivityData();
data.setActivity(activity);
activitiesData.add(data);
//}
}
return activitiesData;
You can retrieve them using the following API call:
GET https://www.googleapis.com/youtube/v3/activitiespart=snippet%2CcontentDetails&channelId={channel—_Id}&maxResults=25®ionCode=tw&key={YOUR_API_KEY}
I am using the Xamarin Mono for Android Google API binding. I receive an HTTP 308 error, which is basically a timeout, when I upload a video that's larger than 75 MB. I am unable to cast my videosInsertRequest.RequestFactory to GDataRequestFactory and set the time out. No GDataRequestFactory exists. The request factory is of type ICreateHttp and it's create method returns a HttpWebRequest. Is there another way to set the YouTubeRequest's time out property or upload the videos another way?
GoogleAuthenticator auth2;
YoutubeService yt = new YoutubeService (auth2);
string name = String.Format("{0} {1}", etStatusUpdate.Text, DateTime.Now.ToString());
var videosInsertRequest = yt.Videos.Insert (Helpers.MakeVideo (name, etStatusUpdate.Text), "snippet,statistics,status", MakeVideoFileStream (), VIDEO_FILE_FORMAT);
//((GDataRequestFactory)videosInsertRequest.RequestFactory).Timeout = 9999999;
videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;
videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;
I would suggest you to use Data API v3.
YouTube Direct Lite project has uploads for Android.
(I wrote "Hello", but it gets removed.)
I'm using the youtube api from an android application.
I was getting the channelId from a "channel" search by looking at id.channelid. Now it seems to have been changed to snippet.channelid.
But the field value is always "UC". ???
The code:
YouTube.Search.List search = youtube.search().list("id,snippet");
search.setKey("my key");
search.setQ("whatever channel name");
search.setType("channel");
search.setFields("items(snippet(channelId))");
search.setMaxResults((long)1);
SearchListResponse searchResponseC = search.execute();
List<SearchResult> searchResultListC = searchResponseC.getItems();
String channelid = ((SearchResult)searchResultListC.get(0)).getSnippet().getChannelId();
Now channelid value is "UC".
Also, I'm not sure if the line search.setType("channel"); has any effect.
Help, please.
Its a known issue with the V3 api this week.
https://code.google.com/p/gdata-issues/issues/detail?id=4971
I need to generate a snapshot from multiple links of blogs.
What i have is a list of text like these
"Report: Twitter Will Release Music Discovery App This Month http://on.mash.to/10L1v49 via #mashable"
I want to show the links as snapshot of the blog, followed by its text in my view. Or at least i need to get the picture attached to the blog.
Using facebook debug, http://developers.facebook.com/tools/debug ,i am getting this..
fb:app_id: 122071082108
og:url: http://mashable.com/2013/03/13/twitter-music-app/
og:type: article
og:title: Report: Twitter Will Release Music Discovery App This Month
og:image:
og:description: Twitter is planning to release a standalone music app for iOS called Twitter Music as soon as the end of this month, according to CNET. CNET reports that Twitter Music will help...
og:site_name: Mashable
og:updated_time: 1363267654
I tried the same link from my c# code, accessed the link with parameter 'q' as my desired link. I got the same html as reply but i am unable to find the image associated as it is coming differently for different links.
Can anyone suggest a better method to do this in mvc?
My code in controller to access facebook debug :
var client = new RestClient
{
BaseUrl = "http://developers.facebook.com/tools/debug/og/object"
};
var request = new RestRequest
{
DateFormat = DataFormat.Xml.ToString(),
Resource = "Add",
Method = Method.GET
};
request.AddParameter("q", "http://on.mash.to/10L1v49");
IRestResponse response = client.Execute(request);
var content = response.Content; // raw content as string
What i understand from your question is, you need something like the preview of a link what we get on pasting some link on facebook share area.
Facebook debug method returns an html page which has the image of your blog entry from the link given.
Use HtmlAgilityPack to parse your html returned from facebook debug
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(content);
HtmlNode root = doc.DocumentNode;
var imageurl = doc.DocumentNode.SelectNodes("//img/#src").LastOrDefault();
string imagesrc = imageurl.OuterHtml.ToString();
int start = imagesrc.IndexOf("url=");
int to = imagesrc.IndexOf("\"", start + "url=".Length);
string s = imagesrc.Substring(
start + "url=".Length,
to - start - "url=".Length);
string a = Uri.UnescapeDataString(s);
and..there you have your image of the blog entry. Same function can be modified to retireve the title, description and the updated time of the blog entry.
I'm currently in the middle of a project that involves YouTube API. I'm using the Zend Gdata, and everything has gone nicely until this.
I need to get a Zend_Gdata_YouTube_PlaylistListEntry based on the ID of the playlist. I have managed to retrieve the videos with some fiddling:
$feed = $yt->getVideoFeed('http://gdata.youtube.com/feeds/api/playlists/'.$id.'?v=2');
$playlist = new Zend_Gdata_YouTube_PlaylistListEntry($feed->getDOM());
However, I need to use the method $playlist->getPlaylistVideoFeedUrl(), and it returns NULL in this case.
Any help regarding this is appreciated =)
Got it:
$url = 'http://gdata.youtube.com/feeds/api/playlists/'.$input['id'].'?v=2';
$feed = $yt->getPlaylistVideoFeed($url);