Exemple #1
0
        public static async Task <string> requestAsync(HttpClient client, string channelId)
        {
            Uri url = new Uri("https://www.googleapis.com/youtube/v3/search")
                      .AddQuery("part", "snippet")
                      .AddQuery("channelId", channelId)
                      .AddQuery("type", "video")
                      .AddQuery("eventType", "upcoming")
                      .AddQuery("key", getToken());

            // AlConsole.WriteLine(DefaultScheme.REQUEST_SCHEME, url.ToString().Substring(0, 129) + "[SECRET TOKEN]");
            AlExtension.ColorizeWrite(DefaultScheme.REQUEST_SCHEME, $"情報をリクエスト ^: ^ChannelId [ ^{channelId, -16} ^] ^/ ",
                                      new [] { ConsoleColor.Green, ConsoleColor.DarkGray, ConsoleColor.Magenta, ConsoleColor.Cyan, ConsoleColor.Magenta, ConsoleColor.DarkGray });
            string result = ReSpell.Execute(5, 5,
                                            () => client.GetStringAsync(url).Result,
                                            (c) => {
                Console.Write($"Retry ({c})");
                Console.CursorLeft = 124;
                Settings.UseQuota += 101;
            }, (c) => {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Failure  \n");
                Console.ResetColor();
            });

            Console.WriteLine("Success.");
            Settings.UseQuota += 101;
            return(result);
        }
Exemple #2
0
        public static async Task <string> RequestStartTimeAsync(HttpClient client, string videoIds /*string[] videoId */)
        {
            Uri url = new Uri("https://www.googleapis.com/youtube/v3/videos?")
                      .AddQuery("part", "liveStreamingDetails")
                      .AddQuery("key", getToken())
                      .AddQuery("id", videoIds);
            //.AddArrayQuery("id", videoId);
            string res = ReSpell.Execute(5, 5,
                                         () => client.GetStringAsync(url).Result,
                                         (c) => AlConsole.WriteLine(DefaultScheme.REQUEST_SCHEME, $"Retry Request... [ Count: {c}]"));

            //foreach (string value in videoId) {
            //    AlConsole.WriteLine(DefaultScheme.REQUEST_SCHEME, $"  #-- {value, 15}");
            //}
            Settings.UseQuota += 8;
            return(res);
        }