From 21bcb33caa3d1b306984669a1123f8e8fa057f73 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Fri, 14 Aug 2020 14:47:49 +0200 Subject: [PATCH] :sparkles: Add method to check if is soundcloud link --- package.json | 1 + src/Util.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/package.json b/package.json index 40e60a9..e61ab92 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "merge-options": "^2.0.0", "moment": "^2.27.0", "node-fetch": "^2.6.0", + "soundcloud-scraper": "^1.0.1", "spotify-url-info": "^1.3.1", "ytpl": "^0.2.4", "ytsr": "^0.1.19" diff --git a/src/Util.js b/src/Util.js index 97b33d0..dbc9090 100644 --- a/src/Util.js +++ b/src/Util.js @@ -1,4 +1,5 @@ const ytpl = require('ytpl') +const scraper = require('soundcloud-scraper') const Discord = require('discord.js') const youtubeVideoRegex = (/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/) @@ -13,6 +14,10 @@ module.exports = class Util { return channel.members.filter((member) => !member.user.bot).size === 0 } + static isSoundcloudLink (query) { + return scraper.validateURL(query) + } + static isSpotifyLink (query) { return spotifySongRegex.test(query) }