Ejemplo n.º 1
0
        public void GetVideoID_CanGetVideoID(params string[] videoUrls)
        {
            //Act
            string[] videoIds = new string[videoUrls.Length];
            for (int i = 0; i < videoUrls.Length; i++)
            {
                videoIds[i] = target.GetVideoID(videoUrls[i]);
            }

            //Assert
            Assert.Equal("Bey4XXJAqS8", videoIds[0]);
            Assert.Equal("HmZKgaHa3Fg", videoIds[1]);
            Assert.Equal("2MpUj-Aua48", videoIds[2]);
            Assert.Equal("LXb3EKWsInQ", videoIds[3]);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetVideoMetaData(string videoUrl)
        {
            VideoDetails details;

            try
            {
                details = await clientHelper.GetVideoMetadataAsync(clientHelper.GetVideoID(videoUrl));
            }
            catch (FormatException)
            {
                return(BadRequest("Provided URL is incorrect"));
            }
            return(Ok(details));
        }
Ejemplo n.º 3
0
 private async Task <VideoDetails> GetVideoDetails(string ytUrl)
 {
     if (!IsValidUrl(ytUrl))
     {
         return(null);
     }
     try
     {
         return(await clientHelper.GetVideoMetadata(clientHelper.GetVideoID(ytUrl)));
     }
     catch (Exception ex)
     {
         // todo: handle error
     }
     return(null);
 }