Skip to content

Commit

Permalink
Handle youtube /live/ URLs.
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Dec 25, 2023
1 parent 53eb716 commit f55fb79
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public class DefaultYoutubeLinkRouter implements YoutubeLinkRouter {
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + DOMAIN_REGEX + "/.*"), this::routeFromMainDomain),
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + SHORT_DOMAIN_REGEX + "/.*"), this::routeFromShortDomain),
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + DOMAIN_REGEX + "/embed/.*"), this::routeFromEmbed),
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + DOMAIN_REGEX + "/shorts/.*"), this::routeFromShorts)
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + DOMAIN_REGEX + "/shorts/.*"), this::routeFromShorts),
new Extractor(Pattern.compile("^" + PROTOCOL_REGEX + DOMAIN_REGEX + "/live/.*"), this::routeFromShortPath)
};

@Override
Expand Down Expand Up @@ -118,6 +119,12 @@ protected <T> T routeFromShorts(Routes<T> routes, String url) {
return routeFromUrlWithVideoId(routes, urlInfo.path.substring(8), urlInfo);
}

protected <T> T routeFromShortPath(Routes<T> routes, String url) {
UrlInfo urlInfo = getUrlInfo(url, true);
String[] pathParts = urlInfo.path.split("/");
return routeFromUrlWithVideoId(routes, pathParts[pathParts.length - 1], urlInfo);
}

private static UrlInfo getUrlInfo(String url, boolean retryValidPart) {
try {
if (!url.startsWith("http://") && !url.startsWith("https://")) {
Expand Down

0 comments on commit f55fb79

Please sign in to comment.