@@ -62,7 +62,7 @@ To retrieve the metadata associated with a YouTube video, call `Videos.GetAsync(
6262``` csharp
6363using YoutubeExplode ;
6464
65- var youtube = new YoutubeClient ();
65+ using var youtube = new YoutubeClient ();
6666
6767// You can specify either the video URL or its ID
6868var videoUrl = " https://youtube.com/watch?v=u_yIGGhubZs" ;
@@ -96,7 +96,7 @@ You can request the manifest that lists all available streams for a particular v
9696``` csharp
9797using YoutubeExplode ;
9898
99- var youtube = new YoutubeClient ();
99+ using var youtube = new YoutubeClient ();
100100
101101var videoUrl = " https://youtube.com/watch?v=u_yIGGhubZs" ;
102102var streamManifest = await youtube .Videos .Streams .GetManifestAsync (videoUrl );
@@ -144,7 +144,7 @@ To get the list of available closed caption tracks, call `Videos.ClosedCaptions.
144144``` csharp
145145using YoutubeExplode ;
146146
147- var youtube = new YoutubeClient ();
147+ using var youtube = new YoutubeClient ();
148148
149149var videoUrl = " https://youtube.com/watch?v=u_yIGGhubZs" ;
150150var trackManifest = await youtube .Videos .ClosedCaptions .GetManifestAsync (videoUrl );
@@ -188,7 +188,7 @@ You can get the metadata associated with a YouTube playlist by calling the `Play
188188``` csharp
189189using YoutubeExplode ;
190190
191- var youtube = new YoutubeClient ();
191+ using var youtube = new YoutubeClient ();
192192
193193var playlistUrl = " https://youtube.com/playlist?list=PLa1F2ddGya_-UvuAqHAksYnB0qL9yWDO6" ;
194194var playlist = await youtube .Playlists .GetAsync (playlistUrl );
@@ -205,7 +205,7 @@ To get the videos included in a playlist, call `Playlists.GetVideosAsync(...)`:
205205using YoutubeExplode ;
206206using YoutubeExplode .Common ;
207207
208- var youtube = new YoutubeClient ();
208+ using var youtube = new YoutubeClient ();
209209var playlistUrl = " https://youtube.com/playlist?list=PLa1F2ddGya_-UvuAqHAksYnB0qL9yWDO6" ;
210210
211211// Get all playlist videos
@@ -220,7 +220,7 @@ You can also enumerate the videos iteratively without waiting for the whole list
220220``` csharp
221221using YoutubeExplode ;
222222
223- var youtube = new YoutubeClient ();
223+ using var youtube = new YoutubeClient ();
224224var playlistUrl = " https://youtube.com/playlist?list=PLa1F2ddGya_-UvuAqHAksYnB0qL9yWDO6" ;
225225
226226await foreach (var video in youtube .Playlists .GetVideosAsync (playlistUrl ))
@@ -235,7 +235,7 @@ If you need precise control over how many requests you send to YouTube, use `Pla
235235``` csharp
236236using YoutubeExplode ;
237237
238- var youtube = new YoutubeClient ();
238+ using var youtube = new YoutubeClient ();
239239var playlistUrl = " https://youtube.com/playlist?list=PLa1F2ddGya_-UvuAqHAksYnB0qL9yWDO6" ;
240240
241241// Each batch corresponds to one request
@@ -262,7 +262,7 @@ You can get the metadata associated with a YouTube channel by calling the `Chann
262262``` csharp
263263using YoutubeExplode ;
264264
265- var youtube = new YoutubeClient ();
265+ using var youtube = new YoutubeClient ();
266266
267267var channelUrl = " https://youtube.com/channel/UCSMOQeBJ2RAnuFungnQOxLg" ;
268268var channel = await youtube .Channels .GetAsync (channelUrl );
@@ -275,7 +275,7 @@ You can also get the channel metadata by username or profile URL with `Channels.
275275``` csharp
276276using YoutubeExplode ;
277277
278- var youtube = new YoutubeClient ();
278+ using var youtube = new YoutubeClient ();
279279
280280var channelUrl = " https://youtube.com/user/BlenderFoundation" ;
281281var channel = await youtube .Channels .GetByUserAsync (channelUrl );
@@ -288,7 +288,7 @@ To get the channel metadata by slug or legacy custom URL, use `Channels.GetBySlu
288288``` csharp
289289using YoutubeExplode ;
290290
291- var youtube = new YoutubeClient ();
291+ using var youtube = new YoutubeClient ();
292292
293293var channelUrl = " https://youtube.com/c/BlenderFoundation" ;
294294var channel = await youtube .Channels .GetBySlugAsync (channelUrl );
@@ -301,7 +301,7 @@ To get the channel metadata by handle or custom URL, use `Channels.GetByHandleAs
301301``` csharp
302302using YoutubeExplode ;
303303
304- var youtube = new YoutubeClient ();
304+ using var youtube = new YoutubeClient ();
305305
306306var channelUrl = " https://youtube.com/@BlenderOfficial" ;
307307var channel = await youtube .Channels .GetByHandleAsync (channelUrl );
@@ -317,7 +317,7 @@ To get the list of videos uploaded by a channel, call `Channels.GetUploadsAsync(
317317using YoutubeExplode ;
318318using YoutubeExplode .Common ;
319319
320- var youtube = new YoutubeClient ();
320+ using var youtube = new YoutubeClient ();
321321var channelUrl = " https://youtube.com/channel/UCSMOQeBJ2RAnuFungnQOxLg" ;
322322
323323var videos = await youtube .Channels .GetUploadsAsync (channelUrl );
@@ -331,7 +331,7 @@ Each search result may represent either a video, a playlist, or a channel, so yo
331331``` csharp
332332using YoutubeExplode ;
333333
334- var youtube = new YoutubeClient ();
334+ using var youtube = new YoutubeClient ();
335335
336336await foreach (var result in youtube .Search .GetResultsAsync (" blender tutorials" ))
337337{
@@ -367,7 +367,7 @@ To limit the results to a specific type, use `Search.GetVideosAsync(...)`, `Sear
367367using YoutubeExplode ;
368368using YoutubeExplode .Common ;
369369
370- var youtube = new YoutubeClient ();
370+ using var youtube = new YoutubeClient ();
371371
372372var videos = await youtube .Search .GetVideosAsync (" blender tutorials" );
373373var playlists = await youtube .Search .GetPlaylistsAsync (" blender tutorials" );
@@ -379,7 +379,7 @@ Similarly to playlists, you can also enumerate results in batches by calling `Se
379379``` csharp
380380using YoutubeExplode ;
381381
382- var youtube = new YoutubeClient ();
382+ using var youtube = new YoutubeClient ();
383383
384384// Each batch corresponds to one request
385385await foreach (var batch in youtube .Search .GetResultBatchesAsync (" blender tutorials" ))
@@ -417,7 +417,7 @@ using YoutubeExplode;
417417var cookies = .. .;
418418
419419// Cookie collection must be of type IReadOnlyList<System.Net.Cookie>
420- var youtube = new YoutubeClient (cookies );
420+ using var youtube = new YoutubeClient (cookies );
421421```
422422
423423In order to actually perform the authentication, you can use an embedded browser such as [ WebView] ( https://nuget.org/packages/Microsoft.Web.WebView2 ) to navigate the user to the [ YouTube login page] ( https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fwww.youtube.com ) , let them log in, and then extract the cookies from the browser.
0 commit comments