Ejemplo n.º 1
0
        //public async  Task<IResult<InstaLoginResult>> LoginWithNumber()
        //{
        //  //await   _instaApi.lo

        //}


        public async Task <IResult <bool> > LikePost(string uri)
        {
            var mediaId = await _instaApi.GetMediaIdFromUrlAsync(new Uri(uri));


            return(await _instaApi.LikeMediaAsync(mediaId.Value));
        }
        private async Task DownloadUrlPhotoAsync(string input, InputMediaType inputType)
        {
            try
            {
                var statsFile = $@"{_statsDirectory}\urls.csv";
                IResult <string> mediaIdFromUrl = null;

                if (!File.Exists(statsFile))
                {
                    using (var csv = new Csv(statsFile, _delimiter))
                    {
                        csv.WriteHeader();
                    }
                }

                if (inputType == InputMediaType.Url)
                {
                    mediaIdFromUrl = await _instaApi.GetMediaIdFromUrlAsync(new Uri(input));

                    if (!mediaIdFromUrl.Succeeded)
                    {
                        return;
                    }
                }

                var mediaId = mediaIdFromUrl == null ? input : mediaIdFromUrl.Value;

                var mediaInformation = await _instaApi.GetMediaByIdAsync(mediaId);

                if (!mediaInformation.Succeeded)
                {
                    return;
                }

                _cancellationToken.ThrowIfCancellationRequested();

                if (_mediaFilter.CheckFilters(mediaInformation.Value))
                {
                    return;
                }
                if (CheckTotalDownloads())
                {
                    await DownloadInstaMediaAsync(mediaInformation.Value, statsFile);
                }
            }
            catch (Exception)
            {
                // something probably went wrong
            }
        }