1
0
Fork 0
mirror of https://github.com/fiso64/slsk-batchdl.git synced 2024-12-22 06:22:41 +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)
- [File conditions](#file-conditions)
- [Name format](#name-format)
- [Skip existing](#skip-existing)
- [Skip-existing](#skip-existing)
- [Configuration](#configuration)
- [Examples](#examples-1)
- [Notes](#notes)
@ -42,43 +42,32 @@ Usage: sldl <input> [OPTIONS]
```
General Options
-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
-n, --number <maxtracks> Download the first n tracks of a playlist
-o, --offset <offset> Skip a specified number of tracks
-r, --reverse Download tracks in reverse order
-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)
--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
all downloaded files, required for skip-existing=m3u
'all': Write the index and a list of paths and fails
--m3u-path <path> Override default m3u path
-s, --skip-existing Skip if a track matching file conditions is found in the
output folder or your music library (if provided)
--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
library. Use with --skip-existing
--skip-not-found Skip searching for tracks that weren't found on Soulseek
during the last run. Fails are read from the m3u file.
--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
--skip-existing-pref-cond Use preferred instead of necessary conds for skip-existing
--listen-port <port> Port for incoming connections (default: 49998)
--on-complete <command> Run a command whenever a file is downloaded.
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
downloaded successfully. Prepend 's:' to use the system
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
@ -454,7 +451,7 @@ extractor Name of the extractor used (CSV/Spotify/YouTube/
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
with --music-dir.
@ -606,7 +603,7 @@ sldl --profile wishlist
## 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.
- 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

View file

@ -74,6 +74,7 @@ public class Config
public bool useRandomLogin = false;
public bool noBrowseFolder = false;
public bool skipExistingPrefCond = false;
public bool noProgress = false;
public int downrankOn = -1;
public int ignoreOn = -2;
public int minAlbumTrackCount = -1;
@ -97,7 +98,6 @@ public class Config
public Track regexReplaceBy = new();
public AlbumArtOption albumArtOption = AlbumArtOption.Default;
public M3uOption m3uOption = M3uOption.Index;
public DisplayMode displayMode = DisplayMode.Single;
public InputType inputType = InputType.None;
public SkipMode skipMode = SkipMode.M3u;
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 =>
{
if (arg.Length > 2 && arg[0] == '-')
@ -223,7 +231,7 @@ public class Config
m3uOption = M3uOption.None;
else if (!hasConfiguredM3uMode && inputType == InputType.String)
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;
if (albumArtOnly && albumArtOption == AlbumArtOption.Default)
@ -1091,16 +1099,9 @@ public class Config
case "--desperate":
setFlag(ref desperateSearch, ref i);
break;
case "--dm":
case "--display":
case "--display-mode":
displayMode = args[++i].ToLower().Trim() switch
{
"single" => DisplayMode.Single,
"double" => DisplayMode.Double,
"simple" => DisplayMode.Simple,
_ => throw new ArgumentException($"Invalid display mode '{args[i]}'"),
};
case "--np":
case "--no-progress":
setFlag(ref noProgress, ref i);
break;
case "--sm":
case "--skip-mode":

View file

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

View file

@ -43,18 +43,7 @@ public static class Help
library. Use with --skip-existing
--skip-not-found Skip searching for tracks that weren't found on Soulseek
during the last run. Fails are read from the m3u file.
--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
--skip-existing-pref-cond Use preferred instead of necessary conds for skip-existing
--listen-port <port> Port for incoming connections (default: 49998)
--on-complete <command> Run a command whenever a file is downloaded.
@ -66,6 +55,14 @@ public static class Help
E.g: '1:<cmd>' will only run the command if the file is
downloaded successfully. Prepend 's:' to use the system
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
--fast-search Begin downloading as soon as a file satisfying the preferred
@ -428,7 +425,7 @@ public static class Help
";
const string skipExistingHelp = @"
Skip existing
Skip-existing
sldl can skip downloads that exist in the output directory or a specified directory configured
with --music-dir.

View file

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

View file

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

View file

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

View file

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