Skip to content

Commit 3aa7ff6

Browse files
committed
make ytdescription alter href instead of the text of links
1 parent e662c97 commit 3aa7ff6

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,15 @@ private String parseHtmlAndGetFullLinks(String descriptionHtml)
173173
final String link =
174174
Parser.compatParseMap(queryString).get("q");
175175

176-
// if link is null the a tag is a hashtag. They refer to the youtube search. We do not handle them.
177176
if(link != null) {
178-
a.text(link);
177+
// if link is null the a tag is a hashtag.
178+
// They refer to the youtube search. We do not handle them.
179+
a.attr("abs:href", link);
180+
181+
} else if(redirectLink.toString().contains("watch?v=")) {
182+
// Another posibility is that this link is pointing to another video
183+
// we need to put the redirectLink in here explicitly in order to add the domain part to the link.
184+
a.attr("abs:href", redirectLink.toString());
179185
}
180186
}
181187
}

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void testGetInvalidTimeStamp() throws ParsingException {
5858
}
5959

6060
@Test
61-
public void testGetValidTimeStamp() throws IOException, ExtractionException {
61+
public void testGetValidTimeStamp() throws ExtractionException {
6262
StreamExtractor extractor = YouTube.getStreamExtractor("https://youtu.be/FmG385_uUys?t=174");
6363
assertEquals(extractor.getTimeStamp() + "", "174");
6464
}
@@ -77,8 +77,7 @@ public void testGetDescription() throws ParsingException {
7777
@Test
7878
public void testGetFullLinksInDescriptlion() throws ParsingException {
7979
assertTrue(extractor.getDescription().contains("http://smarturl.it/SubscribeAdele?IQid=yt"));
80-
assertFalse(extractor.getDescription().contains("http://smarturl.it/SubscribeAdele?IQi..."));
81-
System.out.println(extractor.getDescription());
80+
assertTrue(extractor.getDescription().contains("http://smarturl.it/SubscribeAdele?IQi..."));
8281
}
8382

8483
@Test

0 commit comments

Comments
 (0)