kopia lustrzana https://github.com/TeamNewPipe/NewPipeExtractor
Prevent NPE on live streams and cache correctly
rodzic
ba2efde599
commit
ef6a53ebb3
|
@ -42,7 +42,7 @@ public class YoutubeStreamInfoItemLockupExtractor implements StreamInfoItemExtra
|
||||||
private final TimeAgoParser timeAgoParser;
|
private final TimeAgoParser timeAgoParser;
|
||||||
|
|
||||||
private String cachedName;
|
private String cachedName;
|
||||||
private String cachedTextualUploadDate;
|
private Optional<String> cachedTextualUploadDate;
|
||||||
|
|
||||||
private JsonArray cachedMetadataRows;
|
private JsonArray cachedMetadataRows;
|
||||||
|
|
||||||
|
@ -198,13 +198,13 @@ public class YoutubeStreamInfoItemLockupExtractor implements StreamInfoItemExtra
|
||||||
@Override
|
@Override
|
||||||
public String getTextualUploadDate() throws ParsingException {
|
public String getTextualUploadDate() throws ParsingException {
|
||||||
if (cachedTextualUploadDate != null) {
|
if (cachedTextualUploadDate != null) {
|
||||||
return cachedTextualUploadDate;
|
return cachedTextualUploadDate.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This might be null e.g. for live streams
|
||||||
this.cachedTextualUploadDate = metadataPart(1, 1)
|
this.cachedTextualUploadDate = metadataPart(1, 1)
|
||||||
.map(this::getTextContentFromMetadataPart)
|
.map(this::getTextContentFromMetadataPart);
|
||||||
.orElse(null);
|
return cachedTextualUploadDate.orElse(null);
|
||||||
return cachedTextualUploadDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -214,7 +214,12 @@ public class YoutubeStreamInfoItemLockupExtractor implements StreamInfoItemExtra
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return timeAgoParser.parse(getTextualUploadDate());
|
final String textualUploadDate = getTextualUploadDate();
|
||||||
|
// Prevent NPE when e.g. a live stream is shown
|
||||||
|
if (textualUploadDate == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return timeAgoParser.parse(textualUploadDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Ładowanie…
Reference in New Issue