Exemplo n.º 1
0
        public async Task <VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Album> > AlbumleriGetirHizliAsync(int Page, string Query)
        {
            VimeoDotNet.VimeoClient client = new VimeoDotNet.VimeoClient(TokenKey.Token);
            VimeoDotNet.Parameters.GetAlbumsParameters parametreler = new VimeoDotNet.Parameters.GetAlbumsParameters();
            parametreler.Page      = Page;
            parametreler.PerPage   = 50;
            parametreler.Query     = Query;
            parametreler.Sort      = GetAlbumsSortOption.Date;
            parametreler.Direction = GetAlbumsSortDirectionOption.Desc;
            parametreler.Fields    = "name,uri";


            try
            {
                VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Album> albumler = await client.GetAlbumsAsync(VimeoDotNet.Models.UserId.Me, parametreler);

                return(albumler);
            }
            catch (Exception ex)
            {
                if (client.RateLimitRemaining == 0)
                {
                    throw new Exception("Çok fazla istek nedeniyle api erişimi engellendi." + (client.RateLimitReset.AddHours(1) - System.DateTime.Now).TotalMinutes + " dakika sonra tekrar deneyiniz.");
                }
                else
                {
                    throw new Exception(ex.Message);
                }
            }
        }
Exemplo n.º 2
0
        public async Task <VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Album> > AlbumleriGetirAsync()
        {
            VimeoDotNet.VimeoClient client = new VimeoDotNet.VimeoClient(TokenKey.Token);
            string[] fields = { "name", "uri", "link", "created_time", "metadata.connections" };

            VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Album> albumler = await client.GetAlbumsAsync(VimeoDotNet.Models.UserId.Me, fields);

            return(albumler);
        }
Exemplo n.º 3
0
        public async Task <Video> GetVideoId(string oldVideoName)
        {
            vimeoManager = new VimeoManager();
            VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Video> videolarTek = await vimeoManager.VideolariGetirBirAdetAsync(1, oldVideoName);

            var result = videolarTek.Data.FirstOrDefault();

            return(result);
        }
Exemplo n.º 4
0
        // videoları getir 1 adet video için
        public async Task <VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Video> > VideolariGetirBirAdetAsync(int?Page, string query)
        {
            //VimeoDotNet.VimeoClient client1 = new VimeoDotNet.VimeoClient("885d14518da612dac4bd9f06a877b7e1");
            VimeoDotNet.VimeoClient client1 = new VimeoDotNet.VimeoClient(TokenKey.Token);//kendim


            VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Video> videolar = await client1.GetVideosAsync(Page, 1, query, new string[4] {
                "uri", "name", "created_time", "pictures"
            });

            return(videolar);
        }
Exemplo n.º 5
0
        public async Task <VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Video> > VideolariGetirAsync(int?Page, string query)
        {
            VimeoDotNet.VimeoClient client1 = new VimeoDotNet.VimeoClient(TokenKey.Token);



            VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Video> videolar = await client1.GetVideosAsync(Page, 50, query, new string[4] {
                "uri", "name", "created_time", "pictures"
            });

            return(videolar);
        }
