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 2024-09-07 11:06:29 +02:00
parent effe864b43
commit 431c18b12c
8 changed files with 60 additions and 76 deletions

View file

@ -20,7 +20,7 @@ See the [examples](#examples-1).
- [Searching](#searching) - [Searching](#searching)
- [File conditions](#file-conditions) - [File conditions](#file-conditions)
- [Name format](#name-format) - [Name format](#name-format)
- [Skip existing](#skip-existing) - [Skip-existing](#skip-existing)
- [Configuration](#configuration) - [Configuration](#configuration)
- [Examples](#examples-1) - [Examples](#examples-1)
- [Notes](#notes) - [Notes](#notes)
@ -42,17 +42,17 @@ Usage: sldl <input> [OPTIONS]
``` ```
General Options General Options
-p, --path <path> Download directory -p, --path <path> Download directory
--input-type <type> Force set input type, [csv|youtube|spotify|bandcamp|string] --input-type <type> [csv|youtube|spotify|bandcamp|string|list]
--name-format <format> Name format for downloaded tracks. See --help name-format --name-format <format> Name format for downloaded tracks. See --help name-format
-n, --number <maxtracks> Download the first n tracks of a playlist -n, --number <maxtracks> Download the first n tracks of a playlist
-o, --offset <offset> Skip a specified number of tracks -o, --offset <offset> Skip a specified number of tracks
-r, --reverse Download tracks in reverse order -r, --reverse Download tracks in reverse order
-c, --config <path> Set config file location. Set to 'none' to ignore config -c, --config <path> Set config file location. Set to 'none' to ignore config
--profile <names> Configuration profile(s) to use. See --help "config". --profile <names> Configuration profile(s) to use. See --help ""config"".
--concurrent-downloads <num> Max concurrent downloads (default: 2) --concurrent-downloads <num> Max concurrent downloads (default: 2)
--m3u <option> Create an m3u8 playlist file in the output directory --m3u <option> Create an m3u8 playlist file in the output directory
'none' (default for string input): Do not create 'none' (default for string inputs): Do not create
'index' (default): Write a single line for sldl to index 'index' (default): Write a single line for sldl to index
all downloaded files, required for skip-existing=m3u all downloaded files, required for skip-existing=m3u
'all': Write the index and a list of paths and fails 'all': Write the index and a list of paths and fails
@ -61,24 +61,13 @@ Usage: sldl <input> [OPTIONS]
-s, --skip-existing Skip if a track matching file conditions is found in the -s, --skip-existing Skip if a track matching file conditions is found in the
output folder or your music library (if provided) output folder or your music library (if provided)
--skip-mode <mode> [name|tag|m3u|name-cond|tag-cond|m3u-cond] --skip-mode <mode> [name|tag|m3u|name-cond|tag-cond|m3u-cond]
See --help "skip-existing". See --help ""skip-existing"".
--music-dir <path> Specify to also skip downloading tracks found in a music --music-dir <path> Specify to also skip downloading tracks found in a music
library. Use with --skip-existing library. Use with --skip-existing
--skip-not-found Skip searching for tracks that weren't found on Soulseek --skip-not-found Skip searching for tracks that weren't found on Soulseek
during the last run. Fails are read from the m3u file. during the last run. Fails are read from the m3u file.
--skip-existing-pref-cond Use preferred instead of necessary conds for skip-existing --skip-existing-pref-cond Use preferred instead of necessary conds for skip-existing
--display-mode <option> Changes how searches and downloads are displayed:
'single' (default): Show transfer state and percentage
'double': Transfer state and a large progress bar
'simple': No download bars or changing percentages
--print <option> Print tracks or search results instead of downloading:
'tracks': Print all tracks to be downloaded
'tracks-full': Print extended information about all tracks
'results': Print search results satisfying file conditions
'results-full': Print search results including full paths
--debug Print extra debug info
--listen-port <port> Port for incoming connections (default: 49998) --listen-port <port> Port for incoming connections (default: 49998)
--on-complete <command> Run a command whenever a file is downloaded. --on-complete <command> Run a command whenever a file is downloaded.
Available placeholders: {path} (local save path), {title}, Available placeholders: {path} (local save path), {title},
@ -89,6 +78,14 @@ Usage: sldl <input> [OPTIONS]
E.g: '1:<cmd>' will only run the command if the file is E.g: '1:<cmd>' will only run the command if the file is
downloaded successfully. Prepend 's:' to use the system downloaded successfully. Prepend 's:' to use the system
shell to execute the command. shell to execute the command.
--print <option> Print tracks or search results instead of downloading:
'tracks': Print all tracks to be downloaded
'tracks-full': Print extended information about all tracks
'results': Print search results satisfying file conditions
'results-full': Print search results including full paths
--no-progress Disable progress bars/percentages, only simple printing
--debug Print extra debug info
``` ```
``` ```
Searching Searching
@ -454,7 +451,7 @@ extractor Name of the extractor used (CSV/Spotify/YouTube/
default-folder Default sldl folder name (usually the playlist name) default-folder Default sldl folder name (usually the playlist name)
``` ```
## Skip existing ## Skip-existing
sldl can skip downloads that exist in the output directory or a specified directory configured sldl can skip downloads that exist in the output directory or a specified directory configured
with --music-dir. with --music-dir.
@ -606,7 +603,7 @@ sldl --profile wishlist
## Notes ## Notes
- For macOS builds you can use publish.sh to build the app. Download dotnet from https://dotnet.microsoft.com/en-us/download/dotnet/6.0, then run `chmod +x publish.sh && sh publish.sh`. For intel macs, uncomment the x64 and comment the arm64 section in publish.sh. - For macOS builds you can use publish.sh to build the app. Download dotnet from https://dotnet.microsoft.com/en-us/download/dotnet/6.0, then run `chmod +x publish.sh && sh publish.sh`. For intel macs, uncomment the x64 and comment the arm64 section in publish.sh.
- The printed output may appear duplicated, overlap, or not update on some configurations (new windows terminal, git bash). Use another terminal or `--display-mode simple` in case of issues. - The printed output may appear duplicated, overlap, or not update on some configurations (new windows terminal, git bash). Use another terminal or `--no-progress` in case of issues.
## Docker ## Docker

View file

@ -74,6 +74,7 @@ public class Config
public bool useRandomLogin = false; public bool useRandomLogin = false;
public bool noBrowseFolder = false; public bool noBrowseFolder = false;
public bool skipExistingPrefCond = false; public bool skipExistingPrefCond = false;
public bool noProgress = false;
public int downrankOn = -1; public int downrankOn = -1;
public int ignoreOn = -2; public int ignoreOn = -2;
public int minAlbumTrackCount = -1; public int minAlbumTrackCount = -1;
@ -97,7 +98,6 @@ public class Config
public Track regexReplaceBy = new(); public Track regexReplaceBy = new();
public AlbumArtOption albumArtOption = AlbumArtOption.Default; public AlbumArtOption albumArtOption = AlbumArtOption.Default;
public M3uOption m3uOption = M3uOption.Index; public M3uOption m3uOption = M3uOption.Index;
public DisplayMode displayMode = DisplayMode.Single;
public InputType inputType = InputType.None; public InputType inputType = InputType.None;
public SkipMode skipMode = SkipMode.M3u; public SkipMode skipMode = SkipMode.M3u;
public SkipMode skipModeMusicDir = SkipMode.Name; public SkipMode skipModeMusicDir = SkipMode.Name;
@ -133,8 +133,16 @@ public class Config
} }
public void Load(string[] args) public void LoadAndParse(string[] args)
{ {
int helpIdx = Array.FindLastIndex(args, x => x == "--help" || x == "-h");
if (args.Length == 0 || helpIdx >= 0)
{
string option = helpIdx + 1 < args.Length ? args[helpIdx + 1] : "";
Help.PrintHelp(option);
Environment.Exit(0);
}
arguments = args.SelectMany(arg => arguments = args.SelectMany(arg =>
{ {
if (arg.Length > 2 && arg[0] == '-') if (arg.Length > 2 && arg[0] == '-')
@ -223,7 +231,7 @@ public class Config
m3uOption = M3uOption.None; m3uOption = M3uOption.None;
else if (!hasConfiguredM3uMode && inputType == InputType.String) else if (!hasConfiguredM3uMode && inputType == InputType.String)
m3uOption = M3uOption.None; m3uOption = M3uOption.None;
else if (!hasConfiguredM3uMode && !Program.trackLists.Flattened(true, true).Skip(1).Any()) else if (!hasConfiguredM3uMode && Program.trackLists != null && !Program.trackLists.Flattened(true, true).Skip(1).Any())
m3uOption = M3uOption.None; m3uOption = M3uOption.None;
if (albumArtOnly && albumArtOption == AlbumArtOption.Default) if (albumArtOnly && albumArtOption == AlbumArtOption.Default)
@ -1091,16 +1099,9 @@ public class Config
case "--desperate": case "--desperate":
setFlag(ref desperateSearch, ref i); setFlag(ref desperateSearch, ref i);
break; break;
case "--dm": case "--np":
case "--display": case "--no-progress":
case "--display-mode": setFlag(ref noProgress, ref i);
displayMode = args[++i].ToLower().Trim() switch
{
"single" => DisplayMode.Single,
"double" => DisplayMode.Double,
"simple" => DisplayMode.Simple,
_ => throw new ArgumentException($"Invalid display mode '{args[i]}'"),
};
break; break;
case "--sm": case "--sm":
case "--skip-mode": case "--skip-mode":

View file

@ -71,13 +71,6 @@ namespace Enums
Largest, Largest,
} }
public enum DisplayMode
{
Single,
Double,
Simple,
}
public enum Verbosity public enum Verbosity
{ {
Silent, Silent,

View file

@ -45,17 +45,6 @@ public static class Help
during the last run. Fails are read from the m3u file. during the last run. Fails are read from the m3u file.
--skip-existing-pref-cond Use preferred instead of necessary conds for skip-existing --skip-existing-pref-cond Use preferred instead of necessary conds for skip-existing
--display-mode <option> Changes how searches and downloads are displayed:
'single' (default): Show transfer state and percentage
'double': Transfer state and a large progress bar
'simple': No download bars or changing percentages
--print <option> Print tracks or search results instead of downloading:
'tracks': Print all tracks to be downloaded
'tracks-full': Print extended information about all tracks
'results': Print search results satisfying file conditions
'results-full': Print search results including full paths
--debug Print extra debug info
--listen-port <port> Port for incoming connections (default: 49998) --listen-port <port> Port for incoming connections (default: 49998)
--on-complete <command> Run a command whenever a file is downloaded. --on-complete <command> Run a command whenever a file is downloaded.
Available placeholders: {path} (local save path), {title}, Available placeholders: {path} (local save path), {title},
@ -67,6 +56,14 @@ public static class Help
downloaded successfully. Prepend 's:' to use the system downloaded successfully. Prepend 's:' to use the system
shell to execute the command. shell to execute the command.
--print <option> Print tracks or search results instead of downloading:
'tracks': Print all tracks to be downloaded
'tracks-full': Print extended information about all tracks
'results': Print search results satisfying file conditions
'results-full': Print search results including full paths
--no-progress Disable progress bars/percentages, only simple printing
--debug Print extra debug info
Searching Searching
--fast-search Begin downloading as soon as a file satisfying the preferred --fast-search Begin downloading as soon as a file satisfying the preferred
conditions is found. Only for normal download mode. conditions is found. Only for normal download mode.
@ -428,7 +425,7 @@ public static class Help
"; ";
const string skipExistingHelp = @" const string skipExistingHelp = @"
Skip existing Skip-existing
sldl can skip downloads that exist in the output directory or a specified directory configured sldl can skip downloads that exist in the output directory or a specified directory configured
with --music-dir. with --music-dir.

View file

@ -312,9 +312,11 @@ public static class Printing
try { progress.Refresh(current, item); } try { progress.Refresh(current, item); }
catch { } catch { }
} }
else if ((Config.I.displayMode == DisplayMode.Simple || Console.IsOutputRedirected) && print) else if ((Config.I.noProgress || Console.IsOutputRedirected) && print)
{
Console.WriteLine(item); Console.WriteLine(item);
} }
}
public static void WriteLine(string value, ConsoleColor color = ConsoleColor.Gray, bool safe = false, bool debugOnly = false) public static void WriteLine(string value, ConsoleColor color = ConsoleColor.Gray, bool safe = false, bool debugOnly = false)
@ -342,16 +344,18 @@ public static class Printing
} }
public static ProgressBar? GetProgressBar(DisplayMode style) public static ProgressBar? GetProgressBar()
{ {
lock (consoleLock) lock (consoleLock)
{ {
ProgressBar? progress = null; if (!Config.I.noProgress)
if (style == DisplayMode.Double) {
progress = new ProgressBar(PbStyle.DoubleLine, 100, Console.WindowWidth - 40, character: '―'); return new ProgressBar(PbStyle.SingleLine, 100, Console.WindowWidth - 10, character: ' ');
else if (style != DisplayMode.Simple) }
progress = new ProgressBar(PbStyle.SingleLine, 100, Console.WindowWidth - 10, character: ' '); else
return progress; {
return null;
}
} }
} }
} }

View file

@ -36,15 +36,7 @@ static partial class Program
Console.ResetColor(); Console.ResetColor();
Console.OutputEncoding = System.Text.Encoding.UTF8; Console.OutputEncoding = System.Text.Encoding.UTF8;
int helpIdx = Array.FindIndex(args, x => x == "--help" || x == "-h"); Config.I.LoadAndParse(args);
if (args.Length == 0 || helpIdx >= 0)
{
string option = helpIdx + 1 < args.Length ? args[helpIdx + 1] : "";
Help.PrintHelp(option);
return;
}
Config.I.Load(args);
if (Config.I.input.Length == 0) if (Config.I.input.Length == 0)
throw new ArgumentException($"No input provided"); throw new ArgumentException($"No input provided");

View file

@ -27,7 +27,7 @@ static class Search
IEnumerable<(SlResponse response, SlFile file)>? orderedResults = null; IEnumerable<(SlResponse response, SlFile file)>? orderedResults = null;
var responseData = new ResponseData(); var responseData = new ResponseData();
var progress = Printing.GetProgressBar(Config.I.displayMode); var progress = Printing.GetProgressBar();
var results = new SlDictionary(); var results = new SlDictionary();
var fsResults = new SlDictionary(); var fsResults = new SlDictionary();
using var searchCts = new CancellationTokenSource(); using var searchCts = new CancellationTokenSource();

View file

@ -109,7 +109,7 @@ namespace Test
File.WriteAllText(path, content); File.WriteAllText(path, content);
Config.I.Load(new string[] { "-c", path }); Config.I.LoadAndParse(new string[] { "-c", path });
var tle = new TrackListEntry(TrackType.Album); var tle = new TrackListEntry(TrackType.Album);
Config.UpdateProfiles(tle); Config.UpdateProfiles(tle);
@ -133,7 +133,7 @@ namespace Test
File.WriteAllText(path, content); File.WriteAllText(path, content);
Config.I.Load(new string[] { "-c", path }); Config.I.LoadAndParse(new string[] { "-c", path });
Config.UpdateProfiles(tle); Config.UpdateProfiles(tle);
Assert(Config.I.maxStaleTime == 999999 && !Config.I.useYtdlp); Assert(Config.I.maxStaleTime == 999999 && !Config.I.useYtdlp);
@ -152,7 +152,7 @@ namespace Test
"\nyt-dlp = true"; "\nyt-dlp = true";
File.WriteAllText(path, content); File.WriteAllText(path, content);
Config.I.Load(new string[] { "-c", path }); Config.I.LoadAndParse(new string[] { "-c", path });
Config.UpdateProfiles(new TrackListEntry(TrackType.Normal)); Config.UpdateProfiles(new TrackListEntry(TrackType.Normal));
Assert(Config.I.maxStaleTime == 50000 && Config.I.useYtdlp); Assert(Config.I.maxStaleTime == 50000 && Config.I.useYtdlp);