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