private void DownloadFile(PodcastDownloadModel podcastDownloadModel) { if (podcastDownloadModel.FileExists) { return; } State = podcastDownloadModel.EpisodeName; ItemDownloading?.Invoke(); using (var client = new WebClient()) { client.DownloadFile(podcastDownloadModel.DownloadUrl, podcastDownloadModel.LocalFilePath); } }
private void CheckFilePath(PodcastDownloadModel podcastDownloadModel) { var timeStampAppend = string.Empty; if (podcastDownloadModel.EpisodeDate.HasValue) { timeStampAppend = $" - [{podcastDownloadModel.EpisodeDate.Value.DateTime:yyyy-MM-dd}]"; } var fileName = $"{podcastDownloadModel.EpisodeNumber}{timeStampAppend} - {podcastDownloadModel.EpisodeName}"; var fileExtension = podcastDownloadModel.DownloadUrl.Split(".").Last(); var fileNameWithExtension = $"{fileName}.{fileExtension}".ReplaceInvalidChars(); var localFile = $"{_options.OutputPath}\\{fileNameWithExtension}"; var exists = File.Exists(localFile); podcastDownloadModel.LocalFilePath = localFile; podcastDownloadModel.FileExists = exists; }