From 13f3cbff471a9c87bb379e6a3083d24dbc880841 Mon Sep 17 00:00:00 2001
From: fiso64 <sokfilix@gmail.com>
Date: Fri, 11 Oct 2024 23:49:00 +0200
Subject: [PATCH] expand tildes in input paths

---
 slsk-batchdl/Extractors/Csv.cs  | 10 +++++-----
 slsk-batchdl/Extractors/List.cs | 12 ++++++------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/slsk-batchdl/Extractors/Csv.cs b/slsk-batchdl/Extractors/Csv.cs
index 307e5d6..b0d36ad 100644
--- a/slsk-batchdl/Extractors/Csv.cs
+++ b/slsk-batchdl/Extractors/Csv.cs
@@ -17,19 +17,19 @@ namespace Extractors
 
         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)
             {
diff --git a/slsk-batchdl/Extractors/List.cs b/slsk-batchdl/Extractors/List.cs
index c67643e..9cad984 100644
--- a/slsk-batchdl/Extractors/List.cs
+++ b/slsk-batchdl/Extractors/List.cs
@@ -16,12 +16,12 @@ namespace Extractors
 
         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();
 
@@ -30,7 +30,7 @@ namespace Extractors
             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)
             {