From 2aaeeb3053e464c9d383bedd21ed4e8593b67ea0 Mon Sep 17 00:00:00 2001 From: Saptarshi Sarkar Date: Sun, 29 Oct 2023 12:56:30 +0530 Subject: [PATCH] fix: Applied fixes according to the linter --- mvnw | 0 src/main/java/CLI/Main.java | 18 ++-- src/main/java/GUI/Forms/FormsController.java | 12 +-- src/main/java/Utils/test.java | 98 ------------------- .../native-image/resource-config.json | 6 +- 5 files changed, 17 insertions(+), 117 deletions(-) mode change 100644 => 100755 mvnw delete mode 100644 src/main/java/Utils/test.java diff --git a/mvnw b/mvnw old mode 100644 new mode 100755 diff --git a/src/main/java/CLI/Main.java b/src/main/java/CLI/Main.java index f5d0ffa4f..351cbaef7 100644 --- a/src/main/java/CLI/Main.java +++ b/src/main/java/CLI/Main.java @@ -97,16 +97,14 @@ public static void main(String[] args) { isSpotifyLink = isSpotify(link); downloadsFolder = location; downloadsFolder = getProperDownloadsFolder(downloadsFolder); - if (name == null) { - if (fileName == null || fileName.isEmpty()) { - if (isSpotifyLink && link.contains("playlist")) { - handleSpotifyPlaylist(); - } else { - messageBroker.msgFilenameInfo("Retrieving filename from link..."); - fileName = findFilenameInLink(link); - Job job = new Job(link, downloadsFolder, fileName, false); - checkHistoryAddJobsAndDownload(job, false); - } + if ((name == null) && (fileName == null || fileName.isEmpty())) { + if (isSpotifyLink && link.contains("playlist")) { + handleSpotifyPlaylist(); + } else { + messageBroker.msgFilenameInfo("Retrieving filename from link..."); + fileName = findFilenameInLink(link); + Job job = new Job(link, downloadsFolder, fileName, false); + checkHistoryAddJobsAndDownload(job, false); } } } diff --git a/src/main/java/GUI/Forms/FormsController.java b/src/main/java/GUI/Forms/FormsController.java index 41af39b67..b21e9f84f 100644 --- a/src/main/java/GUI/Forms/FormsController.java +++ b/src/main/java/GUI/Forms/FormsController.java @@ -60,7 +60,7 @@ public final class FormsController { private final String nl = System.lineSeparator(); private int speedValueUpdateCount = 0; private int speedValue = 0; - private String filename = ""; + private String songName = ""; private Folders folders; private Job selectedJob; @@ -210,7 +210,7 @@ private void processLink() { String[] filenames = getSongFilenames(json); for (int i = 0; i < songs.length; i++) { String songLink = songs[i]; - filename = filenames[i] + ".mp3"; + songName = filenames[i] + ".mp3"; verifyLinksAndWaitFor(songLink); } } else { @@ -298,7 +298,7 @@ private Runnable verifyLink(String link) { if (Utility.isLinkValid(link)) { if (getHistory().exists(link)) { Job job = getHistory().getJob(link); - filename = job.getFilename(); + String filename = job.getFilename(); dir = getDir(); if (dir == null) { M.msgDirError("Download folder is not set!"); @@ -323,8 +323,8 @@ private Runnable verifyLink(String link) { addJob(new Job(link, dir, filename, true)); } } else if (Utility.isExtractableLink(link)) { - if (isSpotify(link) && !filename.isEmpty()) { - addJob(new Job(link, getDir(), filename, true)); + if (isSpotify(link) && !songName.isEmpty()) { + addJob(new Job(link, getDir(), songName, true)); } else { Thread getNames = new Thread(getFilenames(link)); getNames.start(); @@ -356,7 +356,7 @@ private Runnable getFilenames(String link) { These bindings allow the Worker thread to post relevant information to the UI, including the progress bar which accurately depicts the remaining number of filenames to extract from the link. However, if there is only one filename to extract, the progress bar goes through a static animation to indicate that the program is not frozen. - The controls that are bound to the thread cannot have their text updated while they ae bound or else an error + The controls that are bound to the thread cannot have their text updated while they are bound or else an error will be thrown and possibly the program execution halted. */ form.lblDownloadInfo.textProperty().bind(((Worker>) task).messageProperty()); diff --git a/src/main/java/Utils/test.java b/src/main/java/Utils/test.java deleted file mode 100644 index 0db09f366..000000000 --- a/src/main/java/Utils/test.java +++ /dev/null @@ -1,98 +0,0 @@ -package Utils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.regex.MatchResult; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Stream; - -public class test { - static String json = """ - [ - { - "name": "The Other (Shallou Remix)", - "artists": [ - "Lauv", - "Shallou" - ], - "artist": "Lauv", - "genres": [ - "pop" - ], - "disc_number": 1, - "disc_count": 1, - "album_name": "The Other (Remixes)", - "album_artist": "Lauv", - "duration": 210000, - "year": "2017", - "date": "2017-03-17", - "track_number": 2, - "tracks_count": 5, - "song_id": "3X4AcIcgHFEqVhZjxiqJtl", - "explicit": false, - "publisher": "Lauv", - "url": "https://open.spotify.com/track/3X4AcIcgHFEqVhZjxiqJtl", - "isrc": "TCACZ1708146", - "cover_url": "https://i.scdn.co/image/ab67616d0000b273043cc4551a8294ebcb93917e", - "copyright_text": "2017 Lauv", - "download_url": null, - "lyrics": null, - "popularity": 0, - "album_id": "5x7wsSiudoWtTAaU2ReB7Q", - "list_name": "Chill", - "list_url": "https://open.spotify.com/playlist/4PhriPzBV7HrnuwA7Z9YYh", - "list_position": 1, - "list_length": 130 - }, - { - "name": "Different Skies", - "artists": [ - "Shoffy" - ], - "artist": "Shoffy", - "genres": [ - "chill pop", - "la pop" - ], - "disc_number": 1, - "disc_count": 1, - "album_name": "Different Skies", - "album_artist": "Shoffy", - "duration": 153939, - "year": "2017", - "date": "2017-01-21", - "track_number": 1, - "tracks_count": 1, - "song_id": "6Gu1BaGI5ijqEqK3g6gvMi", - "explicit": true, - "publisher": "641809 Records DK", - "url": "https://open.spotify.com/track/6Gu1BaGI5ijqEqK3g6gvMi", - "isrc": "QZ4JJ1743715", - "cover_url": "https://i.scdn.co/image/ab67616d0000b2732a8d57e046fdeba6ab6b049f", - "copyright_text": "2017 641809 Records DK", - "download_url": null, - "lyrics": null, - "popularity": 36, - "album_id": "0CgqiKbBr0cTc30GO0NAYh", - "list_name": "Chill", - "list_url": "https://open.spotify.com/playlist/4PhriPzBV7HrnuwA7Z9YYh", - "list_position": 2, - "list_length": 130 - } - ]"""; - - public static void main(String[] args) { - String linkRegex = "(\"url\": \")(.+)(\",)"; - Pattern linkPattern = Pattern.compile(linkRegex); - Matcher linkMatcher = linkPattern.matcher(json); - ArrayList songLinks = new ArrayList<>(); - linkMatcher.results().forEach(matchResult -> { - String songLink = matchResult.group(2); - songLinks.add(songLink); - }); - System.out.println(songLinks); - String[] songs = songLinks.toArray(String[]::new); - } -} diff --git a/src/main/resources/META-INF/native-image/resource-config.json b/src/main/resources/META-INF/native-image/resource-config.json index 6a6dd7a89..a58ea7a69 100644 --- a/src/main/resources/META-INF/native-image/resource-config.json +++ b/src/main/resources/META-INF/native-image/resource-config.json @@ -59,12 +59,12 @@ }]}, "bundles":[{ "name":"com.sun.javafx.tk.quantum.QuantumMessagesBundle", - "locales":["", "und"] + "locales":[""] }, { "name":"com.sun.org.apache.xml.internal.serializer.XMLEntities", - "locales":["", "und"] + "locales":[""] }, { "name":"com/sun/javafx/scene/control/skin/resources/controls", - "locales":["", "und"] + "locales":[""] }] }