Skip to content

Commit

Permalink
add --ytdlpArgs option
Browse files Browse the repository at this point in the history
  • Loading branch information
awidesky committed Mar 30, 2023
1 parent 4395f5b commit 53acf64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/com/awidesky/YoutubeClipboardAutoDownloader/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class Main {
private static Function<String, TaskLogger> taskLogGetter;

private static volatile int taskNum = 0;
private static String[] ytdlpAdditionalOptions = new String[0];

public static final String version = "v2.0.0";

Expand All @@ -83,6 +84,10 @@ public static void main(String[] args) {
System.out.println("\t Useful when you don't want to see dirty log file when multiple tasks running.");
System.out.println("\t--logTime : Log with TimeStamps");
System.out.println("\t--verbose : Print verbose logs(like GUI Windows or extra debug info, etc.)");
System.out.println("\t--ytdlpArgs=<options...> : Add additional yt-dlp options(listed at https://github.com/yt-dlp/yt-dlp#usage-and-options)");
System.out.println("\t that will be appended at the end(but before the url) of yt-dlp execution.");
System.out.println("\t If your options contains space, wrap them with \"\"");
System.out.println("\t If you need multiple options, wrap them with \"\"");
System.out.println(); System.out.println();
System.out.println("exit codes :");
Arrays.stream(ExitCodes.values()).forEach(code -> {
Expand All @@ -102,8 +107,10 @@ public static void main(String[] args) {
datePrefix = true;
} else if ("--logbyTask".equals(arg)) {
logbyTask = true;
} else if (arg.startsWith("--ytdlpArgs")) {
ytdlpAdditionalOptions = arg.split("=")[1].split(" ");
} else {
System.err.println("Unknown option : \"" + arg + "\"");
System.err.println("Invaild option : \"" + arg + "\"");
System.err.println("If you want to find usage, please use --help flag");
Main.kill(ExitCodes.INVALIDCOMMANDARGS);
}
Expand Down Expand Up @@ -263,7 +270,7 @@ private static void submitDownload(String data) {
SwingDialogs.error("Download Path is invalid!", "Invalid path : " + save, null, false);
return;
}
YoutubeAudioDownloader.download(url, t, p);
YoutubeAudioDownloader.download(url, t, p, ytdlpAdditionalOptions);
} else {
t.failed();
SwingDialogs.error("[Task" + num + "|validating] Not a valid url!", data + "\nis invalid or unsupported url!", null, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public static void download(String url, TaskData task, PlayListOption playListOp
}
arguments.add(url);

if(additianalOptions.length != 0) arguments.addAll(1, Arrays.asList(additianalOptions));
if(additianalOptions.length != 0) arguments.addAll(arguments.size() - 1, Arrays.asList(additianalOptions));


// retrieve command line argument
Expand Down

0 comments on commit 53acf64

Please sign in to comment.