From ffcfc7bc77ae2c8e9a049634df1bacc4466ab724 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Wed, 1 Jun 2016 11:31:05 -0500 Subject: [PATCH] Simplify the new playlist creation logic. --- .../wdiwtlt/cli/CommandLineInterface.groovy | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy b/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy index 384b613..fa3bb1d 100644 --- a/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy +++ b/cli/src/main/groovy/com/jdbernard/wdiwtlt/cli/CommandLineInterface.groovy @@ -602,22 +602,16 @@ Configuration: return b case ~/playlist named (.+) from (queue|selection|.+)/: - Playlist p - if (Matcher.lastMatcher[0][2] == 'queue') { - p = playQueue.clone() - p.name = Matcher.lastMatcher[0][1].trim() - p.id = null - p = library.save(p) } - else { - p = new Playlist(name: Matcher.lastMatcher[0][1]) - p = library.save(p) + Playlist p = library.save( + new Playlist( name: Matcher.lastMatcher[0][1].trim())) - if (Matcher.lastMatcher[0][2] != 'selection') - selection = select(Matcher.lastMatcher[0][2], selection) + if (Matcher.lastMatcher[0][2] != 'selection') + selection = select(Matcher.lastMatcher[0][2], selection) - library.addToPlaylist(p.id, - library.collectMediaFiles(selection).collect { it.id }) } + library.addToPlaylist(p.id, + library.collectMediaFiles(selection).collect { it.id }) + msg "New playlist: ${p.id}: ${p.name}" return p case ~/playlist named (.+)/: