removed unused imports #11

Merged
Morril-2300 merged 2 commits from morril into master 2023-01-24 16:24:28 +01:00
3 changed files with 26 additions and 34 deletions

View File

@@ -6,7 +6,6 @@ import de.b00tload.tools.lastfmtospotifyplaylist.arguments.ArgumentHandler;
import de.b00tload.tools.lastfmtospotifyplaylist.arguments.Arguments; import de.b00tload.tools.lastfmtospotifyplaylist.arguments.Arguments;
import de.b00tload.tools.lastfmtospotifyplaylist.util.PeriodHelper; import de.b00tload.tools.lastfmtospotifyplaylist.util.PeriodHelper;
import de.b00tload.tools.lastfmtospotifyplaylist.util.TimeHelper;
import de.b00tload.tools.lastfmtospotifyplaylist.util.TokenHelper; import de.b00tload.tools.lastfmtospotifyplaylist.util.TokenHelper;
import de.umass.lastfm.Caller; import de.umass.lastfm.Caller;
import de.umass.lastfm.Track; import de.umass.lastfm.Track;

View File

@@ -11,11 +11,8 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.time.Clock; import java.time.Clock;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.TextStyle; import java.time.format.TextStyle;
import java.time.temporal.ChronoField; import java.time.temporal.ChronoField;
import java.time.temporal.IsoFields;
import java.time.temporal.TemporalField;
import java.time.temporal.WeekFields; import java.time.temporal.WeekFields;
import java.util.Locale; import java.util.Locale;
@@ -24,9 +21,6 @@ import static de.b00tload.tools.lastfmtospotifyplaylist.LastFMToSpotify.configur
import static de.b00tload.tools.lastfmtospotifyplaylist.util.Logger.logLn; import static de.b00tload.tools.lastfmtospotifyplaylist.util.Logger.logLn;
import java.util.List; import java.util.List;
import javax.xml.crypto.Data;
public class ArgumentHandler { public class ArgumentHandler {
public static void handle(Arguments argument, @Nullable String value) { public static void handle(Arguments argument, @Nullable String value) {
@@ -76,80 +70,80 @@ public class ArgumentHandler {
} }
private static void help(String value) { private static void help(String value) {
if (value == null) { if (value == null || value.isEmpty()) {
System.out.println("This is a list of all available commands. For more specific help on the argument run --help <argument>."); logLn("This is a list of all available commands. For more specific help on the argument run --help <argument>.", 1);
for (Arguments arg : Arguments.values()) { for (Arguments arg : Arguments.values()) {
String name = arg.getName(); String name = arg.getName();
String description = arg.getDescription(); String description = arg.getDescription();
System.out.println("____________________"); logLn("____________________", 1);
System.out.println(name); logLn(name, 1);
System.out.println(" DESCRIPTION" + LINE_SEPERATOR + description); logLn(" DESCRIPTION" + LINE_SEPERATOR + description, 1);
} }
System.exit(200); System.exit(200);
} }
Arguments arg = Arguments.resolveByNameOrAlias(value); Arguments arg = Arguments.resolveByNameOrAlias(value);
if (arg == null) { if (arg == null) {
System.out.println("This argument is unknown. Use --help to get a list of all arguments"); logLn("This argument is unknown. Use --help to get a list of all arguments", 1);
System.exit(200); System.exit(200);
} }
String name = arg.getName(); String name = arg.getName();
String description = arg.getDescription(); String description = arg.getDescription();
String[] aliases = arg.getAliases(); String[] aliases = arg.getAliases();
String usage = arg.getUsage(); String usage = arg.getUsage();
System.out.println(name); logLn(name ,1);
System.out.println(" DESCRIPTION" + LINE_SEPERATOR + description); logLn(" DESCRIPTION" + LINE_SEPERATOR + description, 1);
System.out.println(" USAGE: " + usage); logLn(" USAGE: " + usage, 1);
StringBuilder aliasString = new StringBuilder(); StringBuilder aliasString = new StringBuilder();
for (String alias : aliases) { for (String alias : aliases) {
aliasString.append(", -").append(alias); aliasString.append(", -").append(alias);
} }
System.out.println(" ALIASES:" + aliasString.substring(1)); logLn(" ALIASES:" + aliasString.substring(1), 1);
System.out.println("____________________"); logLn("____________________", 1);
System.exit(200); System.exit(200);
} }
private static void verbose(String value) { private static void verbose(String value) {
if (value == null) { if (value == null || value.isEmpty()) {
System.out.println("--loglevel must be provided with a numeric log level. Check usage: " + Arguments.VERBOSE.getUsage()); logLn("--loglevel must be provided with a numeric log level. Check usage: " + Arguments.VERBOSE.getUsage(), 1);
System.exit(500); System.exit(500);
} }
try { try {
int loglevel = Integer.parseInt(value); int loglevel = Integer.parseInt(value);
configuration.put("logging.level", String.valueOf(loglevel)); configuration.put("logging.level", String.valueOf(loglevel));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
System.out.println("LogLevel must be a numeric value."); logLn("LogLevel must be a numeric value.", 1);
System.exit(500); System.exit(500);
} }
} }
private static void token(String value) { private static void token(String value) {
if (value == null || value.equalsIgnoreCase("")) { if (value == null || value.isEmpty()) {
System.out.println("--lastfmtoken must be provided with an api token from LastFM. Check usage: " + Arguments.TOKEN.getUsage()); logLn("--lastfmtoken must be provided with an api token from LastFM. Check usage: " + Arguments.TOKEN.getUsage(), 1);
System.exit(500); System.exit(500);
} }
configuration.put("lastfm.apikey", value); configuration.put("lastfm.apikey", value);
} }
private static void user(String value) { private static void user(String value) {
if (value == null || value.equalsIgnoreCase("")) { if (value == null || value.isEmpty()) {
System.out.println("--lastfmuser must be provided with a LastFM username. Check usage: " + Arguments.USER.getUsage()); logLn("--lastfmuser must be provided with a LastFM username. Check usage: " + Arguments.USER.getUsage(), 1);
System.exit(500); System.exit(500);
} }
configuration.put("lastfm.user", value); configuration.put("lastfm.user", value);
} }
private static void client(String value) { private static void client(String value) {
if (value == null || value.equalsIgnoreCase("")) { if (value == null || value.isEmpty()) {
System.out.println("--spotifyclient must be provided with a client id from Spotify. Check usage: " + Arguments.CLIENT.getUsage()); logLn("--spotifyclient must be provided with a client id from Spotify. Check usage: " + Arguments.CLIENT.getUsage(), 1);
System.exit(500); System.exit(500);
} }
configuration.put("spotify.clientid", value); configuration.put("spotify.clientid", value);
} }
private static void secret(String value) { private static void secret(String value) {
if (value == null || value.equalsIgnoreCase("")) { if (value == null || value.isEmpty()) {
System.out.println("--spotifysecret must be provided with a client secret from Spotify. Check usage: " + Arguments.SECRET.getUsage()); logLn("--spotifysecret must be provided with a client secret from Spotify. Check usage: " + Arguments.SECRET.getUsage(), 1);
System.exit(500); System.exit(500);
} }
configuration.put("spotify.secret", value); configuration.put("spotify.secret", value);
@@ -161,8 +155,8 @@ public class ArgumentHandler {
} }
private static void cover(String value) { private static void cover(String value) {
if (value == null || value.equalsIgnoreCase("") || !Files.exists(Path.of(value.replace("\\", "//")))) { if (value == null || value.isEmpty() || !Files.exists(Path.of(value.replace("\\", "//")))) {
System.out.println("--coverart must be provided with a path to a png file. Check usage: " + Arguments.COVER.getUsage()); logLn("--coverart must be provided with a path to a png file. Check usage: " + Arguments.COVER.getUsage(), 1);
System.exit(500); System.exit(500);
} }
String base64 = FileHelper.encodeFileToBase64(new File(value.replace("\\", "//"))); String base64 = FileHelper.encodeFileToBase64(new File(value.replace("\\", "//")));
@@ -177,8 +171,8 @@ public class ArgumentHandler {
} }
private static void name(String value) { private static void name(String value) {
if (value == null || value.equalsIgnoreCase("")) { if (value == null || value.isEmpty()) {
System.out.println("--playlistname must be provided with a playlist name. Check usage: " + Arguments.NAME.getUsage()); logLn("--playlistname must be provided with a playlist name. Check usage: " + Arguments.NAME.getUsage(), 1);
System.exit(500); System.exit(500);
} }
LocalDateTime now = LocalDateTime.now(Clock.systemDefaultZone()); LocalDateTime now = LocalDateTime.now(Clock.systemDefaultZone());

View File

@@ -2,7 +2,6 @@ package de.b00tload.tools.lastfmtospotifyplaylist.util;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZoneOffset;
public class TimeHelper { public class TimeHelper {