// 3/10/2020 I wish that we could both be there
        public async void Download()
        {
            if (DownloadContent.IsUgoira)
            {
                DownloadGif();
                return;
            }

            string path = null;

            try
            {
                await using var memory = await PixivIOHelper.Download(DownloadContent.GetDownloadUrl(), new Progress <double>(d => Progress = d), cancellationTokenSource.Token);

                if (DownloadContent.FromSpotlight)
                {
                    path = IsFromManga
                        ? Path.Combine(Directory.CreateDirectory(AppContext.DownloadPathProvider.GetSpotlightPath(DownloadContent.SpotlightTitle)).FullName, DownloadContent.Id, AppContext.FileNameFormatter.FormatManga(DownloadContent, MangaIndex))
                        : Path.Combine(Directory.CreateDirectory(AppContext.DownloadPathProvider.GetSpotlightPath(DownloadContent.SpotlightTitle)).FullName, AppContext.FileNameFormatter.Format(DownloadContent));
                }
                else if (IsFromManga)
                {
                    path = Path.Combine(Directory.CreateDirectory(AppContext.DownloadPathProvider.GetMangaPath(DownloadContent.Id)).FullName, AppContext.FileNameFormatter.FormatManga(DownloadContent, MangaIndex));
                }
                else
                {
                    path = Path.Combine(Directory.CreateDirectory(AppContext.DownloadPathProvider.GetIllustrationPath()).FullName, AppContext.FileNameFormatter.Format(DownloadContent));
                }
                if (cancellationTokenSource.IsCancellationRequested)
                {
                    return;
                }
                await using var fileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
                memory.WriteTo(fileStream);
                Application.Current.Invoke(() => DownloadFinished?.Invoke(this));
            }
            catch (TaskCanceledException)
            {
                if (path != null && File.Exists(path))
                {
                    File.Delete(path);
                }
            }
            catch (Exception e)
            {
                if (!retried)
                {
                    Restart();
                    retried = true;
                }
                else
                {
                    HandleError(e, path);
                }
            }
        }
        public async void Download()
        {
            if (!modifiable)
            {
                return;
            }

            DownloadState.Value = DownloadStateEnum.Downloading;
            var downloadPath = GetPath();

            if (DownloadContent.IsUgoira)
            {
                DownloadGif();
                return;
            }

            try
            {
                await using var memory = await PixivIO.Download(DownloadContent.GetDownloadUrl(),
                                                                new Progress <double>(d => Progress = d),
                                                                cancellationTokenSource.Token);

                if (cancellationTokenSource.IsCancellationRequested)
                {
                    return;
                }
                await using var fileStream = new FileStream(downloadPath, FileMode.OpenOrCreate, FileAccess.ReadWrite,
                                                            FileShare.None);
                memory.WriteTo(fileStream);
                DownloadState.Value = DownloadStateEnum.Finished;
            }
            catch (OperationCanceledException)
            {
                if (downloadPath != null && File.Exists(downloadPath))
                {
                    File.Delete(downloadPath);
                }
            }
            catch (Exception e)
            {
                if (!retried)
                {
                    Restart();
                    retried = true;
                }
                else
                {
                    HandleError(e, downloadPath);
                }
            }
        }