Add MP3 direct link to allowed sources
This commit is contained in:
1 parent
fa93bf6af4
commit
fe70bba689
1 file changed
+7
-1
@@ -20,6 +20,7 @@ public class SourceFinder {
|
||||
Vimeo,
|
||||
YTSearch,
|
||||
Udio,
|
||||
DirectLinkMp3,
|
||||
Nothing
|
||||
|
||||
}
|
||||
@@ -28,6 +29,7 @@ public class SourceFinder {
|
||||
private static final Pattern youtubeMusicPattern = Pattern.compile("^(?:https?://)?(?:www\\.)?music\\.(?:youtube\\.com|youtu\\.be)/.*?(?:embed|e|v|watch.*?v=)?/?([-_a-zA-Z0-9]{10,})?(?:&?index=\\d+)?(?>(?:playlist\\?|&)?list=([^#\\\\&?]{12,}))?", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern soundcloudPattern = Pattern.compile("^(?:https?://)?(?:www\\.)?(?:m\\.)?soundcloud\\.com/([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)(?:\\\\?.*|)$", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern udioPattern = Pattern.compile("^https://www.udio.com/songs/[0-9A-Za-z]+$", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern mp3Pattern = Pattern.compile("^https?://(?:.*)(?:.mp3)$", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
|
||||
public static AudioSourceType getSource(String url) {
|
||||
@@ -35,6 +37,7 @@ public class SourceFinder {
|
||||
Matcher youtubeMusicMatcher = youtubeMusicPattern.matcher(url);
|
||||
Matcher soundcloudMatcher = soundcloudPattern.matcher(url);
|
||||
Matcher udioMatcher = udioPattern.matcher(url);
|
||||
Matcher mp3Matcher = mp3Pattern.matcher(url);
|
||||
|
||||
if (youtubeMatcher.find())
|
||||
return AudioSourceType.Youtube;
|
||||
@@ -48,6 +51,9 @@ public class SourceFinder {
|
||||
if (udioMatcher.find())
|
||||
return AudioSourceType.Udio;
|
||||
|
||||
if (mp3Matcher.find())
|
||||
return AudioSourceType.DirectLinkMp3;
|
||||
|
||||
if (!(url.startsWith("http://") || url.startsWith("https://")))
|
||||
return AudioSourceType.YTSearch;
|
||||
|
||||
@@ -58,7 +64,7 @@ public class SourceFinder {
|
||||
String identifier;
|
||||
|
||||
identifier = switch (getSource(url)) {
|
||||
case Youtube, YTMusic, Soundcloud, Udio -> url;
|
||||
case Youtube, YTMusic, Soundcloud, Udio, DirectLinkMp3 -> url;
|
||||
case YTSearch -> "ytsearch:" + url;
|
||||
default -> null;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user