kopia lustrzana https://github.com/TeamNewPipe/NewPipeExtractor
Apply code review suggestions
rodzic
e9dd84fe66
commit
c79afc0076
|
@ -174,16 +174,20 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public String getTextualUploadDate() throws ParsingException {
|
public String getTextualUploadDate() throws ParsingException {
|
||||||
final String dateStr = playerMicroFormatRenderer.getString("uploadDate",
|
String timestamp = playerMicroFormatRenderer.getString("uploadDate", "");
|
||||||
playerMicroFormatRenderer.getString("publishDate", ""));
|
if (timestamp.isEmpty()) {
|
||||||
if (!dateStr.isEmpty()) {
|
timestamp = playerMicroFormatRenderer.getString("publishDate", "");
|
||||||
return dateStr;
|
}
|
||||||
|
if (!timestamp.isEmpty()) {
|
||||||
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
final var liveDetails = playerMicroFormatRenderer.getObject("liveBroadcastDetails");
|
final var liveDetails = playerMicroFormatRenderer.getObject("liveBroadcastDetails");
|
||||||
final String timestamp = liveDetails.getString("endTimestamp", // an ended live stream
|
timestamp = liveDetails.getString("endTimestamp", ""); // an ended live stream
|
||||||
liveDetails.getString("startTimestamp", "")); // a running live stream
|
if (timestamp.isEmpty()) {
|
||||||
|
// a running live stream
|
||||||
|
timestamp = liveDetails.getString("startTimestamp", "");
|
||||||
|
}
|
||||||
if (!timestamp.isEmpty()) {
|
if (!timestamp.isEmpty()) {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
} else if (getStreamType() == StreamType.LIVE_STREAM) {
|
} else if (getStreamType() == StreamType.LIVE_STREAM) {
|
||||||
|
@ -229,7 +233,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
final var instant = date.atStartOfDay(ZoneId.systemDefault()).toInstant();
|
final var instant = date.atStartOfDay(ZoneId.systemDefault()).toInstant();
|
||||||
return new DateWrapper(instant, true);
|
return new DateWrapper(instant, true);
|
||||||
})
|
})
|
||||||
.orElseThrow(() -> new ParsingException("Could not parse upload date"));
|
.orElseThrow(() -> new ParsingException("Could not parse upload date \""
|
||||||
|
+ dateText + "\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<LocalDate> parseOptionalDate(final String date, final String pattern) {
|
private Optional<LocalDate> parseOptionalDate(final String date, final String pattern) {
|
||||||
|
|
Ładowanie…
Reference in New Issue