Implement getUploadDate() in YouTubeStreamInfoItemExtractor
This commit is contained in:
parent
26ea3dceb6
commit
f39603f6ef
|
@ -164,11 +164,9 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
|
||||
@Override
|
||||
public long getSubscriberCount() throws ParsingException {
|
||||
|
||||
final JsonObject subscriberInfo = initialData.getObject("header").getObject("c4TabbedHeaderRenderer").getObject("subscriberCountText");
|
||||
if (subscriberInfo != null) {
|
||||
try {
|
||||
|
||||
return Utils.mixedNumberWordToLong(subscriberInfo.getArray("runs").getObject(0).getString("text"));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ParsingException("Could not get subscriber count", e);
|
||||
|
|
|
@ -512,7 +512,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public StreamInfoItemsCollector getRelatedStreams() throws ExtractionException {
|
||||
assertPageFetched();
|
||||
|
@ -678,7 +677,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
private EmbeddedInfo getEmbeddedInfo() throws ParsingException, ReCaptchaException {
|
||||
try {
|
||||
|
|
|
@ -158,12 +158,26 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
|
|||
@Override
|
||||
public String getTextualUploadDate() {
|
||||
// TODO: Get upload date in case of a videoRenderer (not available in case of a compactVideoRenderer)
|
||||
return null;
|
||||
try {
|
||||
String s =videoInfo.getObject("publishedTimeText").getString("simpleText");
|
||||
return s;
|
||||
} catch (Exception e) {
|
||||
// upload date is not always available, e.g. in playlists
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public DateWrapper getUploadDate() {
|
||||
public DateWrapper getUploadDate() throws ParsingException {
|
||||
String textualUploadDate = getTextualUploadDate();
|
||||
if (timeAgoParser != null && textualUploadDate != null && !textualUploadDate.isEmpty()) {
|
||||
try {
|
||||
return timeAgoParser.parse(textualUploadDate);
|
||||
} catch (ParsingException e) {
|
||||
throw new ParsingException("Could not get upload date", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue