Esempio n. 1
0
        // [TestCase]
        public void SingleClientService_SpeedTest()
        {
            // DISABLE THIS TEST IF YOU DON'T NEED IT.

            byte[] bytes;
            var rawService = new VimeoService();

            using (var managedService = new SingleClientService(rawService))
            {
                var watch = Stopwatch.StartNew();

                for (int i = 0; i < 5; i++)
                    bytes = rawService.Download(VimeoUri);

                var rawTime = watch.Elapsed;
                watch.Restart();

                for (int i = 0; i < 5; i++)
                    bytes = managedService.Download(VimeoUri);

                var managedTime = watch.Elapsed;
                watch.Stop();

                var difference = managedTime - rawTime;
                Assert.That(difference > TimeSpan.Zero, $"Single client speed test failed! Difference is: {difference}.");
            }
        }
Esempio n. 2
0
        // [TestCase]
        public void Vimeo_DownloadMany()
        {
            // DISABLE THIS TEST IF YOU DON'T NEED IT.

            var service = new VimeoService();

            var byteArrays = service.DownloadMany(VimeoUri);

            foreach (var array in byteArrays);
        }
 internal VimeoChannelsEndpoint(VimeoService service) {
     Service = service;
 }
Esempio n. 4
0
        public void Vimeo_Download()
        {
            var service = new VimeoService();

            byte[] bytes = service.Download(VimeoUri);
        }
Esempio n. 5
0
 internal VimeoChannelsEndpoint(VimeoService service)
 {
     Service = service;
 }
 internal VimeoPeopleEndpoint(VimeoService service) {
     Service = service;
 }
Esempio n. 7
0
        public void UpdateVimeoVideos(string username)
        {
            if (string.IsNullOrWhiteSpace(username))
            {
                throw new ArgumentNullException("username");
            }

            // Map the path to the directory
            var savePath = IOHelper.MapPath(SaveDirectory);

            if (Directory.Exists(savePath) == false)
            {
                Directory.CreateDirectory(savePath);
            }

            // Map the path to the JSON file
            var path = savePath + "VimeoVideos_" + username + ".json";

            // Initialize a new service from an OAuth 2.0 access token
            var vimeo = VimeoService.CreateFromAccessToken(ConfigurationManager.AppSettings["VimeoAccessToken"]);

            var       page     = 1;
            const int maxPages = 10;

            // Initialize a list for all the videos
            var videos = new List <VimeoVideo>();

            // Create a loop for the pages
            while (page <= maxPages)
            {
                // Make the request to the Vimeo API
                var response = vimeo.Videos.GetVideos(username, page, 100);

                // Append the videos of the response to the list
                videos.AddRange(response.Body.Data);

                // Download the thumnails for each video
                foreach (var video in videos)
                {
                    var thumbnail = video.Pictures.Sizes.FirstOrDefault(x => x.Width >= 350);

                    const string mediaRoot     = "~/media/Vimeo";
                    var          thumbnailFile = IOHelper.MapPath($"{mediaRoot}/{video.Id}.jpg");

                    var mediaPath = IOHelper.MapPath(mediaRoot);
                    if (Directory.Exists(mediaPath) == false)
                    {
                        Directory.CreateDirectory(mediaPath);
                    }

                    if (File.Exists(thumbnailFile))
                    {
                        continue;
                    }

                    using (var client = new WebClient())
                        client.DownloadFile(thumbnail.Link, thumbnailFile);
                }

                // Break the loop if there are no further pages
                if (response.Body.Paging.Next == null)
                {
                    break;
                }

                // Increment the page count
                page++;
            }

            // Save the videos as a JSON file
            JsonUtils.SaveJsonArray(path, videos);
        }
Esempio n. 8
0
        public void Vimeo_Download()
        {
            var service = new VimeoService();

            byte[] bytes = service.Download(VimeoUri);
        }
 internal VimeoTestEndpoint(VimeoService service) {
     Service = service;
 }
Esempio n. 10
0
 internal VimeoTestEndpoint(VimeoService service)
 {
     Service = service;
 }
Esempio n. 11
0
 internal VimeoPeopleEndpoint(VimeoService service)
 {
     Service = service;
 }
 internal VimeoVideosEndpoint(VimeoService service) {
     Service = service;
 }
Esempio n. 13
0
 internal VimeoVideosEndpoint(VimeoService service)
 {
     Service = service;
 }
 internal VimeoUsersEndpoint(VimeoService service)
 {
     Service = service;
 }