Skip to content

Commit

Permalink
expand tildes in input paths
Browse files Browse the repository at this point in the history
  • Loading branch information
fiso64 committed Oct 11, 2024
1 parent d5a4750 commit 13f3cbf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions slsk-batchdl/Extractors/Csv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ public static bool InputMatches(string input)

public async Task<TrackLists> GetTracks(string input, int maxTracks, int offset, bool reverse)
{
if (!File.Exists(input))
throw new FileNotFoundException($"CSV file '{input}' not found");
csvFilePath = Utils.ExpandUser(input);

csvFilePath = input;
if (!File.Exists(csvFilePath))
throw new FileNotFoundException($"CSV file '{csvFilePath}' not found");

var tracks = await ParseCsvIntoTrackInfo(input, Config.I.artistCol, Config.I.titleCol, Config.I.lengthCol,
var tracks = await ParseCsvIntoTrackInfo(csvFilePath, Config.I.artistCol, Config.I.titleCol, Config.I.lengthCol,
Config.I.albumCol, Config.I.descCol, Config.I.ytIdCol, Config.I.trackCountCol, Config.I.timeUnit, Config.I.ytParse);

if (reverse)
tracks.Reverse();

var trackLists = TrackLists.FromFlattened(tracks.Skip(offset).Take(maxTracks));
var csvName = Path.GetFileNameWithoutExtension(input);
var csvName = Path.GetFileNameWithoutExtension(csvFilePath);

foreach (var tle in trackLists.lists)
{
Expand Down
12 changes: 6 additions & 6 deletions slsk-batchdl/Extractors/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public static bool InputMatches(string input)

public async Task<TrackLists> GetTracks(string input, int maxTracks, int offset, bool reverse)
{
if (!File.Exists(input))
throw new FileNotFoundException($"List file '{input}' not found");
listFilePath = Utils.ExpandUser(input);

if (!File.Exists(listFilePath))
throw new FileNotFoundException($"List file '{listFilePath}' not found");

listFilePath = input;

var lines = File.ReadAllLines(input);
var lines = File.ReadAllLines(listFilePath);

var trackLists = new TrackLists();

Expand All @@ -30,7 +30,7 @@ public async Task<TrackLists> GetTracks(string input, int maxTracks, int offset,
int count = 0;
int added = 0;

string foldername = Path.GetFileNameWithoutExtension(input);
string foldername = Path.GetFileNameWithoutExtension(listFilePath);

for (int i = start; i < lines.Length && i >= 0; i += step)
{
Expand Down

0 comments on commit 13f3cbf

Please sign in to comment.