static async Task Main() { LogUtil.ConfigurarLog("Clipper.ConsoleApp"); try { var TopGames = Twitch.GetTopGames(); var GameClips = new Dictionary <GameInfo, List <(ClipInfo, string)> >(); int Top = 5; foreach (var game in TopGames.data.Where(x => x.id != "509663").Take(6)) { var LocalClipPaths = new List <(ClipInfo, string)>(); var Id = int.TryParse(game.id, out int Result) ? Result : 0; if (Id == 0) { continue; } var Clips = Twitch.GetTopClips(Id, Top, new DateRange(DateTime.Now.AddDays(-1), DateTime.Now)); foreach (var c in Clips.data) { var ClipPath = await Twitch.DownloadClipAsync(c); if (ClipPath != null) { LocalClipPaths.Add((c, ClipPath)); } } GameClips.Add(game, LocalClipPaths.OrderBy(x => x.Item2).Select(x => (x.Item1, x.Item2)).ToList()); } var StartDate = DateTimeOffset.Now.AddHours(2); foreach (var gameclips in GameClips) { try { string FileName = $"TOP {gameclips.Value.Count} {(gameclips.Key.name == "Just Chatting" ? "IRL" : gameclips.Key.name)} TWITCH CLIPS {DateTime.Now.ToString("MMM-dd", new CultureInfo("en-US"))} {string.Join(", ", gameclips.Value.Select(x => x.Item1.broadcaster_name).Distinct())}".RemoveInvalidChars().Truncate(100); var OutputDir = Path.Combine(ExeFolder, DateTime.Now.ToString("yyyy_MMM_dd", new CultureInfo("en-US"))); Directory.CreateDirectory(OutputDir); var OutputPath = Path.Combine(OutputDir, FileName); var Result = FFMpegLib.Merge(OutputPath + ".mp4", gameclips.Value.OrderBy(x => x.Item2).Select(x => x.Item2).ToArray()); var Tags = BuildTags(gameclips); string Description = BuildDescription(gameclips, Result); BuildMetadata(gameclips, FileName, OutputDir, Result); await YouTube.UploadClipAsync(Result.MergedPath, Title : FileName, Privacy : PrivacyStatus.Private, Tags : Tags, Description : Description, PublishAtUtc : StartDate); StartDate = StartDate.AddHours(3); } catch (Exception ex) { LogUtil.Log(ex); } } HandleComments(); Directory.GetFiles(ExeFolder, "*.ts").Union(Directory.GetFiles(ExeFolder, "*.mp4")).ToList().ForEach(x => FFMpegHelper.TryDelete(x)); } catch (Exception ex) { LogUtil.Log(ex); } }