|
18 | 18 | import org.schabi.newpipe.extractor.linkhandler.LinkHandler; |
19 | 19 | import org.schabi.newpipe.extractor.services.youtube.ItagItem; |
20 | 20 | import org.schabi.newpipe.extractor.stream.*; |
21 | | -import org.schabi.newpipe.extractor.utils.DonationLinkHelper; |
22 | 21 | import org.schabi.newpipe.extractor.utils.Parser; |
23 | 22 | import org.schabi.newpipe.extractor.utils.Utils; |
24 | 23 |
|
25 | 24 | import javax.annotation.Nonnull; |
26 | 25 | import javax.annotation.Nullable; |
27 | 26 | import java.io.IOException; |
| 27 | +import java.io.UnsupportedEncodingException; |
| 28 | +import java.net.MalformedURLException; |
| 29 | +import java.net.URL; |
28 | 30 | import java.util.*; |
29 | 31 |
|
30 | 32 | /* |
@@ -152,12 +154,24 @@ public String getThumbnailUrl() throws ParsingException { |
152 | 154 | public String getDescription() throws ParsingException { |
153 | 155 | assertPageFetched(); |
154 | 156 | try { |
155 | | - return doc.select("p[id=\"eow-description\"]").first().html(); |
| 157 | + return parseHtmlAndGetFullLinks(doc.select("p[id=\"eow-description\"]").first().html()); |
156 | 158 | } catch (Exception e) {//todo: add fallback method <-- there is no ... as long as i know |
157 | 159 | throw new ParsingException("Could not get the description", e); |
158 | 160 | } |
159 | 161 | } |
160 | 162 |
|
| 163 | + private String parseHtmlAndGetFullLinks(String descriptionHtml) |
| 164 | + throws MalformedURLException, UnsupportedEncodingException, ParsingException { |
| 165 | + final Document description = Jsoup.parse(descriptionHtml, getUrl()); |
| 166 | + for(Element a : description.select("a")) { |
| 167 | + final URL redirectLink = new URL( |
| 168 | + a.attr("abs:href")); |
| 169 | + final String link = Parser.compatParseMap(redirectLink.getQuery()).get("q"); |
| 170 | + a.text(link); |
| 171 | + } |
| 172 | + return description.select("body").first().html(); |
| 173 | + } |
| 174 | + |
161 | 175 | @Override |
162 | 176 | public int getAgeLimit() throws ParsingException { |
163 | 177 | assertPageFetched(); |
|
0 commit comments