Skip to content

Commit 254e34d

Browse files
authored
[v1-legacy] Handle youtube /live/ URLs. (#54)
* Handle youtube /live/ URLs. * Use substring method as Lavaplayer will trim extra characters. * consistent naming (LivePath -> Live)
1 parent 77da04d commit 254e34d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: main/src/main/java/com/sedmelluq/discord/lavaplayer/source/youtube/DefaultYoutubeLinkRouter.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public class DefaultYoutubeLinkRouter implements YoutubeLinkRouter {
2929
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + DOMAIN_REGEX + "/.*"), this::routeFromMainDomain),
3030
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + SHORT_DOMAIN_REGEX + "/.*"), this::routeFromShortDomain),
3131
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + DOMAIN_REGEX + "/embed/.*"), this::routeFromEmbed),
32-
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + DOMAIN_REGEX + "/shorts/.*"), this::routeFromShorts)
32+
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + DOMAIN_REGEX + "/shorts/.*"), this::routeFromShorts),
33+
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + DOMAIN_REGEX + "/live/.*"), this::routeFromLive)
3334
};
3435

3536
@Override
@@ -118,6 +119,11 @@ protected <T> T routeFromShorts(Routes<T> routes, String url) {
118119
return routeFromUrlWithVideoId(routes, urlInfo.path.substring(8), urlInfo);
119120
}
120121

122+
protected <T> T routeFromLive(Routes<T> routes, String url) {
123+
UrlInfo urlInfo = getUrlInfo(url, true);
124+
return routeFromUrlWithVideoId(routes, urlInfo.path.substring(6), urlInfo);
125+
}
126+
121127
private static UrlInfo getUrlInfo(String url, boolean retryValidPart) {
122128
try {
123129
if (!url.startsWith("http://") && !url.startsWith("https://")) {

0 commit comments

Comments
 (0)