1
0
Fork 0
mirror of https://github.com/fiso64/slsk-batchdl.git synced 2024-12-22 14:32:40 +00:00

implement select individual files in interactive mode

This commit is contained in:
fiso64 2024-10-19 16:24:12 +02:00
parent 82df27d40a
commit 7689745d48
2 changed files with 17 additions and 4 deletions

View file

@ -906,7 +906,7 @@ static partial class Program
WriteLine($" [Up/p] | [Down/n] | [Enter] | [q] {retrieveAll1}| [Esc/s]", ConsoleColor.Green); WriteLine($" [Up/p] | [Down/n] | [Enter] | [q] {retrieveAll1}| [Esc/s]", ConsoleColor.Green);
WriteLine($" Prev | Next | Accept | Accept & Quit Interactive {retrieveAll2}| Skip", ConsoleColor.Green); WriteLine($" Prev | Next | Accept | Accept & Quit Interactive {retrieveAll2}| Skip", ConsoleColor.Green);
Console.WriteLine(); Console.WriteLine();
WriteLine($" d:1,2,3 to download individual files", ConsoleColor.Green); WriteLine($" d:1,2,3 or d:start:end to download individual files", ConsoleColor.Green);
Console.WriteLine(); Console.WriteLine();
} }
@ -971,7 +971,20 @@ static partial class Program
return (aidx, tracks, true); return (aidx, tracks, true);
try try
{ {
var indices = options.Split(',').Select(int.Parse).ToArray(); var indices = options.Split(',')
.SelectMany(option =>
{
if (option.Contains(':'))
{
var parts = option.Split(':');
int start = string.IsNullOrEmpty(parts[0]) ? 1 : int.Parse(parts[0]);
int end = string.IsNullOrEmpty(parts[1]) ? tracks.Count : int.Parse(parts[1]);
return Enumerable.Range(start, end - start + 1);
}
return new[] { int.Parse(option) };
})
.Distinct()
.ToArray();
return (aidx, indices.Select(i => tracks[i - 1]).ToList(), false); return (aidx, indices.Select(i => tracks[i - 1]).ToList(), false);
} }
catch catch