Fix fallback method is not tried on exception
in YoutubeChannelInfoItem.getUrl()
This commit is contained in:
parent
6d504e0883
commit
94e7f0d3ab
1 changed files with 13 additions and 7 deletions
|
@ -56,6 +56,7 @@ public class YoutubeChannelInfoItemExtractor implements ChannelInfoItemExtractor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl() throws ParsingException {
|
public String getUrl() throws ParsingException {
|
||||||
|
try {
|
||||||
String buttonTrackingUrl = el.select("button[class*=\"yt-uix-button\"]").first()
|
String buttonTrackingUrl = el.select("button[class*=\"yt-uix-button\"]").first()
|
||||||
.attr("abs:data-href");
|
.attr("abs:data-href");
|
||||||
|
|
||||||
|
@ -64,11 +65,16 @@ public class YoutubeChannelInfoItemExtractor implements ChannelInfoItemExtractor
|
||||||
|
|
||||||
if (match.matches()) {
|
if (match.matches()) {
|
||||||
return YoutubeChannelExtractor.CHANNEL_URL_BASE + match.group(1);
|
return YoutubeChannelExtractor.CHANNEL_URL_BASE + match.group(1);
|
||||||
} else {
|
}
|
||||||
|
} catch(Throwable ignored) {}
|
||||||
|
|
||||||
|
try {
|
||||||
// fallback method just in case youtube changes things; it should never run and tests will fail
|
// fallback method just in case youtube changes things; it should never run and tests will fail
|
||||||
// provides an url with "/user/NAME", that is inconsistent with stream and channel extractor
|
// provides an url with "/user/NAME", that is inconsistent with stream and channel extractor
|
||||||
return el.select("a[class*=\"yt-uix-tile-link\"]").first()
|
return el.select("a[class*=\"yt-uix-tile-link\"]").first()
|
||||||
.attr("abs:href");
|
.attr("abs:href");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
throw new ParsingException("Could not get channel url", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue