Skip to content

Commit 981cb33

Browse files
committed
fix link parsing for yt internal links
blub
1 parent 389a87f commit 981cb33

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public String getDescription() throws ParsingException {
155155
assertPageFetched();
156156
try {
157157
return parseHtmlAndGetFullLinks(doc.select("p[id=\"eow-description\"]").first().html());
158-
} catch (Exception e) {//todo: add fallback method <-- there is no ... as long as i know
158+
} catch (Exception e) {
159159
throw new ParsingException("Could not get the description", e);
160160
}
161161
}
@@ -166,8 +166,14 @@ private String parseHtmlAndGetFullLinks(String descriptionHtml)
166166
for(Element a : description.select("a")) {
167167
final URL redirectLink = new URL(
168168
a.attr("abs:href"));
169-
final String link = Parser.compatParseMap(redirectLink.getQuery()).get("q");
170-
a.text(link);
169+
final String queryString = redirectLink.getQuery();
170+
if(queryString != null) {
171+
// if the query string is null we are not dealing with a redirect link,
172+
// so we don't need to override it.
173+
final String link =
174+
Parser.compatParseMap(queryString).get("q");
175+
a.text(link);
176+
}
171177
}
172178
return description.select("body").first().html();
173179
}

0 commit comments

Comments
 (0)