Skip to content

Commit 393e811

Browse files
committed
Wrap LocalDateTime.parse in try-catch
1 parent 3c404e5 commit 393e811

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemLockupExtractor.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.time.OffsetDateTime;
2222
import java.time.ZoneOffset;
2323
import java.time.format.DateTimeFormatter;
24+
import java.time.format.DateTimeParseException;
2425
import java.util.List;
2526
import java.util.Optional;
2627
import java.util.stream.Collectors;
@@ -289,9 +290,13 @@ public DateWrapper getUploadDate() throws ParsingException {
289290
throw new ParsingException("Could not get upload date from premiere");
290291
}
291292

292-
// As we request a UTC offset of 0 minutes, we get the UTC data
293-
return new DateWrapper(OffsetDateTime.of(
294-
LocalDateTime.parse(premiereDate, PREMIERES_DATE_FORMATTER), ZoneOffset.UTC));
293+
try {
294+
// As we request a UTC offset of 0 minutes, we get the UTC data
295+
return new DateWrapper(OffsetDateTime.of(LocalDateTime.parse(
296+
premiereDate, PREMIERES_DATE_FORMATTER), ZoneOffset.UTC));
297+
} catch (final DateTimeParseException e) {
298+
throw new ParsingException("Could not parse premiere upload date", e);
299+
}
295300
}
296301

297302
return timeAgoParser.parse(textualUploadDate);

0 commit comments

Comments
 (0)