private static async Task <int> Index(IndexOptions options) { options.Init(); var youtubeService = await GetYouTubeService(); Log.Logger.Information("Getting channel info for {channelId}...", options.ChannelId); var channel = await GetChannel(options.ChannelId, youtubeService); Log.Logger.Information("Getting uploaded videos for channel {channel}...", channel.Title); var videos = await GetVideos(channel, youtubeService); Log.Logger.Information("Saving index.json..."); var destinationFile = Path.Combine(options.IndexDirectory, "index.json"); if (File.Exists(destinationFile)) { File.Delete(destinationFile); } File.WriteAllText(destinationFile, JsonConvert.SerializeObject(new YouTubeDumpChannelIndex { Channel = channel, Videos = videos }, Formatting.Indented)); Log.Logger.Information("Indexed!"); return(0); }