public async Task Run() { try { string PageResponse = await RequestCurrentStatus(); if (PageResponse != null) { Player DownloadInfo = Player.RetrievePlayer(PageResponse); if (DownloadInfo.Quality == Quality.NotFound) { return; } string Title = ScrapeBit.FirstFrom(PageResponse, TITLE); string Path = FilePaths.GetLivestreamsPath(FileName.Purify($"{Title} [{DateTime.Now.Ticks.GetHashCode()}].mp4")); string Description = ScrapeBit.FirstFrom(PageResponse, DESCRIPTION); Console.WriteLine($"Found Livestream with Title: {Title} and Quality: {DownloadInfo.Quality}"); await Download(DownloadInfo.Url, Path); var Upload = new Youtube(FilePaths.SecretsFile); await Upload.Init(); _ = Upload.UploadWithRetry(new YoutubeUpload() { LivestreamPath = Path, Title = Title, Description = Description, ThumbnailPath = null }, TimeSpan.FromHours(3)); } } catch (Exception x) { Console.WriteLine($"Error in Check loop, Exception occurred: {x.Message}, please restart"); } }
public async Task <string> RequestCurrentStatus() { try { var client = new RestClient($"https://trovo.live/{Name}"); client.Timeout = -1; client.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"; var request = new RestRequest(Method.GET); IRestResponse PageResponse = await client.ExecuteAsync(request); if (PageResponse.Content == null) { return(null); } string BoolText = ScrapeBit.FirstFrom(PageResponse.Content, ISLIVE); if (BoolText == null) { return(null); } bool status = bool.Parse(BoolText.ToLower()); if (status) { return(PageResponse.Content); } else { return(null); } } catch (Exception) { return(null); } }