mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-25 01:20:34 +00:00
YTStreamExtractor: implement getAgeRestriction
This commit is contained in:
parent
3f0947fa5b
commit
2edfcb78fe
@ -30,6 +30,10 @@ public class YoutubeStreamExtractorRestrictedTest extends AndroidTestCase {
|
|||||||
extractor.getTimeStamp() == 174);
|
extractor.getTimeStamp() == 174);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGetAgeLimit() throws ParsingException {
|
||||||
|
assertTrue(extractor.getAgeLimit() == 18);
|
||||||
|
}
|
||||||
|
|
||||||
public void testGetTitle() throws ParsingException {
|
public void testGetTitle() throws ParsingException {
|
||||||
assertTrue(!extractor.getTitle().isEmpty());
|
assertTrue(!extractor.getTitle().isEmpty());
|
||||||
}
|
}
|
||||||
|
@ -529,11 +529,17 @@ public class YoutubeStreamExtractor implements StreamExtractor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAgeLimit() throws ParsingException {
|
public int getAgeLimit() throws ParsingException {
|
||||||
// Not yet implemented.
|
if (!isAgeRestricted) {
|
||||||
// Also you need to be logged in to see age restricted videos on youtube,
|
|
||||||
// therefore NP is not able to receive such videos.
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
return Integer.valueOf(doc.head()
|
||||||
|
.getElementsByAttributeValue("property", "og:restrictions:age")
|
||||||
|
.attr("content").replace("+", ""));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ParsingException("Could not get age restriction");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAverageRating() throws ParsingException {
|
public String getAverageRating() throws ParsingException {
|
||||||
|
Loading…
Reference in New Issue
Block a user