make ytdescription alter href instead of the text of links
This commit is contained in:
parent
e662c97433
commit
3aa7ff6d0e
|
@ -173,9 +173,15 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
final String link =
|
final String link =
|
||||||
Parser.compatParseMap(queryString).get("q");
|
Parser.compatParseMap(queryString).get("q");
|
||||||
|
|
||||||
// if link is null the a tag is a hashtag. They refer to the youtube search. We do not handle them.
|
|
||||||
if(link != null) {
|
if(link != null) {
|
||||||
a.text(link);
|
// if link is null the a tag is a hashtag.
|
||||||
|
// They refer to the youtube search. We do not handle them.
|
||||||
|
a.attr("abs:href", link);
|
||||||
|
|
||||||
|
} else if(redirectLink.toString().contains("watch?v=")) {
|
||||||
|
// Another posibility is that this link is pointing to another video
|
||||||
|
// we need to put the redirectLink in here explicitly in order to add the domain part to the link.
|
||||||
|
a.attr("abs:href", redirectLink.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
public void testGetValidTimeStamp() throws ExtractionException {
|
||||||
StreamExtractor extractor = YouTube.getStreamExtractor("https://youtu.be/FmG385_uUys?t=174");
|
StreamExtractor extractor = YouTube.getStreamExtractor("https://youtu.be/FmG385_uUys?t=174");
|
||||||
assertEquals(extractor.getTimeStamp() + "", "174");
|
assertEquals(extractor.getTimeStamp() + "", "174");
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetFullLinksInDescriptlion() throws ParsingException {
|
public void testGetFullLinksInDescriptlion() throws ParsingException {
|
||||||
assertTrue(extractor.getDescription().contains("http://smarturl.it/SubscribeAdele?IQid=yt"));
|
assertTrue(extractor.getDescription().contains("http://smarturl.it/SubscribeAdele?IQid=yt"));
|
||||||
assertFalse(extractor.getDescription().contains("http://smarturl.it/SubscribeAdele?IQi..."));
|
assertTrue(extractor.getDescription().contains("http://smarturl.it/SubscribeAdele?IQi..."));
|
||||||
System.out.println(extractor.getDescription());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue