removed progress bar
This commit is contained in:
@@ -49,38 +49,22 @@ public class LastFMToSpotify {
|
|||||||
|
|
||||||
|
|
||||||
// Start Progress Bar
|
// Start Progress Bar
|
||||||
try (ProgressBar pb = new ProgressBar("LastFM -> Spotify Playlist", 4)) {
|
try {
|
||||||
for (int progress = 1; progress<=5; progress++) {
|
logLn("Authenticating with Spotify...", 1);
|
||||||
pb.step(); // step by 1
|
logLn("Authenticating with LastFM...", 1);
|
||||||
switch (progress) {
|
Caller.getInstance().setUserAgent(configuration.get("requests.useragent"));
|
||||||
case 1:
|
logLn(User.getInfo(configuration.get("lastfm.user"), configuration.get("lastfm.apikey")).getName(), 1);
|
||||||
pb.setExtraMessage("Authenticating with Spotify...");
|
logLn("Reading from LastFM...", 1);
|
||||||
|
User.getTopTracks(configuration.get("lastfm.user"), Period.ONE_MONTH, configuration.get("lastfm.apikey"));
|
||||||
break;
|
logLn("Creating Playlist...", 1);
|
||||||
case 2:
|
SpotifyApi.Builder build = SpotifyApi.builder();
|
||||||
pb.setExtraMessage("Authenticating with LastFM...");
|
build.setClientId(configuration.get("spotify.clientid"));
|
||||||
Caller.getInstance().setUserAgent(configuration.get("requests.useragent"));
|
build.setClientSecret(configuration.get("spotify.secret"));
|
||||||
logLn(User.getInfo(configuration.get("lastfm.user"), configuration.get("lastfm.apikey")).getName(), 1);
|
build.setRedirectUri(URI.create("http://localhost:9876/callback/spotify/"));
|
||||||
break;
|
SpotifyApi api = build.build();
|
||||||
case 3:
|
api.setAccessToken(configuration.get("spotify.access"));
|
||||||
pb.setExtraMessage("Reading from LastFM...");
|
api.createPlaylist(api.getCurrentUsersProfile().build().execute().getId(), configuration.get("playlist.name")).setHeader("User-Agent", configuration.get("requests.useragent"));
|
||||||
User.getTopTracks(configuration.get("lastfm.user"), Period.ONE_MONTH, configuration.get("lastfm.apikey"));
|
logLn("Done.", 1);
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
pb.setExtraMessage("Creating Playlist...");
|
|
||||||
SpotifyApi.Builder build = SpotifyApi.builder();
|
|
||||||
build.setClientId(configuration.get("spotify.clientid"));
|
|
||||||
build.setClientSecret(configuration.get("spotify.secret"));
|
|
||||||
build.setRedirectUri(URI.create("http://localhost:9876/callback/spotify/"));
|
|
||||||
SpotifyApi api = build.build();
|
|
||||||
api.setAccessToken(configuration.get("spotify.access"));
|
|
||||||
api.createPlaylist(api.getCurrentUsersProfile().build().execute().getId(), configuration.get("playlist.name")).setHeader("User-Agent", configuration.get("requests.useragent"));
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
pb.setExtraMessage("Done.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException | ParseException | SpotifyWebApiException e) {
|
} catch (IOException | ParseException | SpotifyWebApiException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user