Skip to content

Commit

Permalink
add "open config.txt" button
Browse files Browse the repository at this point in the history
  • Loading branch information
awidesky committed Jun 1, 2021
1 parent 7b6f15a commit 410029f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/com/awidesky/YoutubeClipboardAutoDownloader/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ private static void readProperties() {

String s;
while((s = br.readLine()) != null) {
if(s.startsWith("#") || s.equals("https://www.youtu")) continue;
if(s.equals("") || s.startsWith("#") || s.equals("https://www.youtu")) continue;
Config.addAcceptableList(s);
}

Expand Down Expand Up @@ -340,11 +340,13 @@ public static void writeProperties() {
bw.write("FileNameFormat=" + Config.getFileNameFormat() + "\n");
bw.write("ClipboardListenOption=" + Config.getClipboardListenOption() + "\n");

bw.newLine();
bw.write("#If you know a type of link that youtube-dl accepts (listed in https://github.com/ytdl-org/youtube-dl/blob/master/docs/supportedsites.md),\n");
bw.write("#and wish YoutubeAudioDownloader detact & download it, you can write how does the link starts(e.g. in youtube, \"https://www.youtu\")\n");
bw.write("#Every line starting with # will be ignored, but DO NOT CHANGE lines before these comments.\n");
bw.write("#If you want to modify those, please do it in YoutubeAudioDownloader GUI,\n");
bw.write("#and let my spaghetti handle that hardcoded shit. :)\n");
bw.newLine();

bw.write(Config.getAcceptedLinkStr());

Expand Down Expand Up @@ -462,6 +464,17 @@ public LoggerThread() {

}

public static void openConfig() {

File f = new File(YoutubeAudioDownloader.getProjectpath() + File.separator + "config.txt");
try {
Desktop.getDesktop().open(f);
} catch (IOException e) {
GUI.warning("Cannot open default text file editor!", "Please open" + f.getAbsolutePath() + "\n%e%", e);
}

}

}


6 changes: 5 additions & 1 deletion src/com/awidesky/YoutubeClipboardAutoDownloader/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class GUI {


private JFrame mainFrame;
private JButton browse, cleanCompleted, cleanAll, nameFormatHelp;
private JButton browse, cleanCompleted, cleanAll, nameFormatHelp, openConfig;
private JLabel format, quality, path, nameFormat, playList;
private JTextField pathField, nameFormatField;
private JComboBox<String> cb_format, cb_quality, cb_playList, cb_clipboardOption;
Expand Down Expand Up @@ -198,6 +198,7 @@ private void addButtons() {
cleanCompleted = new JButton("clean completed");
cleanAll = new JButton("clean all");
nameFormatHelp = new JButton("<= help?");
openConfig = new JButton("open config.txt");

browse.addActionListener((e) -> {

Expand All @@ -216,16 +217,19 @@ private void addButtons() {
cleanCompleted.addActionListener((e) -> { TaskStatusModel.getinstance().clearDone(); });
cleanAll.addActionListener((e) -> { TaskStatusModel.getinstance().clearAll(); });
nameFormatHelp.addActionListener((e) -> { Main.webBrowse("https://github.com/ytdl-org/youtube-dl#output-template"); });
openConfig.addActionListener((e) -> {Main.openConfig();});

browse.setBounds(523, 75, browse.getPreferredSize().width, browse.getPreferredSize().height);
cleanCompleted.setBounds(14, 418, cleanCompleted.getPreferredSize().width, cleanCompleted.getPreferredSize().height);
cleanAll.setBounds(160, 418, cleanAll.getPreferredSize().width, cleanAll.getPreferredSize().height);
nameFormatHelp.setBounds(298, 121, nameFormatHelp.getPreferredSize().width, nameFormatHelp.getPreferredSize().height);
openConfig.setBounds(490, 418, openConfig.getPreferredSize().width, openConfig.getPreferredSize().height);

mainFrame.add(browse);
mainFrame.add(cleanCompleted);
mainFrame.add(cleanAll);
mainFrame.add(nameFormatHelp);
mainFrame.add(openConfig);

}

Expand Down

0 comments on commit 410029f

Please sign in to comment.