mirror of
https://github.com/fiso64/slsk-batchdl.git
synced 2024-12-22 06:22:41 +00:00
commit
This commit is contained in:
parent
effe864b43
commit
431c18b12c
8 changed files with 60 additions and 76 deletions
33
README.md
33
README.md
|
@ -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,17 +42,17 @@ 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
|
||||
|
@ -61,24 +61,13 @@ Usage: sldl <input> [OPTIONS]
|
|||
-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
|
||||
|
||||
--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
|
||||
|
||||
|
|
|
@ -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":
|
||||
|
|
|
@ -71,13 +71,6 @@ namespace Enums
|
|||
Largest,
|
||||
}
|
||||
|
||||
public enum DisplayMode
|
||||
{
|
||||
Single,
|
||||
Double,
|
||||
Simple,
|
||||
}
|
||||
|
||||
public enum Verbosity
|
||||
{
|
||||
Silent,
|
||||
|
|
|
@ -45,17 +45,6 @@ public static class Help
|
|||
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
|
||||
|
||||
--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},
|
||||
|
@ -67,6 +56,14 @@ public static class Help
|
|||
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
|
||||
conditions is found. Only for normal download mode.
|
||||
|
@ -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.
|
||||
|
|
|
@ -312,9 +312,11 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue