Exemplo n.º 1
0
 public static DateTime?GetRecordingDate(this TwitchVideo video)
 {
     if (video is null)
     {
         throw new ArgumentNullException(nameof(video));
     }
     if (!string.IsNullOrWhiteSpace(video.CreatedAt) &&
         DateTime.TryParse(video.CreatedAt, out DateTime rv))
     {
         return(rv);
     }
     if (!string.IsNullOrWhiteSpace(video.PublishedAt) &&
         DateTime.TryParse(video.PublishedAt, out rv))
     {
         return(rv);
     }
     return(null);
 }
Exemplo n.º 2
0
        private static async Task <string> UploadVideoAsync(
            BrowserCredential credential,
            FileInfo videoFile,
            TwitchVideo video)
        {
            string description = video.Description;

            HashSet <string> playlists = new()
            {
                "C# Programming"
            };
            HashSet <string> tags = new()
            {
                "programming"
            };

            if (video.Title.Contains("C#"))
            {
                tags.Add("C#");
            }
            if (video.Title.Contains("WPF"))
            {
                tags.Add("C#");
                tags.Add("WPF");
            }
            if (video.Title.Contains("XAML"))
            {
                tags.Add("XAML");
            }
            if (video.Title.Contains("Material Design"))
            {
                description += Environment.NewLine + Environment.NewLine + "Material Design In XAML Project: https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit";
                tags.Add("material design");
                playlists.Add("Material Design in Xaml");
            }
            if (video.Title.Contains("System.CommandLine"))
            {
                tags.Add("C#");
                tags.Add("command line");
                tags.Add("System.CommandLine");
                playlists.Add("System.CommandLine");
                description += Environment.NewLine + Environment.NewLine + "System.CommandLine: https://github.com/dotnet/command-line-api";
            }
            if (video.Title.Contains("terraform"))
            {
                tags.Add("terraform");
                tags.Add("azure");
                tags.Add("devops");
                playlists.Add("Terraform");
                playlists.Add("DevOps");
                playlists.Add("Azure");
            }
            if (video.Title.Contains("DevOps"))
            {
                tags.Add("devops");
                playlists.Add("DevOps");
            }
            if (video.Title.Contains("GitHub"))
            {
                tags.Add("github");
            }
            if (video.Title.Contains("Azure"))
            {
                tags.Add("azure");
            }
            if (video.Title.Contains("WinUI"))
            {
                tags.Add("winui");
            }

            description += Environment.NewLine + Environment.NewLine + $"Broadcasted live on Twitch -- Watch live at https://twitch.keboo.dev";

            DateTime recordingDate = video.GetRecordingDate() ?? DateTime.UtcNow.Date;

            YouTubeBrowser browser = new(credential.Username, credential.Password, credential.RecoveryEmail);

            return(await browser.UploadAsync(videoFile, video.Title, description, recordingDate, playlists, tags));
        }

        private static async Task DeleteFile(FileInfo file)