mirror of
https://github.com/fiso64/slsk-batchdl.git
synced 2024-12-22 14:32:40 +00:00
commit
This commit is contained in:
parent
6c70442449
commit
e4505a53c7
2 changed files with 20 additions and 10 deletions
|
@ -139,6 +139,7 @@ static class Program
|
|||
static bool removeBrackets = false;
|
||||
static bool reverse = false;
|
||||
static bool useYtdlp = false;
|
||||
static string ytdlpArgument = "";
|
||||
static bool skipExisting = false;
|
||||
static string m3uOption = "fails";
|
||||
static bool useTagsCheckExisting = false;
|
||||
|
@ -186,7 +187,7 @@ static class Program
|
|||
// undocumented options:
|
||||
// --artist-col, --title-col, --album-col, --length-col, --yt-desc-col, --yt-id-col
|
||||
// --remove-brackets, --spotify, --csv, --string, --youtube, --random-login
|
||||
// --danger-words, --pref-danger-words, --no-modify-share-count
|
||||
// --danger-words, --pref-danger-words, --no-modify-share-count, --yt-dlp-argument
|
||||
Console.WriteLine("Usage: slsk-batchdl <input> [OPTIONS]" +
|
||||
"\n" +
|
||||
"\n <input> <input> is one of the following:" +
|
||||
|
@ -752,6 +753,9 @@ static class Program
|
|||
preferredCond.AcceptMissingProps = false;
|
||||
necessaryCond.AcceptMissingProps = false;
|
||||
break;
|
||||
case "--yt-dlp-argument":
|
||||
ytdlpArgument = args[++i];
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException($"Unknown argument: {args[i]}");
|
||||
}
|
||||
|
@ -1427,6 +1431,7 @@ static class Program
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static List<Track> InteractiveModeAlbum(List<List<Track>> list)
|
||||
{
|
||||
int aidx = 0;
|
||||
|
@ -1685,7 +1690,7 @@ static class Program
|
|||
string saveFilePathNoExt = GetSavePathNoExt(title);
|
||||
downloading = true;
|
||||
RefreshOrPrint(progress, 0, $"yt-dlp download: {track}", true);
|
||||
saveFilePath = await YouTube.YtdlpDownload(id, saveFilePathNoExt);
|
||||
saveFilePath = await YouTube.YtdlpDownload(id, saveFilePathNoExt, ytdlpArgument);
|
||||
RefreshOrPrint(progress, 100, $"Succeded: yt-dlp completed download for {track}", true);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -471,13 +471,16 @@ public static class YouTube
|
|||
return results;
|
||||
}
|
||||
|
||||
public static async Task<string> YtdlpDownload(string id, string savePathNoExt)
|
||||
public static async Task<string> YtdlpDownload(string id, string savePathNoExt, string ytdlpArgument="")
|
||||
{
|
||||
Process process = new Process();
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||||
|
||||
if (ytdlpArgument == "")
|
||||
ytdlpArgument = "\"{id}\" -f bestaudio/best -ci -o \"{savepath-noext}.%(ext)s\" -x";
|
||||
|
||||
startInfo.FileName = "yt-dlp";
|
||||
startInfo.Arguments = $"\"{id}\" -f bestaudio/best -ci -o \"{savePathNoExt}.%(ext)s\" -x";
|
||||
startInfo.Arguments = ytdlpArgument.Replace("{id}", id).Replace("{savepath-noext}", savePathNoExt);
|
||||
|
||||
startInfo.RedirectStandardOutput = true;
|
||||
startInfo.RedirectStandardError = true;
|
||||
|
@ -489,13 +492,15 @@ public static class YouTube
|
|||
process.Start();
|
||||
process.WaitForExit();
|
||||
|
||||
string[] files = Directory.GetFiles(Path.GetDirectoryName(savePathNoExt), Path.GetFileName(savePathNoExt + ".ext") + ".*");
|
||||
if (File.Exists(savePathNoExt + ".opus"))
|
||||
return savePathNoExt + ".opus";
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (Utils.IsMusicFile(file))
|
||||
return file;
|
||||
}
|
||||
string parentDirectory = Path.GetDirectoryName(savePathNoExt);
|
||||
string[] musicFiles = Directory.GetFiles(parentDirectory, "*", SearchOption.TopDirectoryOnly)
|
||||
.Where(file => Utils.IsMusicFile(file))
|
||||
.ToArray();
|
||||
if (musicFiles.Length > 0)
|
||||
return musicFiles[0];
|
||||
|
||||
return "";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue