Skip to content

Commit

Permalink
style: Formatted Java files
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 24, 2023
1 parent 3ea8c9e commit 38e550f
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/main/java/Backend/DownloadFolderLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public void run() {
while ((c = is.read()) != -1) {
sw.write(c);
}
} catch (IOException ignored) {}
} catch (IOException ignored) {
}
}

public String getResult() {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/Backend/DownloaderThread.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package Backend;

import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;

public class DownloaderThread extends Thread {
private final URL url;
private final long start;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/Enums/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ public enum Program {
public static void setYtDlpExecutableName(String name) {
Program.ytDLP = name;
}

public static void setSpotdlExecutableName(String name) {
Program.spotdl = name;
}

public static void setDriftyPath(String path) { Program.driftyPath = path; }
public static void setDriftyPath(String path) {
Program.driftyPath = path;
}

public static String get(Program program) {
return switch (program) {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/GUI/Forms/GetFilename.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,16 @@ public void run() {
FormsController.addJob(jobList);
deleteList.addLast(file);
}
} catch (IOException ignored) {}
} catch (IOException ignored) {
}
}
for (File file : deleteList) {
try {
if (file.exists()) {
FileUtils.forceDelete(file);
}
} catch (IOException ignored) {}
} catch (IOException ignored) {
}
}
}
};
Expand Down Expand Up @@ -171,7 +173,7 @@ private Runnable getFileCount() {
try (
InputStream inputStream = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))
)
)
{
String line;
while ((line = reader.readLine()) != null) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/GUI/Support/Jobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
public class Jobs {
private ConcurrentLinkedDeque<Job> jobList;

public Jobs() {
this.jobList = new ConcurrentLinkedDeque<>();
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/Preferences/Clear.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public final class Clear { // This class is used to clear the user preferences
private static final Clear INSTANCE = new Clear();
private final Preferences preferences = Labels.PREFERENCES;

private Clear() {}
private Clear() {
}

static Clear getInstance() {
return INSTANCE;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/Preferences/Get.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public final class Get { // This class is used to get the user preferences
private static final Get INSTANCE = new Get();
private final Preferences preferences = Labels.PREFERENCES;

private Get() {}
private Get() {
}

static Get getInstance() {
return INSTANCE;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/Preferences/Set.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class Set { // This class is used to set the user preferences
private static final Set INSTANCE = new Set();
private final Preferences preferences = Labels.PREFERENCES;

public Set() {}
public Set() {
}

protected static Set getInstance() {
return INSTANCE;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/Utils/DriftyConstants.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package Utils;

/**
* This file contains some String constants which are repeatedly used in the whole project.
*/
public final class DriftyConstants {
/**
* This is a private constructor of this class.
*/
private DriftyConstants() {}
private DriftyConstants() {
}
public static final String VERSION_NUMBER = "v2.1.0";
public static final String APPLICATION_NAME = "Drifty";
public static final String DRIFTY_WEBSITE_URL = "https://saptarshisarkar12.github.io/Drifty/";
Expand Down
1 change: 1 addition & 0 deletions src/main/java/Utils/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public static void checkAndUpdateYtDlp() {
msgBroker.msgInitError("Component (yt-dlp) update process was interrupted! " + e.getMessage());
}
}

public static boolean isYtDLPUpdated() {
final long oneDay = 1000 * 60 * 60 * 24; // Value of one day (24 Hours) in milliseconds
long timeSinceLastUpdate = System.currentTimeMillis() - AppSettings.GET.lastDLPUpdateTime();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/Utils/ScannerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
public final class ScannerFactory { // This class is used to get a scanner object
private static Scanner scanner;

private ScannerFactory() {}
private ScannerFactory() {
}

public static Scanner getInstance() {
if (scanner == null) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/Utils/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static boolean isInstagram(String url) {
String pattern = "(https?://(?:www\\.)?instagr(am|.am)?(\\.com)?/(p|reel)/([^/?#&]+)).*";
return url.matches(pattern);
}

public static boolean isSpotify(String url) {
String pattern = "(https?://(open.spotify\\.com|play\\.spotify\\.com)/(track|album|playlist)/[a-zA-Z0-9]+).*";
return url.matches(pattern);
Expand Down Expand Up @@ -182,7 +183,7 @@ public static LinkedList<String> getLinkMetadata(String link) {
return null;
}
Thread linkThread;
if (isSpotify(link)){
if (isSpotify(link)) {
linkThread = new Thread(spotdlJsonData(Program.getSpotdlDataPath().toFile().getAbsolutePath(), link));
} else {
linkThread = new Thread(ytDLPJsonData(driftyJsonFolder.getAbsolutePath(), link));
Expand Down Expand Up @@ -316,6 +317,7 @@ private static Runnable spotdlJsonData(String folderPath, String link) {
.run();
};
}

public static boolean isURL(String text) {
String regex = "^(http(s)?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
Pattern p = Pattern.compile(regex);
Expand Down

1 comment on commit 38e550f

@vercel
Copy link

@vercel vercel bot commented on 38e550f Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.