From 7cfdaf39a433122c075b12c7593f54831da98d28 Mon Sep 17 00:00:00 2001 From: Coffeemakr Date: Thu, 4 Jan 2018 18:42:30 +0100 Subject: [PATCH] Fix relative url in uploader URL --- .../youtube/YoutubeStreamInfoItemExtractor.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java index 9b00d8a36..3e9f51365 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java @@ -94,13 +94,23 @@ 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 public String getUploaderUrl() throws ParsingException { try { try { - return item.select("div[class=\"yt-lockup-byline\"]").first() + String url = item.select("div[class=\"yt-lockup-byline\"]").first() .select("a").first() .attr("href"); + return fixRelativeUrls(url); } catch (Exception e){} // try this if the first didn't work