Implemented public / collaborative flag
closes #6 also stated flag exclusivity in argument descriptions
This commit is contained in:
@@ -93,7 +93,7 @@ public class LastFMToSpotify {
|
||||
Collection<Track> tracks = User.getTopTracks(configuration.get("lastfm.user"), PeriodHelper.getPeriodByString(configuration.get("lastfm.period")), configuration.get("lastfm.apikey"));
|
||||
logLn("Creating Playlist...", 1);
|
||||
api.setAccessToken(configuration.get("spotify.access"));
|
||||
Playlist list = api.createPlaylist(api.getCurrentUsersProfile().build().execute().getId(), configuration.get("playlist.name")).public_(configuration.containsKey("playlist.public")||configuration.containsKey("playlist.collab")).collaborative(configuration.containsKey("playlist.collab")).setHeader("User-Agent", configuration.get("requests.useragent")).build().execute();
|
||||
Playlist list = api.createPlaylist(api.getCurrentUsersProfile().build().execute().getId(), configuration.get("playlist.name")).public_(configuration.containsKey("playlist.public")).collaborative(configuration.containsKey("playlist.collab")).setHeader("User-Agent", configuration.get("requests.useragent")).build().execute();
|
||||
List<String> adders = new LinkedList<>();
|
||||
String charsToReplace = "[\"']"; //regex for " and '
|
||||
for (Track track : tracks) {
|
||||
|
||||
@@ -39,6 +39,8 @@ public class ArgumentHandler {
|
||||
case YEARLY -> period(Period.TWELVE_MONTHS);
|
||||
case COVER -> cover(value);
|
||||
case NAME -> name(value);
|
||||
case PUBLIC -> access("public");
|
||||
case COLLABORATIVE -> access("collaborative");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +141,13 @@ public class ArgumentHandler {
|
||||
configuration.put("playlist.cover", base64);
|
||||
}
|
||||
|
||||
private static void access(String value) {
|
||||
switch (value) {
|
||||
case "collaborative" -> configuration.put("playlist.collab", "collab");
|
||||
case "public" -> configuration.put("playlist.public", "public");
|
||||
}
|
||||
}
|
||||
|
||||
private static void name(String value) {
|
||||
if (value == null || value.equalsIgnoreCase("")) {
|
||||
System.out.println("--playlistname must be provided with a playlist name. Check usage: " + Arguments.NAME.getUsage());
|
||||
|
||||
@@ -24,20 +24,24 @@ public enum Arguments {
|
||||
+ "Sets the LastFM API token.", "--lastfmtoken <apitoken>", "lT", "lToken"),
|
||||
USER("lastfmuser", "[Required]" + LINE_SEPERATOR
|
||||
+ "Sets the LastFM API token.", "--lastfmuser <username>", "lU", "lUser"),
|
||||
WEEKLY("weekly", "[Optional]" + LINE_SEPERATOR
|
||||
WEEKLY("weekly", "[Optional] [EXCLUSIVE: weekly, monthly, quarterly, biannually, annually]" + LINE_SEPERATOR
|
||||
+ "Creates a playlist from your top tracks from last week.", "--weekly", "W"),
|
||||
MONTHLY("monthly", "[Optional, Default]" + LINE_SEPERATOR
|
||||
MONTHLY("monthly", "[Optional, Default] [EXCLUSIVE: weekly, monthly, quarterly, biannually, annually]" + LINE_SEPERATOR
|
||||
+ "Creates a playlist from your top tracks from last month.", "--monthly", "M"),
|
||||
QUARTERLY("quarterly", "[Optional]" + LINE_SEPERATOR
|
||||
QUARTERLY("quarterly", "[Optional] [EXCLUSIVE: weekly, monthly, quarterly, biannually, annually]" + LINE_SEPERATOR
|
||||
+ "Creates a playlist from your top tracks from last quarter.", "--quarterly", "Q"),
|
||||
BIANNUALLY("biannually", "[Optional]" + LINE_SEPERATOR
|
||||
BIANNUALLY("biannually", "[Optional] [EXCLUSIVE: weekly, monthly, quarterly, biannually, annually]" + LINE_SEPERATOR
|
||||
+ "Creates a playlist from your top tracks from last half-year.", "--biannualy", "B"),
|
||||
YEARLY("yearly", "[Optional]" + LINE_SEPERATOR
|
||||
YEARLY("annually", "[Optional] [EXCLUSIVE: weekly, monthly, quarterly, biannually, annually]" + LINE_SEPERATOR
|
||||
+ "Creates a playlist from your top tracks from last year.", "--anually", "A"),
|
||||
COVER("coverart", "[Optional]" + LINE_SEPERATOR
|
||||
+ "Will set a cover art for the playlist. Must be jpeg/jpg.", "--coverart <path/to/coverart.jpg>", "ca", "cover"),
|
||||
NAME("playlistname", "[Optional]" + LINE_SEPERATOR
|
||||
+ "Sets the playlist name. Supports templating. Refer to https://github.com/B00tLoad/LastFMtoSpotifyPlaylist/wiki/Filename-Templating.", "--playlistname <name>", "pName", "pN");
|
||||
+ "Sets the playlist name. Supports templating. Refer to https://github.com/B00tLoad/LastFMtoSpotifyPlaylist/wiki/Filename-Templating.", "--playlistname <name>", "pName", "pN"),
|
||||
PUBLIC("public", "[Optional] [EXCLUSIVE: public, collaborative]" + LINE_SEPERATOR
|
||||
+ "Makes the playlist public.", "--public", "pP"),
|
||||
COLLABORATIVE("collaborative", "[Optional] [EXCLUSIVE: public, collaborative]" + LINE_SEPERATOR
|
||||
+ "Makes the playlist collaborative.", "--collaborative", "pC");
|
||||
|
||||
private final String name;
|
||||
private final String description;
|
||||
|
||||
Reference in New Issue
Block a user