Skip to content

Commit

Permalink
Fix to playlist search
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianusIV committed Jul 4, 2021
1 parent 0662deb commit 720e5ea
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ internal class Search
[STAThread]
static void Main(string[] args)
{
try
{
//try
//{
switch (args[0].ToUpper())
{
case "UPLOADS":
Expand All @@ -29,14 +29,14 @@ static void Main(string[] args)
Console.WriteLine("todo add help");
break;
}
}
catch (AggregateException ex)
{
foreach (var e in ex.InnerExceptions)
{
Console.Error.WriteLine("Error: " + e.Message);
}
}
//}
//catch (AggregateException ex)
//{
// foreach (var e in ex.InnerExceptions)
// {
// Console.Error.WriteLine("Error: " + e.Message);
// }
//}
}

private async Task RunUploads(string[] args)
Expand Down Expand Up @@ -106,6 +106,7 @@ private async Task RunPlaylists(string[] args)
//create a playlist request for all playlists of a channel
var playlistListRequest = youtubeService.Playlists.List("snippet");
playlistListRequest.ChannelId = args[Array.IndexOf(args, "-c") + 1];
playlistListRequest.MaxResults = 50;

List<Models.Playlist> playlists = new();
var playlistListResponse = await playlistListRequest.ExecuteAsync();
Expand All @@ -125,6 +126,7 @@ private async Task RunPlaylists(string[] args)
//build playlist request
var playlistItemListRequest = youtubeService.PlaylistItems.List("snippet,contentDetails");
playlistItemListRequest.PlaylistId = item.Id;
playlistItemListRequest.MaxResults = 50;

var playlistItemListResponse = await playlistItemListRequest.ExecuteAsync();
//for each available page of the response amount
Expand All @@ -133,6 +135,9 @@ private async Task RunPlaylists(string[] args)
//foreach video in the playlist
foreach (var video in playlistItemListResponse.Items)
{
//private videos have no timestamp lol
if (video.ContentDetails.VideoPublishedAt == null)
continue;
//add video to playlist
playlist.Videos.Add(new()
{
Expand Down

0 comments on commit 720e5ea

Please sign in to comment.