public static TimeSpan GetBrightcoveVideoLength(string video_id, ChromeDriver chrome, WebDriverWait wait, out bool cc, out string text) { chrome.Url = $"https://studio.brightcove.com/products/videocloud/media/videos/search/{video_id}"; string length; text = ""; try { length = wait.UntilElementIsVisible(By.CssSelector("div[class*=\"Thumbnail\"]")).Text; } catch { Console.WriteLine("Video not found"); length = "00:00"; cc = false; return(new TimeSpan(0)); } if ((length as string).Count(c => c == ':') < 2) { length = "00:" + length; } length = (length as string).RollOverTime(); try { chrome.FindElementsByCssSelector("div.name").Where(c => c.Text.Contains(video_id)).FirstOrDefault().FindElement(By.TagName("a")).Click(); cc = !wait.UntilElementExist(By.CssSelector("section#textTracksPanel")).Text.Contains("There are no text tracks"); } catch { cc = false; } try { var NameElement = wait.UntilElementExist(By.CssSelector("div[id*=\"video-name\"]")); text = "\nVideo name: " + NameElement.Text; } catch { text = "\nFailed to find video name"; } if (!TimeSpan.TryParseExact(length, @"h\:mm\:ss", null, out TimeSpan video_length)) { return(new TimeSpan(0)); } return(video_length); }
public static TimeSpan GetBYUMediaSiteVideoLength(string video_id, ChromeDriver chrome, WebDriverWait wait, out bool cc) { chrome.Url = $"https://byu.mediasite.com/Mediasite/Play/{video_id}"; dynamic length = null; try { wait.UntilElementIsVisible(By.CssSelector(".play-button")).Click(); while ("0:00" == length || "" == length || null == length) { length = wait.UntilElementIsVisible(By.CssSelector("span[class*=\"duration\"]")).Text; } } catch { try { while ("0:00" == length || "" == length || null == length) { length = wait.UntilElementIsVisible(By.CssSelector("span[class*=\"duration\"]")).Text; } } catch { Console.WriteLine("Video not found"); length = "00:00"; cc = false; return(new TimeSpan(0)); } } if ((length as string).Count(c => c == ':') < 2) { length = "00:" + length; } length = (length as string).RollOverTime(); cc = wait.UntilElementExist(By.CssSelector("button.cc.ui-button")).GetAttribute("aria-disabled") == "false" ? true : false; if (!TimeSpan.TryParseExact(length, "hh':'mm':'ss", null, out TimeSpan video_length)) { return(new TimeSpan(0)); } return(video_length); }
public static TimeSpan GetPanoptoVideoLength(string video_id, ChromeDriver chrome, WebDriverWait wait, out bool cc) { chrome.Url = $"https://byu.hosted.panopto.com/Panopto/Pages/Embed.aspx?id={video_id}&v=1"; while ((string)chrome.ExecuteScript("return document.readyState") != "complete") { } ; dynamic length = null; try { while (chrome.FindElementsByCssSelector("[id=copyrightNoticeContainer]").FirstOrDefault().Displayed) { } ; wait.UntilElementIsVisible(By.CssSelector("div#title")); wait.UntilElementIsVisible(By.CssSelector("div#playIconContainer")).Click(); length = wait.UntilElementIsVisible(By.CssSelector("span[class*=\"duration\"]")).Text; } catch { Console.WriteLine("Video not found"); length = "00:00"; cc = false; return(new TimeSpan(0)); } if ((length as string).Count(c => c == ':') < 2) { length = "00:" + length; } length = (length as string).RollOverTime(); cc = !wait.UntilElementExist(By.CssSelector("div.fp-menu.fp-subtitle-menu")).GetAttribute("outerHTML").ToLower().Contains("no subtitles"); if (!TimeSpan.TryParseExact(length, @"h\:mm\:ss", null, out TimeSpan video_length)) { return(new TimeSpan(0)); } return(video_length); }