private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string path = folderTextBox.Text;

            if (path != null)
            {
                var userIDs = File.ReadAllLines(path);
                foreach (var userID in userIDs)
                {
                    if (userID != null && folderTextBox != null)
                    {
                        // For collecting media URI.
                        Dictionary <string, List <string> > URI = new Dictionary <string, List <string> >()
                        {
                            ["photoURI"] = new List <string>(),
                            ["videoURI"] = new List <string>()
                        };
                        Parsing p             = new Parsing(Login._instaApi);
                        var     URIcollection = await p.GetMedia(userID, URI);

                        if (URIcollection != null)
                        {
                            await Downloader.DownloadPhotoToFolder(folderTosave.Text, userID, URIcollection);

                            await Downloader.DownloadVideoToFolder(folderTosave.Text, userID, URIcollection);
                        }
                    }
                    else
                    {
                        System.Windows.MessageBox.Show("Fill the all fields!");
                    }
                }
            }
        }
Example #2
0
        static async Task Main(string[] args)
        {
            var result = Task.Run(MainAsync).GetAwaiter().GetResult();

            if (result)
            {
                return;
            }
            Console.WriteLine("Вход в аккаунт выполнен успешно.");
            Console.WriteLine("Выберите дальнейшее действие: " +
                              "\n1 - Получить медиа-ресурсы с профиля");
            var pressed = Console.ReadLine();

            switch (pressed)
            {
            case "1":
                var parsing = new Parsing(_instaApi);
                Console.WriteLine("Введите id пользователя: ");
                var objectId = Console.ReadLine();
                // GETTING MEDIA INFORMATION(URISES).
                URI = await parsing.GetMedia(objectId, URI);

                Console.WriteLine("Данные о медиа-ресурсах получены. Скачать ресурсы?(Y - да, N - нет)");
                break;

            default:
                break;
            }
            pressed = Console.ReadLine();
            switch (pressed)
            {
            case "Y":
                Downloader.DownloadPhotoToFolder(URI);
                Downloader.DownloadVideoToFolder(URI);
                Console.WriteLine("Данные успешно загружены.");
                break;

            default:
                break;
            }
            Console.ReadLine();
        }