Implemented Tokens
The arguments for spotify and lastfm auth are now being handled.
This commit is contained in:
@@ -47,10 +47,6 @@ public class LastFMToSpotify {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logLn("Priority 0",0 );
|
|
||||||
logLn("Priority 1",1 );
|
|
||||||
logLn("Priority 2",2 );
|
|
||||||
logLn("Priority 3",3 );
|
|
||||||
|
|
||||||
// Start Progress Bar
|
// Start Progress Bar
|
||||||
try (ProgressBar pb = new ProgressBar("LastFM -> Spotify Playlist", 4)) {
|
try (ProgressBar pb = new ProgressBar("LastFM -> Spotify Playlist", 4)) {
|
||||||
@@ -64,7 +60,7 @@ public class LastFMToSpotify {
|
|||||||
case 2:
|
case 2:
|
||||||
pb.setExtraMessage("Authenticating with LastFM...");
|
pb.setExtraMessage("Authenticating with LastFM...");
|
||||||
Caller.getInstance().setUserAgent(configuration.get("requests.useragent"));
|
Caller.getInstance().setUserAgent(configuration.get("requests.useragent"));
|
||||||
User.getInfo(configuration.get("lastfm.user"), configuration.get("lastfm.apikey")).getName();
|
logLn(User.getInfo(configuration.get("lastfm.user"), configuration.get("lastfm.apikey")).getName(), 1);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
pb.setExtraMessage("Reading from LastFM...");
|
pb.setExtraMessage("Reading from LastFM...");
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package de.b00tload.tools.lastfmtospotifyplaylist.arguments;
|
package de.b00tload.tools.lastfmtospotifyplaylist.arguments;
|
||||||
|
|
||||||
import de.b00tload.tools.lastfmtospotifyplaylist.util.Logger;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import static de.b00tload.tools.lastfmtospotifyplaylist.LastFMToSpotify.LINE_SEPERATOR;
|
import static de.b00tload.tools.lastfmtospotifyplaylist.LastFMToSpotify.LINE_SEPERATOR;
|
||||||
@@ -12,6 +11,10 @@ public class ArgumentHandler {
|
|||||||
switch (argument){
|
switch (argument){
|
||||||
case HELP -> help(value);
|
case HELP -> help(value);
|
||||||
case VERBOSE -> verbose(value);
|
case VERBOSE -> verbose(value);
|
||||||
|
case SECRET -> secret(value);
|
||||||
|
case CLIENT -> client(value);
|
||||||
|
case TOKEN -> token(value);
|
||||||
|
case USER -> user(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,6 +56,10 @@ public class ArgumentHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void verbose(String value){
|
private static void verbose(String value){
|
||||||
|
if(value == null){
|
||||||
|
System.out.println("--loglevel must be provided with a numeric log level. Check usage: " + Arguments.VERBOSE.getUsage());
|
||||||
|
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));
|
||||||
@@ -62,4 +69,36 @@ public class ArgumentHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void token(String value) {
|
||||||
|
if(value == null || value.equalsIgnoreCase("")){
|
||||||
|
System.out.println("--lastfmtoken must be provided with an api token from LastFM. Check usage: " + Arguments.TOKEN.getUsage());
|
||||||
|
System.exit(500);
|
||||||
|
}
|
||||||
|
configuration.put("lastfm.apikey", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void user(String value) {
|
||||||
|
if(value == null || value.equalsIgnoreCase("")){
|
||||||
|
System.out.println("--lastfmuser must be provided with a LastFM username. Check usage: " + Arguments.USER.getUsage());
|
||||||
|
System.exit(500);
|
||||||
|
}
|
||||||
|
configuration.put("lastfm.user", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void client(String value) {
|
||||||
|
if(value == null || value.equalsIgnoreCase("")){
|
||||||
|
System.out.println("--spotifyclient must be provided with a client id from Spotify. Check usage: " + Arguments.CLIENT.getUsage());
|
||||||
|
System.exit(500);
|
||||||
|
}
|
||||||
|
configuration.put("spotify.clientid", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void secret(String value) {
|
||||||
|
if(value == null || value.equalsIgnoreCase("")){
|
||||||
|
System.out.println("--spotifysecret must be provided with a client secret from Spotify. Check usage: " + Arguments.SECRET.getUsage());
|
||||||
|
System.exit(500);
|
||||||
|
}
|
||||||
|
configuration.put("spotify.secret", value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,14 @@ public enum Arguments {
|
|||||||
+ " - 2: Verbose Will echo current step being worked on" + LINE_SEPERATOR
|
+ " - 2: Verbose Will echo current step being worked on" + LINE_SEPERATOR
|
||||||
+ " - 3: Debug Will give specific information on what excactly the tool is doing",
|
+ " - 3: Debug Will give specific information on what excactly the tool is doing",
|
||||||
"--loglevel <level>", "log", "l"),
|
"--loglevel <level>", "log", "l"),
|
||||||
SECRET("spotifysecret", "[]", "--spotifysecret <secret>", "sS", "sSecret");
|
SECRET("spotifysecret", "[Required]" + LINE_SEPERATOR
|
||||||
|
+ "Sets the spotify client secret.", "--spotifysecret <secret>", "sS", "sSecret"),
|
||||||
|
CLIENT("spotifyclient", "[Required]" + LINE_SEPERATOR
|
||||||
|
+ "Sets the spotify cliend id.", "--spotifyclient <clientid>", "sC", "sClient"),
|
||||||
|
TOKEN("lastfmtoken", "[Required]" + LINE_SEPERATOR
|
||||||
|
+ "Sets the LastFM API token.", "--lastfmtoken <apitoken>", "lT", "lToken"),
|
||||||
|
USER("lastfmuser", "[Required]" + LINE_SEPERATOR
|
||||||
|
+ "Sets the LastFM API token.", "--lastfmuser <username>", "lU", "lUser");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|||||||
Reference in New Issue
Block a user