Beispiel #1
0
        static void Main(string[] args)
        {
            var configuration = new ConfigurationBuilder()
                                .AddUserSecrets(Assembly.GetEntryAssembly())
                                .Build();

            var service = new YouTubeService(new BaseClientService.Initializer()
            {
                ApiKey = configuration["YouTubeApiKey"]
            });

            var playlistId = service.GetUploadPlaylist("CaseyNeistat");

            var items = service.GetAllItems(playlistId);

            File.WriteAllText($"{playlistId}.json", JsonConvert.SerializeObject(items.Select(i => new
            {
                title       = i.Snippet.Title,
                videoId     = i.Snippet.ResourceId.VideoId,
                publishedAt = i.Snippet.PublishedAt
            })));

            Console.WriteLine($"Downloaded {playlistId}");
        }