Beispiel #1
0
        public void smth()
        {
            VkCollection <Audio> audio = api.Audio.Get(new AudioGetParams
            {
                OwnerId = 597417716
            });


            List <AudioFile> audioFile = new List <AudioFile>();

            try
            {
                foreach (var item in audio)
                {
                    if (item.Url != null)
                    {
                        audioFile.Add(new AudioFile {
                            performer = item.Artist, title = item.Title, url = AudioFile.DecodeAudioUrl(item.Url)
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            foreach (var item in audioFile)
            {
                Console.WriteLine(item.url);
            }


            IEnumerable <Audio> audioo = api.Audio.GetPopular();


            List <AudioFile> audioFilee = new List <AudioFile>();

            try
            {
                foreach (var item in audioo)
                {
                    if (item.Url != null)
                    {
                        audioFilee.Add(new AudioFile {
                            performer = item.Artist, title = item.Title, url = AudioFile.DecodeAudioUrl(item.Url)
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            foreach (var item in audioFilee)
            {
                Console.WriteLine(item.url);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Get a VK user playlist into \servers\*current server*\*userid*.dat
        /// </summary>
        /// <param name="api">VK account</param>
        /// <param name="ownerid">VK user's id</param>
        /// <param name="guildid">User's guildid</param>
        /// <returns></returns>
        public static async Task GetPlaylistInFile(VkApi api, int ownerid, ulong guildid)
        {
            VkCollection <Audio> audios = null;

            try
            {
                audios = await api.Audio.GetAsync(new VkNet.Model.RequestParams.AudioGetParams {
                    OwnerId = ownerid
                });
            }
            catch (Exception)
            {
                Console.WriteLine(new LogMessage(LogSeverity.Error, "Vk.net", "Cant get audio(Token confirmation)"));

                return;
            }

            Audio[] audio = audios.ToArray();

            BinaryFormatter formatter = new BinaryFormatter();

            string uri = $@"{Directory.GetCurrentDirectory()}\servers\{guildid}\{ownerid}.dat";

            using (FileStream fs = new FileStream(uri, FileMode.OpenOrCreate, FileAccess.Write))
            {
                formatter.Serialize(fs, audio);
            }

            await Task.CompletedTask;
        }
Beispiel #3
0
        public void JsonConvertWrite()
        {
            var vkCollection = new VkCollection <User>(totalCount: 10,
                                                       list: new List <User>
            {
                new User
                {
                    Id        = 12,
                    FirstName = "Andrew",
                    LastName  = "Teleshev"
                },
                new User
                {
                    Id        = 13,
                    FirstName = "Даниил",
                    LastName  = "Рыльцов"
                }
            });

            var result = Utilities.SerializeToJson(@object: vkCollection);

            Assert.AreNotEqual(expected: result, actual: "{}");
            var attribute = Attribute.GetCustomAttribute(element: typeof(VkCollection <>), attributeType: typeof(DataContractAttribute));

            Assert.That(actual: attribute, expression: Is.Null);
        }
Beispiel #4
0
        private void DownloadCommentsButton_Click(object sender, EventArgs e)
        {
            long PostID = long.Parse(Posts.CurrentRow.Cells[0].Value.ToString());
            WallGetCommentsParams wallparams = new WallGetCommentsParams();

            wallparams.Count     = 100;
            wallparams.OwnerId   = chosenGroup().groupID;
            wallparams.PostId    = PostID;
            wallparams.Sort      = 0; // Desc
            wallparams.NeedLikes = true;

            using (FileStream fstream = new FileStream(PostID.ToString() + ".txt", FileMode.Create))
            {
                int AllLikesCount = GetNumberOfComments(PostID);
                int i             = 0;
                while (AllLikesCount > 0)
                {
                    wallparams.Offset = i * 100;
                    VkCollection <Comment> comments = vkApi.Wall.GetComments(wallparams);
                    foreach (var it in comments)
                    {
                        PrintFoFile(fstream, it.FromId + " Likes:" + it.Likes.Count + " Text:" + it.Text + " ");
                    }
                    i++;
                    AllLikesCount -= 100;
                }
                MessageBox.Show("Comments save to file");
            }
        }
        private InfoGroup GetMapperMembersGroup(VkCollection <User> groupInfo)
        {
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap <VkCollection <User>, InfoGroup>()
                                                 .ForMember("CountSubscribers", src => src.MapFrom(p => p.TotalCount))).CreateMapper();

            return(mapper.Map <VkCollection <User>, InfoGroup>(groupInfo));
        }
Beispiel #6
0
 public void DownloadAllMusic()
 {
     AudioList = GetAllAudio();
     if (AudioList != null || AudioList.Count != 0)
     {
         using (WebClient client = new WebClient())
         {
             foreach (var audio in AudioList)
             {
                 string   path = $@"{Properties.Resources.MusicFolderPath}{Account.Name}\{audio.Title} - {audio.Artist}.mp3";
                 FileInfo file = new FileInfo(path);
                 if (Directory.Exists(Properties.Resources.MusicFolderPath + Account.Name))
                 {
                     if (!file.Exists)
                     {
                         client.DownloadFile(audio.Url, path);
                     }
                 }
                 else
                 {
                     Directory.CreateDirectory(Properties.Resources.MusicFolderPath + Account.Name);
                 }
             }
         }
     }
     else
     {
         MusicMessageBox box = new MusicMessageBox();
         box.Show();
         box.ShowWindow(null, Properties.Resources.NoMusicToDownloadText + "\n\rThanks form using our product.");
     }
 }
Beispiel #7
0
        public void JsonConvertWrite()
        {
            var vkCollection = new VkCollection <User>(10,
                                                       new List <User>
            {
                new User
                {
                    Id        = 12,
                    FirstName = "Andrew",
                    LastName  = "Teleshev"
                },
                new User
                {
                    Id        = 13,
                    FirstName = "Даниил",
                    LastName  = "Рыльцов"
                }
            });

            var result = Utilities.SerializeToJson(vkCollection);

            Assert.AreNotEqual(result, "{}");
            var attribute = Attribute.GetCustomAttribute(typeof(VkCollection <>), typeof(DataContractAttribute));

            Assert.That(attribute, Is.Null);
        }
Beispiel #8
0
        public async Task <List <Post> > GetUserWallPostsAsync(User user)
        {
            List <Post> result = new List <Post>();

            ulong maxPostsBatch   = 100;
            ulong postsOffset     = 0;
            bool  postsFinished   = false;
            int   borderTimestamp = (int)DateTime.UtcNow.AddMonths(-3).ToUnixTimestamp();
            long  targetUserId    = user.Id;

            while (!postsFinished)
            {
                VkResponse wallPostsResponse = null;

                try
                {
                    var parametr = new VkParameters
                    {
                        { "user", targetUserId }, { "offset", postsOffset }, { "deadline", borderTimestamp }
                    };

                    var yyy = await UserApi.Execute.StoredProcedureAsync <JObject>("GetUserWall", parametr);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error getting wall posts for user " + targetUserId + ": " + e);
                }

                if (!string.IsNullOrEmpty(wallPostsResponse?.RawJson))
                {
                    VkCollection <Post> postCollection = wallPostsResponse.ToVkCollectionOf <Post>(p => p);

                    if (postCollection.Count > 0)
                    {
                        result.AddRange(postCollection);

                        if (postCollection.Count < (int)maxPostsBatch)
                        {
                            postsFinished = true;
                        }
                        else
                        {
                            postsOffset = (ulong)result.Count;
                        }
                    }
                    else
                    {
                        postsFinished = true;
                    }
                }
                else
                {
                    postsFinished = true;
                }
            }

            return(result);
        }
Beispiel #9
0
        public VkCollection <Audio> GetAudioFromProfile(int userId)
        {
            VkCollection <Audio> audio = api.Audio.Get(new AudioGetParams
            {
                OwnerId = userId
            });

            return(audio);
        }
Beispiel #10
0
        public async Task <List <User> > GetMembersAsync()
        {
            List <User> result = new List <User>();

            var groupId = Group.Id;

            GroupsGetMembersParams groupMembersCountParams = new GroupsGetMembersParams
            {
                GroupId = groupId.ToString(),
                Fields  = UsersFields.Status | UsersFields.Counters
                          | UsersFields.Sex | UsersFields.City | UsersFields.Country
                          | UsersFields.BirthDate | UsersFields.PhotoMaxOrig | UsersFields.Site
            };

            long communityOffset          = 0;
            bool communityMembersFinished = false;
            long maxCommunityMembersBatch = 1000;

            while (!communityMembersFinished)
            {
                GroupsGetMembersParams communityMembersParams = new GroupsGetMembersParams
                {
                    GroupId = groupId.ToString(),
                    Fields  = UsersFields.Counters,
                    Offset  = communityOffset,
                    Sort    = GroupsSort.IdAsc,
                    Count   = maxCommunityMembersBatch
                };

                List <User> membersBatch;

                try
                {
                    VkCollection <User> vkResult = await Vk.ServiceApi.Groups.GetMembersAsync(communityMembersParams);

                    membersBatch = vkResult.ToList();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error getting members for community " + groupId + ": " + e);
                    throw;
                }

                if (membersBatch.Count > 0)
                {
                    result.AddRange(membersBatch);
                    communityOffset = result.Count;
                }

                if (membersBatch.Count < maxCommunityMembersBatch)
                {
                    communityMembersFinished = true;
                }
            }

            return(result);
        }
Beispiel #11
0
        static VkCollection <User> GetFriends()
        {
            VkCollection <User> Friends = vkapi.Friends.Get(new FriendsGetParams
            {
                UserId = vkapi.UserId,
                Fields = ProfileFields.FirstName | ProfileFields.LastName,
                Order  = FriendsOrder.Name
            });

            return(Friends);
        }
Beispiel #12
0
        public VkCollection <Audio> GetAudioSearch(string searchText)
        {
            VkCollection <Audio> audio = api.Audio.Search(new AudioSearchParams
            {
                Query        = searchText,
                Count        = 5,
                Autocomplete = true
            });

            return(audio);
        }
Beispiel #13
0
        private ImageResult GetMapperImage(VkCollection <Photo> images)
        {
            var mapper = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <VkCollection <Photo>, ImageResult>()
                .ForMember("Images", src => src.MapFrom(p => p.ToCollection()));
                cfg.CreateMap <Photo, Entities.Images.Image>()
                .ForMember("Title", src => src.MapFrom(p => p.Text));
            }).CreateMapper();

            return(mapper.Map <VkCollection <Photo>, ImageResult>(images));
        }
Beispiel #14
0
        public async Task <IReadOnlyList <T> > GetAllPagesAsync <T>(PageGetter <T> pageGetter, decimal pageSize, CancellationToken token, ILog log, bool throwIfCountMismatch = false)
        {
            var firstPage = await pageGetter(pageSize, 0);

            var total = firstPage.TotalCount;

            log.Debug($"{0}/{total}, {firstPage.Count} items");

            var result = new HashSet <T>((int)total);

            result.AddUnique(firstPage, log);

            var remainingPages = total / pageSize;
            var pageTasks      = Enumerable.Range(1, (int)remainingPages)
                                 .Select(pageNumber => (ulong)pageNumber * pageSize)
                                 .Select(async offset =>
            {
                VkCollection <T> page = null;
                try
                {
                    page = await pageGetter(pageSize, offset);
                    log.Debug($"{offset}/{total}, {page.Count} items");
                }
                catch (Exception e)
                {
                    log.Warn($"Error getting page {offset}/{total}. Getting page by smaller chunks...", e);
                    var items = await GetSinglePage(pageGetter, offset, pageSize, token, log);
                    page      = new VkCollection <T>(0, items);
                }

                token.ThrowIfCancellationRequested();
                return(page ?? new VkCollection <T>(0, new List <T>()));
            });
            var pages = await Task.WhenAll(pageTasks);

            foreach (var page in pages)
            {
                result.AddUnique(page, log);
            }

            if ((int)total != result.Count)
            {
                var message = $"Expected {total} items, got {result.Count}. Maybe they were created/deleted, or it's VK bugs again.";
                log.Warn(message);
                if (throwIfCountMismatch)
                {
                    throw new InvalidOperationException(message);
                }
            }

            return(result.ToList());
        }
Beispiel #15
0
            public Photo getLastPhoto()
            {
                var photo = _listPhotos[numGetPhoto];

                numGetPhoto++;
                if ((ulong)(numGetPhoto + 1) == _count)
                {
                    numGetPhoto = 0;
                    numChangeListPhotos++;
                    _listPhotos = getListPhotos(_count, numChangeListPhotos * _count, _idUser);
                }

                return(photo);
            }
Beispiel #16
0
 public Playlist(VkCollection <Audio> playlist, string titlePlaylist, long idPlaylist, string urlPhoto)
 {
     Title    = titlePlaylist;
     Id       = idPlaylist;
     PhotoUrl = urlPhoto;
     foreach (var song in playlist)
     {
         if (song.Url != null)
         {
             Songs.Add(new Song(song.Title, song.Artist, song.Duration, song.Url.ToString()));
         }
     }
     CountSongs = Songs.Count;
 }
Beispiel #17
0
        void SaveLikesFromPostToFile(long GroupID, long PostID, FileStream fstream)
        {
            int AllLikesCount = 0;

            WallGetParams wallParam = new WallGetParams();

            wallParam.OwnerId = GroupID;
            wallParam.Count   = maxPostFromVkDatabase;


            WallGetObject wallObjects = vkApi.Wall.Get(wallParam);



            foreach (var post_it in wallObjects.WallPosts)
            {
                AllLikesCount = post_it.Likes.Count;
                if (post_it.Id != PostID)
                {
                    continue;
                }

                LikesGetListParams likeParams = new LikesGetListParams();
                likeParams.Type     = LikeObjectType.Post;
                likeParams.ItemId   = PostID;
                likeParams.Extended = true;
                likeParams.OwnerId  = GroupID;
                likeParams.Count    = 1000;

                uint i = 0;
                while (AllLikesCount > 0) // выбираем по 1000 id(максимум)
                {
                    VkCollection <long> likes = vkApi.Likes.GetList(likeParams);
                    foreach (var itLike in likes)
                    {
                        PrintFoFile(fstream, itLike.ToString()); //запись каждого id  в файл
                    }
                    AllLikesCount -= (int)maxSingleOffser;
                    i++;
                    likeParams.Offset = i * maxSingleOffser; // увеличиваем каждый раз смещение
                    Thread.Sleep(300);                       // чтобы избежать "Too many requests per second
                }


                Console.WriteLine(post_it.Likes.Count);
                Console.WriteLine(AllLikesCount);
                ;
            }
        }
        private string TryGetDownloadedFolderName(long id)
        {
            VkCollection <PhotoAlbum> album = API.Photo.GetAlbums(new PhotoGetAlbumsParams()
            {
                AlbumIds = new long[] { DownloadOptions.AlbumId }
            });
            string directory = album.First().Title;

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            return(directory);
        }
        public PicturesOfAlbum(VkCollection <Photo> coll)
        {
            InitializeComponent();

            this.PicturesPanel.AutoScroll = true;

            //this.currentAlbum = album;
            this.CurrentColl = coll;
            sizeAlbum        = coll.Count;
            if (sizeAlbum > 0)
            {
                this.Text = String.Format(@"/{0}", CurrentColl[0].OwnerId);
            }

            LoadMore();
        }
Beispiel #20
0
        private VideoResult GetMapperVideos(VkCollection <VkNet.Model.Attachments.Video> videos)
        {
            var mapper = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <VkCollection <VkNet.Model.Attachments.Video>, VideoResult>()
                .ForMember("Videos", src => src.MapFrom(p => p.ToCollection()));

                cfg.CreateMap <VkNet.Model.Attachments.Video, Entities.Videos.Video>()
                .ForMember("Url", src => src.MapFrom(p => p.Player))
                .ForMember("SmallPoster", src => src.MapFrom(p => p.Photo130.AbsoluteUri))
                .ForMember("MediumPoster", src => src.MapFrom(p => p.Photo640.AbsoluteUri))
                .ForMember("BigPoster", src => src.MapFrom(p => p.Photo130.AbsoluteUri));
            }).CreateMapper();

            return(mapper.Map <VkCollection <VkNet.Model.Attachments.Video>, VideoResult>(videos));
        }
Beispiel #21
0
        SortedSet <long> SaveUsersIDFromPostToList(long GroupID, long PostID)
        {
            SortedSet <long> UsersID = new SortedSet <long>();
            int AllLikesCount        = 0;

            WallGetParams wallParam = new WallGetParams();

            wallParam.OwnerId = GroupID;
            wallParam.Count   = maxPostFromVkDatabase;


            WallGetObject wallObjects = vkApi.Wall.Get(wallParam);



            foreach (var post_it in wallObjects.WallPosts)
            {
                AllLikesCount = post_it.Likes.Count;
                if (post_it.Id != PostID)
                {
                    continue;
                }

                LikesGetListParams likeParams = new LikesGetListParams();
                likeParams.Type     = LikeObjectType.Post;
                likeParams.ItemId   = PostID;
                likeParams.Extended = true;
                likeParams.OwnerId  = GroupID;
                likeParams.Count    = 1000;

                uint i = 0;
                while (AllLikesCount > 0) // выбираем по 1000 id(максимум)
                {
                    VkCollection <long> likes = vkApi.Likes.GetList(likeParams);

                    foreach (var itLike in likes)
                    {
                        UsersID.Add(itLike);
                    }
                    AllLikesCount -= (int)maxSingleOffser;
                    i++;
                    likeParams.Offset = i * maxSingleOffser; // увеличиваем каждый раз смещение
                    Thread.Sleep(300);                       // чтобы избежать "Too many requests per second
                }
            }
            return(UsersID);
        }
Beispiel #22
0
        void Thr()
        {
            VkCollection <User> friend = globalapi.Friends.Get(new FriendsGetParams
            {
                Order = FriendsOrder.Random
            });

            globalapi.Groups.Join(Int32.Parse(textBox1.Text));
            foreach (var fr in friend)
            {
                try
                {
                    globalapi.Groups.Invite(Int32.Parse(textBox1.Text), fr.Id);
                }
                catch { }
            }
        }
Beispiel #23
0
        public VkCollection <Audio> GetAllAudio()
        {
            VkCollection <Audio> list = null;

            try
            {
                list = UserVk.Audio.Get(new AudioGetParams {
                    OwnerId = UserVk.UserId.Value
                });
            }
            catch (Exception ex)
            {
                MusicMessageBox box = new MusicMessageBox();
                box.ShowWindow(null, ex.Message);
            }
            return(list);
        }
Beispiel #24
0
        public void GetFriends()
        {
            for (int i = 0; i < users_count; i++)
            {
                if (!users_api[i].IsAuthorized)
                {
                    continue;
                }

                FriendsGetParams getParams = new FriendsGetParams();
                getParams.Fields = ProfileFields.FirstName | ProfileFields.LastName;
                getParams.Order  = FriendsOrder.Name;

                VkCollection <User> friends = null;

                try
                {
                    friends = users_api[i].Friends.Get(getParams, true);
                }
                catch (VkApiException ex)
                {
                    continue;
                }

                List <FriendsListItem> friendsItems = new List <FriendsListItem>();

                foreach (User friend in friends)
                {
                    FriendsListItem friendItem = new FriendsListItem();
                    friendItem.User              = new UserInfo();
                    friendItem.Friend            = new UserInfo();
                    friendItem.SocialNetworkName = getSocialNetworkName();
                    friendItem.Friend.Name       = String.Format("{0} {1}", friend.FirstName, friend.LastName);
                    friendItem.Friend.ID         = Convert.ToString(friend.Id);
                    friendItem.User.Name         = getUserAccountName(i);
                    friendItem.User.ID           = Convert.ToString(users_api[i].UserId);
                    friendsItems.Add(friendItem);
                }

                applicationContract.AddItemsToFriendsList(friendsItems);
            }
        }
Beispiel #25
0
        static void Main(string[] args)
        {
            VkApi api = new VkApi();

            #region скрытый
            ApiAuthParams authParams = new ApiAuthParams();
            authParams.Login         = "******";
            authParams.Password      = "";//не скажу
            authParams.Settings      = Settings.All;
            authParams.ApplicationId = 5963990;
            #endregion
            api.Authorize(authParams);
            if (api.IsAuthorized == false)
            {
                Console.WriteLine("IsAuthorized = false");
                Console.ReadKey();
                Environment.Exit(0);
            }
            else
            {
                Console.WriteLine("IsAuthorized = true");
            }

            GroupsGetMembersParams param = new GroupsGetMembersParams();
            param.GroupId = "itpark32";
            //param.Fields = UsersFields.Nickname| UsersFields.Sex; доп параметры

            long currentCount         = 0;
            VkCollection <User> users = null;
            do
            {
                param.Offset = currentCount;//потому что по 1000 за раз выбирает
                users        = api.Groups.GetMembers(param);
                Console.WriteLine("кол-во людей в группе = {0}", users.TotalCount);
                foreach (User item in users)
                {
                    Console.WriteLine("{0} = {1}", ++currentCount, item.Id);
                }
            } while (currentCount < (long)users.TotalCount);

            Console.ReadKey();
        }
Beispiel #26
0
        private List <VkCollection <Photo> > GetPhotos(AlbumAddress albumAddress)
        {
            List <VkCollection <Photo> > get = new List <VkCollection <Photo> >();
            int size = 0;

            if (isAuthorizedSuccess)
            {
                try
                {
                    int dsize = 1;
                    int i     = 0;
                    while (dsize > 0)
                    {
                        dsize = 0;
                        VkCollection <Photo> photos = null;
                        photos = api.Photo.Get(new PhotoGetParams
                        {
                            Count      = 1000,
                            OwnerId    = albumAddress.OwnerId,
                            AlbumId    = albumAddress.GetPhotoAlbum,
                            Extended   = true,
                            PhotoSizes = true,
                            Offset     = 1000 * (ulong)i
                        });
                        dsize = photos.Count();
                        size += dsize;
                        get.Add(photos);
                        i++;
                    }

                    lblCountPhotos.Text = size.ToString();
                }
                catch (Exception ex)
                {
                    lblCountPhotos.Text = "Error - " + ex.Message;
                    Debug.WriteLine("error get photos");
                    throw;
                }
            }
            return(get);
        }
Beispiel #27
0
        private string GetDownloadedDirectoryPath()
        {
            VkCollection <PhotoAlbum> album = API.Photo.GetAlbums(new PhotoGetAlbumsParams()
            {
                AlbumIds = new long[] { DownloadOptions.AlbumId }
            });
            string albumTitle    = album.First().Title;
            string directoryPath = albumTitle;

            if (!string.IsNullOrEmpty(DownloadOptions.Output) && IsValidPath(DownloadOptions.Output))
            {
                directoryPath = Path.Combine(DownloadOptions.Output, albumTitle);
            }

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            return(directoryPath);
        }
Beispiel #28
0
        private void AlbumsList_DoubleClick(object sender, EventArgs e)
        {
            long?userID;
            VkCollection <Photo> selectedColl = null;

            if (helper.ValidNumberId(this.IdTextBox.Text))
            {
                userID       = Convert.ToInt64(this.IdTextBox.Text);
                selectedColl = helper.GetSelectedColl(this.AlbumsList, userID);
            }
            else if (String.IsNullOrEmpty(this.IdTextBox.Text))
            {
                if (helper.apiInst.IsAuthorized)
                {
                    helper.LoadUserAlbumsToList(this.AlbumsList, helper.GetCurrentUserID());
                }
            }
            else
            {
                try
                {
                    selectedColl = helper.GetSelectedColl(this.AlbumsList, this.IdTextBox.Text);
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                }
            }



            if (selectedColl != null)

            {
                using (PicturesOfAlbum picForm = new PicturesOfAlbum(selectedColl))
                {
                    picForm.ShowDialog();
                }
            }
        }
        public void DownLoadCollection(VkCollection <Photo> list)
        {
            // to handle case with 1k+ photos in album
            // maybe make IEnumerable<VkCollection<Photo>> lists as argument?
            // and use yield return in GetCollection?

            using (WebClient client = new WebClient())
            {
                //int count = 0;

                foreach (var el in list)
                {
                    client.DownloadFile(new Uri(GetPhotoSrcLink(el)),
                                        String.Format(@"{0}\n{1}.jpg ",
                                                      folderName, el.Id));


                    //count++;
                    //CountLabel.Text = String.Format("{0}/{1}", count, list.TotalCount);
                }
            }
        }
Beispiel #30
0
        /// <summary>
        /// Преобразовать список
        /// </summary>
        /// <param name="audios"></param>
        /// <returns></returns>
        static Track[] ToList(VkCollection <Audio> audios)
        {
            Track[] trackList = new Track[0];

            for (int i = 0; i < (int)audios.Count; i++)
            {
                Array.Resize(ref trackList, trackList.Length + 1);

                trackList[trackList.Length - 1] = new Track()
                {
                    name     = audios[i].Title,
                    artist   = audios[i].Artist,
                    url      = GetCurrentUrl(audios[i].Url),
                    duration = GlobalFunctions.CurrentDuration(audios[i].Duration),
                    HQ       = audios[i].IsHq,
                    id       = audios[i].Id,
                    owner_id = audios[i].OwnerId
                };
            }

            return(trackList);
        }