Reputation: 47
I need help. I'm making a program using the youtube library, for c#.
For songs it works perfect. The problem is in the playlist I want to recover "videoId" to add it to a database, to put the videos in "queue".
I am using this method:
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key= {API key} & maxResults = 50 & playlistId = {id}
which returns a json, but the problem is when I want to retrieve the "videoId" field.
I've tried a lot of things and can't get it to work. For example:
var json = wc.DownloadString ("https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key=API_KEY&playlistId=PL-PXKb5jSjwbU0wzAuEooBvkZ9jnmXR7N");
dynamic data = JObject.Parse (json);
Console.WriteLine ("playlist" + data.items.snippet.resourceId.videoId);
Console.WriteLine ("playlist" + data.items.snippet.videoId);
Console.WriteLine ("playlist" + data.items.videoId);
Console.WriteLine ("playlist" + data.videoId);
The json that it returns is like this:
[
{
"kind": "youtube#playlistItem",
"etag": "_ON9HZaMSViWcbtKBRrSkH8D43Y",
"id": "UEwtUFhLYjVqU2p3YlUwd3pBdUVvb0J2a1o5am5tWFI3Ti4xMjNBNTA2NDBDODU0QTE1",
"snippet": {
"publishedAt": "2021-05-17T09:33:13Z",
"channelId": "UCn3uYZIYTMSvJraGKW2Blhw",
"title": "C. Tangana, Niño de Elche, La Hungara - Tú Me Dejaste De Querer",
"description": "C. Tangana – Tú me dejaste de querer ft La Húngara y Niño de Elche \n\nMERCHANDISING: https://www.ctangana.com \nIG: https://www.instagram.com/c.tangana/\nTW: https://twitter.com/c_tangana\nFB: https://www.facebook.com/ctanganaoficial/\n\n\nLyrics Tú Me Dejaste De Querer\n\nTú me dejaste de querer \nCuando te necesitaba\nCuando más falta hacía\nTú me diste la espalda\n\nTú me dejaste de querer\nCuando menos lo esperaba\nCuando más te quería \nSe te fueron las ganas \n\nYo me creía que era el más cabrón \nPero me estoy notando el corazón\nEstás apretando mucho mami déjalo\nSi quieres te doy la razón \nYo lo único que quiero es largarme de aquí \nMe da igual dónde, puedes elegir \nAlgún día dentro de poco me voy a arrepentir \nDe haberte confesado lo que me haces sufrir\n\nTú me dejaste de querer\nCuando menos lo esperaba\nCuando más te quería \nSe te fueron las ganas \n \nDe punta en blanco para ir a tu fiesta\nHe pasado tres días con la misma ropa puesta\nAndo loco por ti, perdiendo apuestas \nDime en quién piensas cuando te acuestas. \nPorque yo pienso en ti (son ilusiones)\nYo pienso en ti (son ilusiones)\nPorque yo pienso en ti (son ilusiones)\nYo pienso en ti (son ilusiones)\n\nTú me dejaste de querer \nCuando te necesitaba\nCuando más falta hacía\nTú me diste la espalda\n\nTú me dejaste de querer\nCuando menos lo esperaba\nCuando más te quería \nSe te fueron las ganas\n\n\n(C) 2020 Sony Music Entertainment España, S.L",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/ltmO9XQVdSg/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/ltmO9XQVdSg/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/ltmO9XQVdSg/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/ltmO9XQVdSg/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/ltmO9XQVdSg/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "Redlist - Las Mejores Canciones",
"playlistId": "PL-PXKb5jSjwbU0wzAuEooBvkZ9jnmXR7N",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": "ltmO9XQVdSg"
},
"videoOwnerChannelTitle": "CTanganaVEVO",
"videoOwnerChannelId": "UCPTQlbt5SZO_SpYvC4Ygl-A"
}
},
{
"kind": "youtube#playlistItem",
"etag": "4oVVxxoagCYATigtGVg53WXm2ak",
"id": "UEwtUFhLYjVqU2p3YlUwd3pBdUVvb0J2a1o5am5tWFI3Ti5BRDA1REM4NDZFOEZFOEZF",
"snippet": {
"publishedAt": "2021-04-16T05:51:54Z",
"channelId": "UCn3uYZIYTMSvJraGKW2Blhw",
"title": "Omar Montes, Ana Mena, Maffio - Solo",
"description": "“Familia, espero que os guste mi nuevo video “Solo” con mi hermanita Ana Mena y mi amigo Maffio y que todos lo bailéis y mandéis a todos y todas pa´ la Isla de las Tentaciones!!!! OS CAMELO”\n\nOMAR MONTES\nIG: https://www.instagram.com/omarmontesofficial/\nFB: https://www.facebook.com/omarmontessr/\nYOUTUBE: https://www.youtube.com/channel/UC-1BnbAPgInTpJiEi3z2d4A?sub_confirmation=1\n\n\nMusic video by Omar Montes, Ana Mena, Maffio performing Solo. (C) 2021 Sony Music Entertainment España, S.L.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/u12F1RY3WJQ/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/u12F1RY3WJQ/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/u12F1RY3WJQ/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Redlist - Las Mejores Canciones",
"playlistId": "PL-PXKb5jSjwbU0wzAuEooBvkZ9jnmXR7N",
"position": 1,
"resourceId": {
"kind": "youtube#video",
"videoId": "u12F1RY3WJQ"
},
"videoOwnerChannelTitle": "OmarMontesVEVO",
"videoOwnerChannelId": "UCC9RzPoJumhh839VKwGBy6Q"
}
},
{
"kind": "youtube#playlistItem",
"etag": "5zp32QT_yZ4pGN90Y7OKL2weCYU",
"id": "UEwtUFhLYjVqU2p3YlUwd3pBdUVvb0J2a1o5am5tWFI3Ti42OTMwOTQzM0Q0ODU3QkFC",
"snippet": {
"publishedAt": "2021-06-04T19:39:36Z",
"channelId": "UCn3uYZIYTMSvJraGKW2Blhw",
"title": "BRYAN BAUTISTA - PARA MÍ (Official Video)",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/cU_JGIuYsi0/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/cU_JGIuYsi0/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/cU_JGIuYsi0/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/cU_JGIuYsi0/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/cU_JGIuYsi0/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "Redlist - Las Mejores Canciones",
"playlistId": "PL-PXKb5jSjwbU0wzAuEooBvkZ9jnmXR7N",
"position": 2,
"resourceId": {
"kind": "youtube#video",
"videoId": "cU_JGIuYsi0"
},
"videoOwnerChannelTitle": "Bryan Bautista",
"videoOwnerChannelId": "UCxCwpWTTehfcG0wmleUrReg"
}
},
{
"kind": "youtube#playlistItem",
"etag": "t2UOHEo3irk0z4ollZOzB1H3eHE",
"id": "UEwtUFhLYjVqU2p3YlUwd3pBdUVvb0J2a1o5am5tWFI3Ti41RUJCMkQ1ODk1RkI4NDg1",
"snippet": {
"publishedAt": "2021-05-14T19:46:26Z",
"channelId": "UCn3uYZIYTMSvJraGKW2Blhw",
"title": "Juhn, Jay Wheeler - Fragancia (Official Video)",
"description": "Juhn, Jay Wheeler - Fragancia (Official Video)\nEncuéntrala en todas las plataformas: https://juhn.lnk.to/FraganciaYD\n\nSigue a Juhn\n➖ Facebook: https://smarturl.it/Juhn_fb\n➖ Instagram: https://smarturl.it/Juhn_ig\n➖ YouTube: https://smarturl.it/Juhn_yt\n➖ Spotify: https://smarturl.it/Juhn_sp\n\nLyrics/Letra\n\nNo sé que hago buscándote\nSi nadie me dice en donde estas\nTu recuerdo jugando con mi mente\nCuando te tengo, ahí mismo tú te vas\nPero ya yo lo entendí \nNo siempre en la vida uno tiene lo que quiere\nTal vez no eras para mi\nPero si supieras lo loco que me tienes\n\nNo hay quien te sustituya\nDesde que tu olor en mi cama me dejaste\nTan rico me lo hiciste\nQue por siempre en mi mente te quedaste\n\nNo hay quien te sustituya\nDesde que tu olor en mi cama me dejaste\nTan rico me lo hiciste\nQue por siempre en mi mente te quedaste\n\nBebecita, yo no olvido la fragancia de tu olor\nEl primer polvo fue rico\nY el segundo fue mejor\nY tú...\nComo media me viraste\nAbusadora, te subiste y no bajaste\nDe la machina, \nEmpieza otro siempre que termina\nQue le hablen sucio, dice que eso le fascina\nDe una mujer así, dime quien se olvida\n\nY no te niego que detrás tengo unas cuantas\nPero eres tú la que me dominas y me encantas\nLa que se lo lleva completo a la garganta\nSoy egoísta, no pidas que te comparta\nSi tú sabes que\n\nEse cuerpito tuyo es mío\nAunque yo no te hice mujer\nYo sé bien que te acuerdas de mi\nEn donde quiera que estés\n\nNo hay quien te sustituya\nDesde que tu olor en mi cama me dejaste\nTan rico me lo hiciste\nQue por siempre en mi mente te quedaste\n\nNo hay quien te sustituya\nDesde que tu olor en mi cama me dejaste\nTan rico me lo hiciste\nQue por siempre en mi mente te quedaste\n\nTe veo por Twitter\nY rápido me da con escribirte indirectas\nSi\nPuedo tener otros culos\nPero pa' mi tú siempre serás la correcta\nY, si me dejan como Pina, te comprometo\nY es que me enchulo ma' cada vez que te lo meto\nBaby yo soy tuyo completo\nPensándote no me puedo estar quieto\nNo, No, No...\n\nTe llamo pero no contestas\nDime si todavía estas dispuesta\nMi cama no es la misma si tú no te acuestas\nY sigo aquí...\n\nTe llamo pero no contestas\nDime si todavía estas dispuesta\nMi cama no es la misma si tú no te acuestas\n\nNo hay quien te sustituya\nDesde que tu olor en mi cama me dejaste\nTan rico me lo hiciste\nQue por siempre en mi mente te quedaste\n\nNo hay quien te sustituya\nDesde que tu olor en mi cama me dejaste\nTan rico me lo hiciste\nQue por siempre en mi mente te quedaste\n\nLa voz favorita baby\nEste ES Juhn \nJay Wheeler Jay Wheeler\nEl All Star\nJay Wheeler Jay Wheeler\nBaby\n\nHoy ando con Jay Wheeler\nLas estrellas siempre andan juntas\nUstedes lo saben ya\nMontana The Producer\nJonniel\nNosotros tenemos la coneccion directa con Willy Wonka\nLos dulces están de este lao\n\n#Juhn #JayWheeler #Fragancia",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/vN8un8VoPoQ/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/vN8un8VoPoQ/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/vN8un8VoPoQ/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/vN8un8VoPoQ/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/vN8un8VoPoQ/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "Redlist - Las Mejores Canciones",
"playlistId": "PL-PXKb5jSjwbU0wzAuEooBvkZ9jnmXR7N",
"position": 3,
"resourceId": {
"kind": "youtube#video",
"videoId": "vN8un8VoPoQ"
},
"videoOwnerChannelTitle": "Juhn",
"videoOwnerChannelId": "UCTeE0q8xCsbCBL4npUWDPFg"
}
},
{
"kind": "youtube#playlistItem",
"etag": "9me0qaU5MYsZOaBTIqwnxgBpqP4",
"id": "UEwtUFhLYjVqU2p3YlUwd3pBdUVvb0J2a1o5am5tWFI3Ti4xQTlCRURGNEY0QUEyODdD",
"snippet": {
"publishedAt": "2021-06-04T19:39:36Z",
"channelId": "UCn3uYZIYTMSvJraGKW2Blhw",
"title": "Nobeat, KHEA - Medio Crazy (Official Video)",
"description": "Nobeat, KHEA - Medio Crazy (Official Video)\n\nEncuéntrala en todas las plataformas https://Nobeat.lnk.to/mediocrazyID\n\nSigue a Nobeat: \nInstagram: https://www.instagram.com/nobeat/ \nTwitter: https://twitter.com/nobeatmusic \nFacebook: https://www.facebook.com/nobeatmusic\nMailing List: https://Nobeat.lnk.to/MailingListID\n\n\nLyrics/Letra\nYa Nobeat\nSon of God\n \nSé que te pasa igual que yo\nte han roto el corazón\nAmigos pocos los que son\nNo sé ni lo que somos pero sobra la pasión\nTú eres la que manda siempre te doy la razón\n \nTe dedico esta canción\nPa’ que veas que yo\nMe pongo romántico de vez en cuando\nMe encanta ver la cara que pones cuando dices\nTú solito no te mandas ay\n \nTú eres como medio crazy\nPero mejor que muchas por ahí\nQue delicia como bailas pam pam pam\nEl booty te hace así\n \nTú eres como medio crazy\nPero mejor que muchas por ahí\nQue delicia como bailas pam pam pam\n \nEs una loca pero ya no me manda snap\nAhora la tengo bailando como Addison Rae\nSe convirtió en mi favorito snack\nCuando está estresada soy su spa\nSiempre que le caigo\nSe la encesto como Michael\nElla es medio psycho y hace lo que quiere\nCon ese booty me distraigo\nSabe lo que tiene todo natural\nParece que te hicieron pa’ mi\nNo paramos de hablar desde que te conocí\nComo Ester Expósito tu eres elite\nTodos quieren tirarte pero son Mr. Bean\n \nY dale muévelo abusalo\nTú tienes poderes así que úsalos\nBaby excusas no\nPor favor\nTratando de entenderte me gradué\n \nPorque yeah\n \nTu eres medio crazy\nPero mejor que muchas por ahí\nQue delicia como baila pam pam pam\nEl booty te hace así\n \nTú eres como medio crazy\nPero mejor que muchas por ahí\nQue delicia como bailas pam pam pam\n \nElla no juega call of duty pero siempre me mata\nHeadshot\nQue rica que está no es intensa\nMedio crazy no es fácil entenderla\nEs como el algebra de Baldor hey\nNi si fueras un meme te comparto\nTú no eres segundo plato\nBaby please no me preguntes por mi ex no no\n \nNo invoques a Voldemort\nSi confías baby todo es más sencillo\nA mi no me preocupan los demás\nYo los piso y los apago como un cigarrillo\nY dale muévelo abúsalo\nTú tienes poderes así que úsalos\nBaby excusas no por favor\nTratando de entenderte me gradué porque\n \nTú eres como medio crazy\nPero mejor que muchas por ahí\nQue delicia como bailas pam pam pam\nEl booty te hace así\nTú eres com medio crazy\nPero mejor que muchas por ahí\nQue delicia como baila pam pam pam\nEl booty te hace así\n \nKHEA\nYoung Flex Argentina en la casa\nYeah\nNobeat\nDimelo KHEA\nNobeat\n2080’s\n\n#Nobeat #KHEA #MedioCrazy",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/eBwb5BA-stw/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/eBwb5BA-stw/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/eBwb5BA-stw/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/eBwb5BA-stw/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/eBwb5BA-stw/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "Redlist - Las Mejores Canciones",
"playlistId": "PL-PXKb5jSjwbU0wzAuEooBvkZ9jnmXR7N",
"position": 4,
"resourceId": {
"kind": "youtube#video",
"videoId": "eBwb5BA-stw"
},
"videoOwnerChannelTitle": "Nobeat",
"videoOwnerChannelId": "UCW56a1VqbINaFC50Es_EYvg"
}
}
]
I can't get it to return each video "videoId".
If anyone knows how to solve it, I will be very grateful.
Thank you.
Upvotes: 1
Views: 505
Reputation: 10849
You can use JSON Path to get the video id.
Token to fetch all video id is $...videoId
.
Check this fiddle - https://dotnetfiddle.net/nyngkK
You can use this portal to validate the JSON path token - https://jsonpath.com/
The below code demostrates the whole program which returns the output as
ltmO9XQVdSg
u12F1RY3WJQ
cU_JGIuYsi0
vN8un8VoPoQ
eBwb5BA-stw
Code
using System;
using System.Threading.Tasks;
using System.Net.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public class Program
{
public static void Main()
{
RunTest().GetAwaiter().GetResult();
Console.WriteLine("Hello World");
}
public async static Task RunTest()
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
var response = await client.GetAsync("https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key=<<Your Key>>&playlistId=PL-PXKb5jSjwbU0wzAuEooBvkZ9jnmXR7N");
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
JObject jObject = JObject.Parse(content);
var videoIds = jObject.SelectTokens("$...videoId");
foreach (var videoId in videoIds)
{
Console.WriteLine(videoId.Value<string>());
}
}
}
}
Upvotes: 2
Reputation: 6923
I would highly recommend that you use the Google APIs Client Library for .NET for which you can look at samples in the dotnet folder on the official GitHub repo or alternatively parse your Json into strongly typed classess.
The basic issue with your code is you are parsing as a JObject
instead of a JArray
. For details see: Difference between array and object in javascript? or Array Vs Object/
If you intend to continue using raw json. You can parse the Json as a JArray
and select the videoIds from it.
public static List<string> ParseVideoIds()
{
var json = TestConstants.JsonTest;
JArray jArray = JArray.Parse(json);
var videoIds = jArray
.SelectTokens("$...videoId")
.Select(x=> x.ToString())
.ToList();
Console.WriteLine(string.Join(",", videoIds));
return videoIds.ToList();
}
Or you can make your code more formal and use strongly type classes to deserialize your json to.
Edit -> Paste Special -> Paste Json as Classes
NewtonSoft.Json
which I assume you are using from the JObject.Parse
method in your question.JObject.Parse
, identify the strongly typed classes in the Rootobject
properties generated from pasting your json as classes. You can then deserialize the json as that type. In this case it is simply an array of Class1[]
.var json = wc.DownloadString("https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key=API_KEY&playlistId=PL-PXKb5jSjwbU0wzAuEooBvkZ9jnmXR7N");
var obj = JsonConvert.DeserializeObject<Class1[]>(json);
var videoIds = obj.Select(x => x.snippet.resourceId.videoId).ToList();
Putting it all together:
public static List<string> ParseVideoIds(string url)
{
var json = wc.DownloadString(url);
var obj = JsonConvert.DeserializeObject<Class1[]>(json);
var videoIds = obj.Select(x => x.snippet.resourceId.videoId).ToList();
Console.WriteLine(string.Join(",", videoIds));
return videoIds.ToList();
}
For reference, here are the class generated using Paste Json as Classes:
public class Rootobject
{
public Class1[] Property1 { get; set; }
}
public class Class1
{
public string kind { get; set; }
public string etag { get; set; }
public string id { get; set; }
public Snippet snippet { get; set; }
}
public class Snippet
{
public DateTime publishedAt { get; set; }
public string channelId { get; set; }
public string title { get; set; }
public string description { get; set; }
public Thumbnails thumbnails { get; set; }
public string channelTitle { get; set; }
public string playlistId { get; set; }
public int position { get; set; }
public Resourceid resourceId { get; set; }
public string videoOwnerChannelTitle { get; set; }
public string videoOwnerChannelId { get; set; }
}
public class Thumbnails
{
public Default _default { get; set; }
public Medium medium { get; set; }
public High high { get; set; }
public Standard standard { get; set; }
public Maxres maxres { get; set; }
}
public class Default
{
public string url { get; set; }
public int width { get; set; }
public int height { get; set; }
}
public class Medium
{
public string url { get; set; }
public int width { get; set; }
public int height { get; set; }
}
public class High
{
public string url { get; set; }
public int width { get; set; }
public int height { get; set; }
}
public class Standard
{
public string url { get; set; }
public int width { get; set; }
public int height { get; set; }
}
public class Maxres
{
public string url { get; set; }
public int width { get; set; }
public int height { get; set; }
}
public class Resourceid
{
public string kind { get; set; }
public string videoId { get; set; }
}
As noted, you can disregard Rootobject
.
Additionally, feel free to refactor Class1 (or any of the other classes or Rootobject when using Json of a different schema) to something more intuitive. For example:
public class YouTubePlayListItem
{
public string kind { get; set; }
public string etag { get; set; }
public string id { get; set; }
public Snippet snippet { get; set; }
}
With that refactoring you would have:
public static List<string> ParseVideoIds(string url)
{
var json = wc.DownloadString(url);
var obj = JsonConvert.DeserializeObject<YouTubePlayListItem[]>(json);
var videoIds = obj.Select(x => x.snippet.resourceId.videoId).ToList();
Console.WriteLine(string.Join(",", videoIds));
return videoIds.ToList();
}
For Net 5.0, the Microsoft Documentation outlines in more detail what is described above, as pointed out in the answer from Gökdeniz Çetin
Upvotes: 1
Reputation: 181
the returned json from youtube is a array so you must convert that with JArray
its worked with your json
using System.IO;
using Newtonsoft.Json.Linq;
using System;
class program
{
static string json = File.ReadAllText("json.json");
static void Main(string[] args)
{
dynamic data = JArray.Parse(json);
foreach (dynamic dynamic in data)
Console.WriteLine(dynamic.snippet.resourceId.videoId);
Console.ReadKey();
}
}
for understand what is returned json use this website
Upvotes: 0
Reputation: 11
You can serialize your json file through a class and pull the data in a more practical way. See the Microsoft Documentation
Upvotes: 1
Reputation: 2490
Instead of going to every path you can use below code :
var json = wc.DownloadString ("https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key=API_KEY&playlistId=PL-PXKb5jSjwbU0wzAuEooBvkZ9jnmXR7N");
JToken token = JToken.Parse(json);
foreach(var c in token.Children())
{
var m = c.SelectToken("$.." + "videoId");
Console.WriteLine(m);
}
Upvotes: 0