Skip to content

Commit

Permalink
use subpath instead of folder
Browse files Browse the repository at this point in the history
  • Loading branch information
B0pol committed Feb 13, 2021
1 parent 8db40db commit 90b9098
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class YoutubeStreamLinkHandlerFactory extends LinkHandlerFactory {

private static final Pattern YOUTUBE_VIDEO_ID_REGEX_PATTERN = Pattern.compile("^([a-zA-Z0-9_-]{11})");
private static final YoutubeStreamLinkHandlerFactory instance = new YoutubeStreamLinkHandlerFactory();
private static final List<String> folders = Arrays.asList("embed/", "shorts/", "watch/", "v/", "w/");
private static final List<String> subpaths = Arrays.asList("embed/", "shorts/", "watch/", "v/", "w/");

private YoutubeStreamLinkHandlerFactory() {
}
Expand Down Expand Up @@ -153,7 +153,7 @@ public String getId(String urlString) throws ParsingException, IllegalArgumentEx
return assertIsId(viewQueryValue);
}

String maybeId = getIdFromFoldersInPath(path);
String maybeId = getIdFromSubpathsInPath(path);
if (maybeId != null) return maybeId;

String viewQueryValue = Utils.getQueryValue(url, "v");
Expand Down Expand Up @@ -195,7 +195,7 @@ public String getId(String urlString) throws ParsingException, IllegalArgumentEx
return assertIsId(viewQueryValue);
}
}
String maybeId = getIdFromFoldersInPath(path);
String maybeId = getIdFromSubpathsInPath(path);
if (maybeId != null) return maybeId;

String viewQueryValue = Utils.getQueryValue(url, "v");
Expand All @@ -222,10 +222,10 @@ public boolean onAcceptUrl(final String url) throws FoundAdException {
}
}

private String getIdFromFoldersInPath(String path) throws ParsingException {
for (final String folder : folders) {
if (path.startsWith(folder)) {
String id = path.substring(folder.length());
private String getIdFromSubpathsInPath(String path) throws ParsingException {
for (final String subpath : subpaths) {
if (path.startsWith(subpath)) {
String id = path.substring(subpath.length());
return assertIsId(id);
}
}
Expand Down

0 comments on commit 90b9098

Please sign in to comment.