Use 'abs:' prefix

This commit is contained in:
Coffeemakr 2018-01-15 12:33:09 +01:00
parent 7cfdaf39a4
commit 978a33fae2
No known key found for this signature in database
GPG Key ID: 3F35676D8FF6E743
3 changed files with 4 additions and 14 deletions

View File

@ -265,7 +265,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
@Override @Override
public String getUploaderUrl() throws ParsingException { public String getUploaderUrl() throws ParsingException {
return getUploaderLink().attr("href"); return getUploaderLink().attr("abs:href");
} }
@Override @Override

View File

@ -94,23 +94,13 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
} }
} }
private static String fixRelativeUrls(String url) {
if(url == null || url.isEmpty()) return url;
if(url.startsWith("/")) {
return "https://youtube.com" + url;
} else {
return url;
}
}
@Override @Override
public String getUploaderUrl() throws ParsingException { public String getUploaderUrl() throws ParsingException {
try { try {
try { try {
String url = item.select("div[class=\"yt-lockup-byline\"]").first() return item.select("div[class=\"yt-lockup-byline\"]").first()
.select("a").first() .select("a").first()
.attr("href"); .attr("abs:href");
return fixRelativeUrls(url);
} catch (Exception e){} } catch (Exception e){}
// try this if the first didn't work // try this if the first didn't work

View File

@ -110,7 +110,7 @@ public class YoutubeTrendingExtractor extends KioskExtractor {
@Override @Override
public String getUploaderUrl() throws ParsingException { public String getUploaderUrl() throws ParsingException {
try { try {
String link = getUploaderLink().attr("href"); String link = getUploaderLink().attr("abs:href");
if (link.isEmpty()) { if (link.isEmpty()) {
throw new IllegalArgumentException("is empty"); throw new IllegalArgumentException("is empty");
} }