Browse Source

Added option to import music from playlist to queue

Kristian Vos 4 years ago
parent
commit
2b1bc185b1
2 changed files with 15 additions and 5 deletions
  1. 3 2
      backend/logic/actions/queueSongs.js
  2. 12 3
      frontend/src/pages/Station/AddSongToQueue.vue

+ 3 - 2
backend/logic/actions/queueSongs.js

@@ -339,16 +339,17 @@ let lib = {
      *
      * @param {Object} session - the session object automatically added by socket.io
      * @param {String} url - the url of the the YouTube playlist
+     * @param {Boolean} musicOnly - whether to only get music from the playlist
      * @param {Function} cb - gets called with the result
      */
-    addSetToQueue: hooks.loginRequired((session, url, cb) => {
+    addSetToQueue: hooks.loginRequired((session, url, musicOnly, cb) => {
         async.waterfall(
             [
                 (next) => {
                     utils
                         .runJob("GET_PLAYLIST_FROM_YOUTUBE", {
                             url,
-                            musicOnly: false,
+                            musicOnly,
                         })
                         .then((res) => {
                             next(null, res.songs);

+ 12 - 3
frontend/src/pages/Station/AddSongToQueue.vue

@@ -113,18 +113,26 @@
 								type="text"
 								placeholder="YouTube Playlist URL"
 								v-model="importQuery"
-								@keyup.enter="importPlaylist()"
+								@keyup.enter="importPlaylist(false)"
 							/>
 						</p>
 						<p class="control">
 							<a
 								class="button is-info"
-								v-on:click="importPlaylist()"
+								v-on:click="importPlaylist(false)"
 								href="#"
 								><i class="material-icons icon-with-button"
 									>publish</i
 								>Import</a
 							>
+							<a
+								class="button is-info"
+								v-on:click="importPlaylist(true)"
+								href="#"
+								><i class="material-icons icon-with-button"
+									>publish</i
+								>Import only music</a
+							>
 						</p>
 					</div>
 				</div>
@@ -283,7 +291,7 @@ export default {
 				});
 			}
 		},
-		importPlaylist() {
+		importPlaylist(musicOnly) {
 			new Toast({
 				content:
 					"Starting to import your playlist. This can take some time to do.",
@@ -293,6 +301,7 @@ export default {
 			this.socket.emit(
 				"queueSongs.addSetToQueue",
 				this.importQuery,
+				musicOnly,
 				res => {
 					return new Toast({ content: res.message, timeout: 4000 });
 				}