Merge pull request #10 from B00tLoad/morril
Morril
This commit was merged in pull request #10.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
/target/
|
/target/
|
||||||
.idea/
|
.idea/
|
||||||
compile.bat
|
compile.bat
|
||||||
|
.vscode/
|
||||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"java.configuration.updateBuildConfiguration": "interactive"
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import com.neovisionaries.i18n.CountryCode;
|
|||||||
import de.b00tload.tools.lastfmtospotifyplaylist.arguments.ArgumentHandler;
|
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.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;
|
||||||
@@ -36,6 +37,11 @@ public class LastFMToSpotify {
|
|||||||
configuration = new HashMap<>();
|
configuration = new HashMap<>();
|
||||||
configuration.put("requests.useragent", "LastFMToSpotify/1.0-Snapshot (" + System.getProperty("os.name") + "; " + System.getProperty("os.arch") + ") Java/" + System.getProperty("java.version"));
|
configuration.put("requests.useragent", "LastFMToSpotify/1.0-Snapshot (" + System.getProperty("os.name") + "; " + System.getProperty("os.arch") + ") Java/" + System.getProperty("java.version"));
|
||||||
configuration.put("playlist.name", "LastFMToSpotify@" + LocalDateTime.now(Clock.systemDefaultZone()).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
|
configuration.put("playlist.name", "LastFMToSpotify@" + LocalDateTime.now(Clock.systemDefaultZone()).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
|
||||||
|
configuration.put("log.level", "1");
|
||||||
|
if (!ArgumentHandler.checkArguments(args)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// parse arguments
|
// parse arguments
|
||||||
for (int a = 0; a < args.length; a++) {
|
for (int a = 0; a < args.length; a++) {
|
||||||
Arguments arg;
|
Arguments arg;
|
||||||
@@ -59,6 +65,7 @@ public class LastFMToSpotify {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logLn("Authenticating with Spotify...", 1);
|
logLn("Authenticating with Spotify...", 1);
|
||||||
SpotifyApi.Builder build = SpotifyApi.builder();
|
SpotifyApi.Builder build = SpotifyApi.builder();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package de.b00tload.tools.lastfmtospotifyplaylist.arguments;
|
|||||||
|
|
||||||
import de.b00tload.tools.lastfmtospotifyplaylist.util.FileHelper;
|
import de.b00tload.tools.lastfmtospotifyplaylist.util.FileHelper;
|
||||||
import de.b00tload.tools.lastfmtospotifyplaylist.util.TimeHelper;
|
import de.b00tload.tools.lastfmtospotifyplaylist.util.TimeHelper;
|
||||||
|
|
||||||
import de.umass.lastfm.Period;
|
import de.umass.lastfm.Period;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -22,6 +23,10 @@ import static de.b00tload.tools.lastfmtospotifyplaylist.LastFMToSpotify.LINE_SEP
|
|||||||
import static de.b00tload.tools.lastfmtospotifyplaylist.LastFMToSpotify.configuration;
|
import static de.b00tload.tools.lastfmtospotifyplaylist.LastFMToSpotify.configuration;
|
||||||
import static de.b00tload.tools.lastfmtospotifyplaylist.util.Logger.logLn;
|
import static de.b00tload.tools.lastfmtospotifyplaylist.util.Logger.logLn;
|
||||||
|
|
||||||
|
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) {
|
||||||
@@ -48,6 +53,28 @@ public class ArgumentHandler {
|
|||||||
handle(argument, null);
|
handle(argument, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean checkArguments(String[] args) {
|
||||||
|
// check if all required arguments are given
|
||||||
|
Arguments[] required = {Arguments.SECRET, Arguments.CLIENT, Arguments.TOKEN, Arguments.USER};
|
||||||
|
for (Arguments argument : required) {
|
||||||
|
boolean found = false;
|
||||||
|
// check all aliases
|
||||||
|
for (String alias : argument.getAliases()) {
|
||||||
|
// if one alias is found check next argument
|
||||||
|
if (List.of(args).contains(alias)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// else return false
|
||||||
|
if (!found) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static void help(String value) {
|
private static void help(String value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
System.out.println("This is a list of all available commands. For more specific help on the argument run --help <argument>.");
|
System.out.println("This is a list of all available commands. For more specific help on the argument run --help <argument>.");
|
||||||
@@ -130,6 +157,7 @@ public class ArgumentHandler {
|
|||||||
|
|
||||||
private static void period(Period value) {
|
private static void period(Period value) {
|
||||||
configuration.put("lastfm.period", value.getString());
|
configuration.put("lastfm.period", value.getString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void cover(String value) {
|
private static void cover(String value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user