/// <summary> /// Find the duration of a video from its provider and ID. This /// function can throw several exceptions if the process fails, but it /// can also return null if the duration can't be determined or if the /// provider is unrecognized. /// </summary /// <param name="provider">The video provider as given by jsVideoUrlParser, e.g. "youtube" or "vimeo"</param> /// <param name="id">The video ID</param> /// <param name="youTubeKey">A YouTube Data API v3 key. If not provided, all YouTube URLs will return a duration of null, as if they were not recognized.</param> /// <param name="twitchCredentials">Twitch API credentials. If not provided, all Twitch URLs will return null.</param> /// <returns>The duration, or null if the duration could not be determined.</returns> /// <exception cref="ArgumentNullException">id is null.</exception> /// <exception cref="WebException">An HTTP request failed or returned a status outside of the 200 range.</exception> /// <exception cref="FormatException">The duration could not be parsed.</exception> /// <exception cref="JsonReaderException">A JSON response could not be deserialized.</exception> /// <exception cref="YouTubeAPIException">A YouTube API error occurred.</exception> /// <exception cref="TooManyRequestsException">An API quota has been exceeded.</exception> /// <exception cref="VideoNotFoundException">No video was found at the given URL.</exception> public static async Task <TimeSpan?> GetAsync(string provider, string id, string youTubeKey = null, ITwitchCredentials twitchCredentials = null) { if (id == null) { throw new ArgumentNullException(nameof(id)); } switch (provider) { case "youtube": return(youTubeKey == null ? (TimeSpan?)null : await new YouTube(youTubeKey).GetDurationAsync(id)); case "vimeo": return(await Vimeo.GetDurationAsync(new Uri($"https://vimeo.com/{WebUtility.UrlEncode(id)}"))); case "dailymotion": return(await Dailymotion.GetDurationAsync(id)); case "twitch": return(await new Twitch(twitchCredentials).GetDurationAsync(id)); default: // Unrecognized provider return(null); } }
public void Parses_Vimeo_Url(string input, string url) { // Arrange var expected = $"class=\"hide video-vimeo\" data-url=\"{url}\">{url}</div>"; // Act var result = Vimeo.Parse(input); // Assert Assert.Contains(expected, result); }
private static List<VimeoVideo> GetVimeoResponse() { var rsp = new Vimeo(); var xmlSerializer = new XmlSerializer(rsp.GetType()); var xmlResult = HttpClient.Get(VimeoUrl); var xml = (Vimeo)xmlSerializer.Deserialize(new StringReader(xmlResult)); return xml.VimeoVideos; }
public async Task GetVideoWithHighQuality() { //arrange string videoId = "193970500"; //act Video video = await Vimeo.Download(videoId, VideoQuality.High); //assert Assert.AreNotEqual(0, video.Data.Length); Assert.AreNotEqual(string.Empty, video.FileName); }
static async Task Main(string[] args) { var filePath = "D:\\Pobrane - Chrome\\plikjson.txt"; var directoryPath = "C:\\Users\\Mateusz02\\Desktop\\Output"; var extension = ".mp4"; if (IsAdministrator() == false) { Console.WriteLine("You need to run this application as administrator"); throw new MemberAccessException("You need to run this application as administrator"); } while (File.Exists(filePath) == false) { Console.WriteLine($"Type path to json.txt file"); filePath = Console.ReadLine(); } while (Directory.Exists(directoryPath) == false) { Console.WriteLine($"Type path to output directory"); directoryPath = Console.ReadLine(); } JObject json; using (StreamReader file = new StreamReader(filePath)) { json = JObject.Parse(file.ReadToEnd()); } foreach (JProperty property in json.Properties()) { CustomFile obj = ProcessAddress(property.Name, property.Value.ToString(), extension, directoryPath); Directory.CreateDirectory(obj.FileDirectory); Video video = await Vimeo.Download(obj.videoId, VideoQuality.High); File.WriteAllBytes(obj.Filename, video.Data); } }
private static async Task <TimeSpan?> GetByNameAsync(Uri url, string youTubeKey = null, ITwitchCredentials twitchCredentials = null) { if (url == null) { throw new ArgumentNullException(); } if (url.AbsolutePath.EndsWith(".mp4", StringComparison.InvariantCultureIgnoreCase)) { // Assume MP4 return(await MP4.GetDurationAsync(url)); } else if (url.AbsolutePath.EndsWith(".m3u8", StringComparison.InvariantCultureIgnoreCase)) { // Assume HLS return(await HLS.GetPlaylistDurationAsync(url)); } else if (url.Authority.EndsWith("vimeo.com")) { return(await Vimeo.GetDurationAsync(url)); } else if (url.Authority.EndsWith("youtube.com") || url.Authority.EndsWith("youtu.be")) { return(youTubeKey == null ? null : await new YouTube(youTubeKey).GetDurationAsync(url)); } else if (url.Authority.EndsWith("dailymotion.com") || url.Authority.EndsWith("dai.ly")) { return(await Dailymotion.GetDurationAsync(url)); } else if (url.Authority.EndsWith("twitch.tv")) { return(await new Twitch(twitchCredentials).GetDurationAsync(url)); } else if (url.Authority.EndsWith("soundcloud.com")) { return(await SoundCloud.GetDurationAsync(url)); } else { return(null); } }
/// <summary> /// Initialises the object with a given Video URL /// </summary> /// <param name="VideoUrl">The URL to a Youtube or Vimeo Video</param> public VideolizerVideo(string VideoUrl) { this.Url = VideoUrl; string vidId = YouTube.GetVideoId(VideoUrl); if (vidId != null) { //Its a Youtube Clip. this.Id = vidId; this.Type = VideoTypes.YouTube; this.EmbedUrl = "//www.youtube.com/embed/" + vidId; } else { vidId = Vimeo.GetVideoId(VideoUrl); if (vidId != null) { //Its a Vimeo Clip. this.Id = vidId; this.Type = VideoTypes.Vimeo; this.EmbedUrl = "//player.vimeo.com/video/" + vidId; } } }
/// <summary> /// Create a new instance /// </summary> /// <param name="vimeo"></param> public VimeoOnDemand(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Create a new instance /// </summary> /// <param name="vimeo"></param> public VimeoTags(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
public string vimeoVidId(string url) { return(Vimeo.GetVideoId(url)); }
/// <summary> /// Create a new instance of VimeoAuthenticationExtras class /// </summary> /// <param name="vimeo"></param> public VimeoAuthenticationExtras(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Root Authorization /// </summary> public RestBuilder RootAuthorization() => Vimeo.RootAuthorization();
/// <summary> /// Create a new instance /// </summary> /// <param name="vimeo"></param> public VimeoGroups(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Create a new instance /// </summary> /// <param name="vimeo"></param> public VimeoShowCases(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Create a new instance /// </summary> /// <param name="vimeo"></param> public VimeoPortfolios(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Create a new instance /// </summary> /// <param name="vimeo"></param> public VimeoEmbedPresets(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Create a new instance /// </summary> /// <param name="vimeo"></param> public VimeoVideos(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Create a new instance of VimeoAPIInformation class /// </summary> /// <param name="vimeo"></param> public VimeoAPIInformation(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Create a new instance /// </summary> /// <param name="vimeo"></param> public VimeoLive(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Create a new instance of VimeoCategories class /// </summary> /// <param name="vimeo"></param> public VimeoCategories(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Create a new instance /// </summary> /// <param name="vimeo"></param> public VimeoFolders(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Create a new instance /// </summary> /// <param name="vimeo"></param> public VimeoChannels(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }
/// <summary> /// Create a new instance /// </summary> /// <param name="vimeo"></param> public VimeoTeamMembers(Vimeo vimeo) { Vimeo = vimeo; Properties = vimeo.Properties; }