Skip to content

Commit

Permalink
added skipping existing files
Browse files Browse the repository at this point in the history
  • Loading branch information
JosefFStraka committed Apr 7, 2023
1 parent e1335a5 commit 4568dac
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions SongDownloader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,26 @@ public static async Task<int> Main(string[] args)

List<Task> downloadTasks = new List<Task>();

List<string> files = Directory.EnumerateFiles(pathToDownloadFolder).Select(s => Path.GetFileNameWithoutExtension(s)).ToList();

for (int i = 0; i < lines.Length; i++)
{
string songName = lines[i];

if (String.IsNullOrEmpty(songName))
continue;

if (files.Contains(songName))
{
string fullFilePath = Path.Combine(pathToDownloadFolder, $"{songName}.mp3");
FileInfo fi = new FileInfo(fullFilePath);
if (fi.Length > 0)
{
Console.WriteLine($"Skipping: {songName}");
continue;
}
}

downloadTasks.Add(Task.Run(async () =>
{
try
Expand Down

0 comments on commit 4568dac

Please sign in to comment.