| 
					
				 | 
			
			
				@@ -467,7 +467,6 @@ class _YouTubeModule extends CoreClass { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * Gets the id of the channel from a username 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {object} payload - object that contains the payload 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {string} payload.username - the username of the YouTube channel 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @returns {Promise} - returns promise (reject, resolve) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -898,7 +897,6 @@ class _YouTubeModule extends CoreClass { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * Returns the channel ID from a provided URL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {object} payload - object that contains the payload 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {boolean} payload.disableSearch - whether to allow searching for custom url/username 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {string} payload.url - the url of the YouTube channel 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -925,14 +923,15 @@ class _YouTubeModule extends CoreClass { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						if (channelId) return next(true, channelId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						if (!channelUsername) return next(null, true, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						YouTubeModule.runJob("GET_CHANNEL_ID_FROM_USERNAME", { username: channelUsername, }, this) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							.then(({ channelId }) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								next(null, null, channelId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							.catch(next); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						if (channelId) next(true, channelId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						else if (!channelUsername) next(null, true, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							YouTubeModule.runJob("GET_CHANNEL_ID_FROM_USERNAME", { username: channelUsername }, this) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								.then(({ channelId }) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									next(null, null, channelId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								.catch(next); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					(getUsernameFromCustomUrl, channelId, next) => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -940,6 +939,7 @@ class _YouTubeModule extends CoreClass { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						if (disableSearch) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							return next( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								// eslint-disable-next-line 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 								"You are not allowed to look up this type of YouTube channel URL. Please provide a channel URL with the channel ID in it." 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						const payload = {}; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -952,7 +952,7 @@ class _YouTubeModule extends CoreClass { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 								next(null, channelId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							.catch(err => next(err)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				(err, channelId) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log(111, err, channelId); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1041,14 +1041,16 @@ class _YouTubeModule extends CoreClass { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						async.whilst( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								if (payload.max > 0 && songs.length > payload.max) return next(null, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								YouTubeModule.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									"INFO", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									`Getting channel progress for job (${this.toString()}): ${ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-										songs.length 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									} songs gotten so far. Is there a next page: ${nextPageToken !== undefined}.` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								next(null, nextPageToken !== undefined); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								if (payload.max > 0 && songs.length > payload.max) next(null, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									YouTubeModule.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										"INFO", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										`Getting channel progress for job (${this.toString()}): ${ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+											songs.length 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+										} songs gotten so far. Is there a next page: ${nextPageToken !== undefined}.` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									next(null, nextPageToken !== undefined); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 								// Add 250ms delay between each job request 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1653,44 +1655,41 @@ class _YouTubeModule extends CoreClass { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			stats.failedVideoIds = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			stats.successfulVideoIds = existingYoutubeIds; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (!replaceExisting) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if (!createMissing) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				return { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					...stats, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					videos: existingVideos, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					videos: existingVideos 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if (identifiers.length === existingVideos.length || youtubeIds.length === 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				return { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					...stats, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					videos: existingVideos 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			const missingYoutubeIds = youtubeIds.filter(youtubeId => existingYoutubeIds.indexOf(youtubeId) === -1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (missingYoutubeIds.length === 0) return { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				...stats, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				videos: existingVideos, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (missingYoutubeIds.length === 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				return { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					...stats, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					videos: existingVideos 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			const newVideos = await getVideosFromYoutubeIds(missingYoutubeIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			await YouTubeModule.runJob("CREATE_VIDEOS", { youtubeVideos: newVideos }, this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			stats.successful += newVideos.length; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			stats.successfulVideoIds = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				...stats.successfulVideoIds, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				...newVideos.map(newVideo => newVideo.youtubeId), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			stats.successfulVideoIds = [...stats.successfulVideoIds, ...newVideos.map(newVideo => newVideo.youtubeId)]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			// TODO actually handle failed videos I guess? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			return { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				...stats, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				videos: existingVideos.concat(newVideos), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				videos: existingVideos.concat(newVideos) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		const newVideos = await getVideosFromYoutubeIds(existingYoutubeIds); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1706,8 +1705,8 @@ class _YouTubeModule extends CoreClass { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			...stats, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			videos: newVideos, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			videos: newVideos 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	/** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1985,7 +1984,7 @@ class _YouTubeModule extends CoreClass { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 								{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 									url: payload.url, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 									musicOnly: payload.musicOnly, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									max: payload.max, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									max: payload.max 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 								}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 								this 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1999,22 +1998,16 @@ class _YouTubeModule extends CoreClass { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					async youtubeIds => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						if (youtubeIds.length === 0) return { videos: [] }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						const { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							videos, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							successful, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							failed, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							alreadyInDatabase, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							successfulVideoIds, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							failedVideoIds, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						} = await YouTubeModule.runJob( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							"GET_VIDEOS", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								identifiers: youtubeIds, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								createMissing: true, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								returnStats: true, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							this 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						const { videos, successful, failed, alreadyInDatabase, successfulVideoIds, failedVideoIds } = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							await YouTubeModule.runJob( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								"GET_VIDEOS", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									identifiers: youtubeIds, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									createMissing: true, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									returnStats: true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								this 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						return { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							videos, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2022,7 +2015,7 @@ class _YouTubeModule extends CoreClass { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							failed, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							alreadyInDatabase, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							successfulVideoIds, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							failedVideoIds, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							failedVideoIds 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				], 
			 |