From 17793af2f1dfd56f596d348fb5677f655baf8892 Mon Sep 17 00:00:00 2001 From: Donald Shan Date: Sat, 10 Dec 2022 17:04:38 -0800 Subject: Initial Commit --- utility/URLChecker.java | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 utility/URLChecker.java (limited to 'utility/URLChecker.java') diff --git a/utility/URLChecker.java b/utility/URLChecker.java deleted file mode 100644 index ffea53b..0000000 --- a/utility/URLChecker.java +++ /dev/null @@ -1,31 +0,0 @@ -package utility; - -public class URLChecker { - public boolean isURL(String term){ - return term.matches("^(http|https)://.*"); - } - public String getURLType(String url) { - if (url.matches("^((?:https?:)?\\/\\/)?((?:www|m)\\.)?((?:youtube(-nocookie)?\\.com|youtu.be))(\\/(?:[\\w\\-]+\\?v=|embed\\/|v\\/)?)([\\w\\-]+)(\\S+)?$")) { - return "yt"; //Youtube - } else if (url.matches("^(https?:\\/\\/)?(www.)?(m\\.)?soundcloud\\.com\\/[\\w\\-\\.]+(\\/)+[\\w\\-\\.]+/?$")) { - return "snd"; - } else if (url.matches("^(?:https?:\\/\\/)?(?:www\\.|go\\.)?twitch\\.tv\\/([a-z0-9_]+)($|\\?)")) { - return "twitch"; - } else if (url.split("\\?si=")[0].matches("^(https?://)?(www.)?(open.)?spotify.com/(user/[a-zA-Z0-9]+|artist/[a-zA-Z0-9]+|album/[a-zA-Z0-9]+|track/[a-zA-Z0-9]+|playlist/[a-zA-Z0-9]+)$")) { - return url.split("\\?si=")[0].matches("^(https?://)?(www.)?(open.)?spotify.com/playlist/[a-zA-Z0-9]+$") ? "spotify-playlist" : "spotify"; - } - return "unknown"; - - } - - public String getSpotifyTrackID(String uri){ - String[] uriParts = uri.split("\\?si="); - return uriParts[0].replaceAll("https://open.spotify.com/track/",""); - - } - public String getSpotifyPlaylistID(String url){ - String[] uriParts = url.split("\\?si="); - return uriParts[0].replaceAll("https://open.spotify.com/playlist/",""); - - } -} -- cgit v1.2.3