Exemplo n.º 6
0
        public async Task <VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Album> > AlbumleriGetirAsync(int Page, string Query)
        {
            VimeoDotNet.VimeoClient client = new VimeoDotNet.VimeoClient(TokenKey.Token);
            string[] fields = { "name", "uri", "link", "created_time", "metadata.connections" };

            GetAlbumsParameters parametreler = new GetAlbumsParameters();

            parametreler.Page      = Page;
            parametreler.PerPage   = 50;
            parametreler.Query     = Query;
            parametreler.Sort      = GetAlbumsSortOption.Date;
            parametreler.Direction = GetAlbumsSortDirectionOption.Desc;


            VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Album> albumler = await client.GetAlbumsAsync(VimeoDotNet.Models.UserId.Me, fields, parametreler);

            return(albumler);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Returns a List of VideoInfo objects with all video info from a user.
        /// </summary>
        /// <param name="client">The VimeoClient to use.</param>
        /// <param name="width">The closest width of the image url to return. Default is 1920px.</param>
        public List <VideoInfo> GetVideos(VimeoClient client, long userId, int width = 1920)
        {
            var retVal = new List <VideoInfo>();
            var videos = new List <VimeoDotNet.Models.Video>();

            int page = 1;

            while (page > 0)
            {
                VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Video> pagedVideos = null;
                var task = Task.Run(async() =>
                {
                    pagedVideos = await client.GetUserVideosAsync(userId, page, null);
                });
                task.Wait();

                videos.AddRange(pagedVideos.data);

                int num = 0;

                if (pagedVideos.paging.next != null)
                {
                    int.TryParse(pagedVideos.paging.next.Split('=').Last(), out num);
                }

                page = num;
            }

            foreach (var video in videos)
            {
                var videoInfo = new VideoInfo();

                videoInfo.vimeoId = ( long )video.id;
                videoInfo.name    = video.name;
                if (string.IsNullOrWhiteSpace(video.description))
                {
                    videoInfo.description = string.Empty;
                }
                else
                {
                    videoInfo.description = string.Format("<p>{0}</p>", video.description.Replace("\n", "<br>"));
                }
                videoInfo.duration = video.duration;
                videoInfo.hdLink   = video.HighDefinitionVideoSecureLink;
                videoInfo.sdLink   = video.StandardVideoSecureLink;
                videoInfo.hlsLink  = video.StreamingVideoSecureLink;

                if (video.pictures != null)
                {
                    //
                    // for 0.8.x vimeo dot net structure
                    //

                    var pictures = video.pictures.ToList();
                    var picSizes = pictures.FirstOrDefault(p => p.active == true).sizes.ToList();

                    //
                    // for > 0.8.x vimeo dot net structure
                    //
                    //var picSizes = video.pictures.sizes.ToList();

                    if (picSizes.Count > 0)
                    {
                        videoInfo.imageUrl = picSizes.Aggregate((x, y) => Math.Abs(x.width - width) < Math.Abs(y.width - width) ? x : y).link;
                    }
                }

                retVal.Add(videoInfo);
            }

            return(retVal);
        }
Exemplo n.º 8
0
        async Task <List <ModelView> > IServiceAlbum.GetVideoGertir(string VideoAdi)
        {
            vimeoManager = new VimeoManager();

            List <ModelView> AllVideos = new List <ModelView>();

            VimeoDotNet.Models.Paginated <VimeoDotNet.Models.Video> videolarTek = await vimeoManager.VideolariGetirBirAdetAsync(1, VideoAdi);


            int totalVideo = videolarTek.Total;
            int perPage    = 50;
            var totalPages = (int)Math.Ceiling((decimal)totalVideo / (decimal)perPage);


            for (int i = 1; i <= totalPages; i++)
            {
                Paginated <Video> videolar = await vimeoManager.VideolariGetirAsync(i, VideoAdi);



                videolar.Data = videolar.Data.OrderBy(x => x.CreatedTime).ToList();


                foreach (var item in videolar.Data)
                {
                    // eğer videnamenin sonunda (1) gibi parantez varsa ayıkla
                    int parantez = item.Name.IndexOf('(');
                    if (parantez != -1)
                    {
                        item.Name = item.Name.Substring(0, parantez);
                    }

                    var videoNumber = item.Name.Split('-');
                    // eğer aynı numaralı 2 video varsa resmi olmayanı sil


                    foreach (var item1 in AllVideos)
                    {
                        if (item.Name == item1.VideoName)
                        {
                            AllVideos.Remove(item1);
                            break;
                        }
                    }

                    ModelView model = new ModelView
                    {
                        VideoId      = item.Id.Value,
                        VideoName    = item.Name,
                        Picture      = item.Pictures,
                        ModifiedDate = item.CreatedTime,
                        VideoNumber  = Convert.ToInt32(videoNumber.Last()) //videonameyi parse yap ve sondaki sayı numarasını al
                    };

                    AllVideos.Add(model);
                }
            }

            AllVideos = AllVideos.OrderBy(X => X.VideoName).ToList();

            return(AllVideos);
        }