1
0
Fork 0
mirror of https://github.com/fiso64/slsk-batchdl.git synced 2024-12-22 14:32:40 +00:00
This commit is contained in:
fiso64 2023-12-20 18:23:15 +01:00
parent 9904316bdf
commit 6380df3833
4 changed files with 26 additions and 11 deletions

View file

@ -139,6 +139,7 @@ Options:
single (default): Show transfer state and percentage single (default): Show transfer state and percentage
double: Transfer state and a large progress bar double: Transfer state and a large progress bar
simple: No download bars or changing percentages simple: No download bars or changing percentages
--listen-port <port> Port for incoming connections (default: 50000)
--print <option> Print tracks or search results instead of downloading: --print <option> Print tracks or search results instead of downloading:
tracks: Print all tracks to be downloaded tracks: Print all tracks to be downloaded

View file

@ -25,7 +25,7 @@ using ProgressBar = Konsole.ProgressBar;
static class Program static class Program
{ {
static SoulseekClient client = new SoulseekClient(); static SoulseekClient? client = null;
static ConcurrentDictionary<Track, SearchInfo> searches = new ConcurrentDictionary<Track, SearchInfo>(); static ConcurrentDictionary<Track, SearchInfo> searches = new ConcurrentDictionary<Track, SearchInfo>();
static ConcurrentDictionary<string, DownloadWrapper> downloads = new ConcurrentDictionary<string, DownloadWrapper>(); static ConcurrentDictionary<string, DownloadWrapper> downloads = new ConcurrentDictionary<string, DownloadWrapper>();
static List<Track> tracks = new List<Track>(); static List<Track> tracks = new List<Track>();
@ -117,6 +117,7 @@ static class Program
static int maxConcurrentProcesses = 2; static int maxConcurrentProcesses = 2;
static int maxRetriesPerTrack = 30; static int maxRetriesPerTrack = 30;
static int maxResultsPerUser = 30; static int maxResultsPerUser = 30;
static int listenPort = 50000;
static bool slowConsoleOutput = false; static bool slowConsoleOutput = false;
static object consoleLock = new object(); static object consoleLock = new object();
@ -251,6 +252,7 @@ static class Program
"\n single (default): Show transfer state and percentage" + "\n single (default): Show transfer state and percentage" +
"\n double: Transfer state and a large progress bar " + "\n double: Transfer state and a large progress bar " +
"\n simple: No download bars or changing percentages" + "\n simple: No download bars or changing percentages" +
"\n --listen-port <port> Port for incoming connections (default: 50000)" +
"\n" + "\n" +
"\n --print <option> Print tracks or search results instead of downloading:" + "\n --print <option> Print tracks or search results instead of downloading:" +
"\n tracks: Print all tracks to be downloaded" + "\n tracks: Print all tracks to be downloaded" +
@ -465,6 +467,9 @@ static class Program
case "--m3u-only": case "--m3u-only":
m3uOnly = true; m3uOnly = true;
break; break;
case "--listen-port":
listenPort = int.Parse(args[++i]);
break;
case "--search-timeout": case "--search-timeout":
searchTimeout = int.Parse(args[++i]); searchTimeout = int.Parse(args[++i]);
break; break;
@ -595,10 +600,12 @@ static class Program
if (input == "") if (input == "")
input = args[i]; input = args[i];
else else
throw new ArgumentException(); throw new ArgumentException($"Invalid argument \"{input}\"");
} }
} }
client = new SoulseekClient(new SoulseekClientOptions(listenPort: listenPort));
if (input == "") if (input == "")
throw new ArgumentException($"No input provided"); throw new ArgumentException($"No input provided");

View file

@ -137,14 +137,21 @@ public class Spotify
foreach (var track in tracks.Items) foreach (var track in tracks.Items)
{ {
string[] artists = ((IEnumerable<object>)track.Track.ReadProperty("artists")).Select(a => (string)a.ReadProperty("name")).ToArray(); try
string artist = artists[0]; {
string name = (string)track.Track.ReadProperty("name"); string[] artists = ((IEnumerable<object>)track.Track.ReadProperty("artists")).Select(a => (string)a.ReadProperty("name")).ToArray();
string album = (string)track.Track.ReadProperty("album").ReadProperty("name"); string artist = artists[0];
string uri = (string)track.Track.ReadProperty("uri"); string name = (string)track.Track.ReadProperty("name");
int duration = (int)track.Track.ReadProperty("durationMs"); string album = (string)track.Track.ReadProperty("album").ReadProperty("name");
string uri = (string)track.Track.ReadProperty("uri");
int duration = (int)track.Track.ReadProperty("durationMs");
res.Add(new Track { Album = album, ArtistName = artist, TrackTitle = name, Length = duration / 1000, URI = uri }); res.Add(new Track { Album = album, ArtistName = artist, TrackTitle = name, Length = duration / 1000, URI = uri });
}
catch
{
continue;
}
} }
if (tracks.Items.Count < limit || res.Count >= max) if (tracks.Items.Count < limit || res.Count >= max)

View file

@ -21,11 +21,11 @@
<PackageReference Include="Goblinfactory.ProgressBar" Version="1.0.0" /> <PackageReference Include="Goblinfactory.ProgressBar" Version="1.0.0" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.63.0.3205" /> <PackageReference Include="Google.Apis.YouTube.v3" Version="1.63.0.3205" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.54" /> <PackageReference Include="HtmlAgilityPack" Version="1.11.54" />
<PackageReference Include="Soulseek" Version="6.1.3" /> <PackageReference Include="Soulseek" Version="6.2.0" />
<PackageReference Include="SpotifyAPI.Web" Version="7.0.2" /> <PackageReference Include="SpotifyAPI.Web" Version="7.0.2" />
<PackageReference Include="SpotifyAPI.Web.Auth" Version="7.0.2" /> <PackageReference Include="SpotifyAPI.Web.Auth" Version="7.0.2" />
<PackageReference Include="TagLibSharp" Version="2.3.0" /> <PackageReference Include="TagLibSharp" Version="2.3.0" />
<PackageReference Include="YoutubeExplode" Version="6.3.8" /> <PackageReference Include="YoutubeExplode" Version="6.3.9" />
</ItemGroup> </ItemGroup>
</Project> </Project>