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?
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.
Related
While fetching Microsoft 365 Groups using Graph Api (Permission type: Delegated) - I got only 100 Group Count (see below screenshot) - I believe this has to be with pagination however the how to get the next bunch of group ? (like nextlink)
IGraphServiceGroupsCollectionPage groupCollection = await graphClient.Groups.Request().GetAsync();
if (groupCollection?.Count > 0)
{}
When using the SDK, here is how you can paginate the groups. Note I have added .Top(2) to get pagination on a few groups.
var groups = new List<Group>();
var groupsPage = await graphServiceClient.Groups.Request().Top(2).GetAsync();
groups.AddRange(groupsPage.CurrentPage);
while (groupsPage.NextPageRequest != null)
{
groupsPage = await groupsPage.NextPageRequest.GetAsync();
groups.AddRange(groupsPage.CurrentPage);
}
I've been looking at the MusicKit functionality for playlists:
https://developer.apple.com/documentation/applemusicapi/create_a_new_library_playlist
I'm wondering, can anyone confirm if they have been able to:
remove songs from an existing playlist
delete a playlist
update the title of a playlist
For example, I have tried updating the title of a playlist in c# using the following but the endpoint does exist/accept this. Note the appended playlist ID to the POST URL p.ABC123
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + [MYDEVTOKEN]);
client.DefaultRequestHeaders.Add("Music-User-Token", [MYMUSICUSERTOKEN]);
string _postUri = "https://api.music.apple.com/v1/me/library/playlists/p.ABC123";
var jsonObject = JObject.FromObject(new
{
attributes = new
{
name = "Playlist - Edited Title",
description = "This is a playlist edit"
}
});
var _content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json");
var response = await client.PostAsync(_postUri, content: _content);
string outputContent = await response.Content.ReadAsStringAsync();
}
It seems as though Apple isn't allowing this functionality.
https://forums.developer.apple.com/thread/107807
They could be doing this as a security precaution. However, Apple doesn't have a great relationship with the developer community, and is most likely doing it to limit people from building applications on top of theirs. (even though they are an extremely expensive API to work with off the bat...)
I wouldn't anticipate getting this functionality any time soon :(
I have to retrieve all video of my channel with Youtube API.
All videos are published on Youtube and I can see them correctly.
I tried to make the request directly from this page:
https://developers.google.com/youtube/v3/docs/search/list
and this is the example request:
GET http s://www.googleapis.com/youtube/v3/search?part=snippet&channelId=myChannelID&maxResults=50&key={YOUR_API_KEY}
Request doesn't retrieve all videos, it returns only 7 on the total of 9.
All videos have the same configuration. Missing videos are always the same.
If I use the video API passing the ID of one of those videos excluded from the search response, it returns a correct response and it belong correctly to my channel:
https://developers.google.com/youtube/v3/docs/videos/list#try-it
Someone can help me?
thank you in advance
Francesco
The answer to "How do I obtain a list of all videos in a channel using the YouTube Data API v3?" here may be what you need. Look especially at the video linked to in the answer.
To summarize, to get all the uploads from a channel, you need to get the items from the uploads playlist for the channel using playlistItems.list on that playlist's ID rather than calling search.list on the channel ID.
Try this two-step approach:
Get the ID of your channel's uploads playlist using the channels.list API call: GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id={YOUR_CHANNEL_ID}&key={YOUR_API_KEY}
Get the videos from the uploads playlist using the playlistItems.list call: GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=3&playlistId={YOUR_PLAYLIST_ID}&key={YOUR_API_KEY}
try this
async static Task<IEnumerable<YouTubeVideo>> GetVideosList(Configurations configurations, string searchText = "", int maxResult = 20)
{
List<YouTubeVideo> videos = new List<YouTubeVideo>();
using (var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = configurations.ApiKey
}))
{
var searchListRequest = youtubeService.Search.List("snippet");
searchListRequest.Q = searchText;
searchListRequest.MaxResults = maxResult;
searchListRequest.ChannelId = configurations.ChannelId;
searchListRequest.Type = "video";
searchListRequest.Order = SearchResource.ListRequest.OrderEnum.Date;// Relevance;
var searchListResponse = await searchListRequest.ExecuteAsync();
foreach (var responseVideo in searchListResponse.Items)
{
videos.Add(new YouTubeVideo()
{
Id = responseVideo.Id.VideoId,
Description = responseVideo.Snippet.Description,
Title = responseVideo.Snippet.Title,
Picture = GetMainImg(responseVideo.Snippet.Thumbnails),
Thumbnail = GetThumbnailImg(responseVideo.Snippet.Thumbnails)
});
}
return videos;
}
}
i want of find location based on current URL request for my project.
eg. if a user log in , system should output local area -> City -> country
from google API and also show the locaton and google map.
I have worked with freegeoip and to get the geo location from this is as below.
URL:- http://freegeoip.net/xml/{ip}
In this you can provide your IP and can see result in browser.
Implementation in code.
string apiUrl = http://freegeoip.net/xml/{ip}
HttpClient HttpClient = new HttpClient();
var response = HttpClient.GetAsync(apiUrl).Result;
if (response != null && response.ReasonPhrase != "Unauthorized")
{
var myobject = response.Content.ReadAsStringAsync();
}
I would be able to retrieve HTML markup of what is stored in Twitter Card (https://dev.twitter.com/docs/cards).
Up until now I used TweetSharp library to retrieve tweets from some user's timeline. But, what is not surprising, because cards are new thing, it is not included.
Does anyone know, if it is possible to access card (data cached by Twitter crawler) with API?
The Twitter cards themselves are not exposed through the Twitter API.
What you'll need to do is make a request to the URL mentioned and examine the <head> element to see if they have the Twitter Card info in there.
Twitter apis do not provide the twitter-card info out of the box. You can extract the card info for a url by looking it up in its html. Below code in csharp gets card image src from the url-
public static TweetMedia[] GetTwitterCardDetails(string url)
{
string HTML;
using (var wc = new WebClient())
{
HTML = wc.DownloadString(url);
}
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(HTML);
HtmlNode element = doc.DocumentNode.SelectSingleNode("//meta[#name='twitter:image:src']");
if (element != null)
{
return new TweetMedia[] { new TweetMedia { url=url, media_url_https = element.Attributes["content"].Value, type = TweetTypes.TweetType.Photo.ToString() } };
}
return null;
}