Fix YouTube parse error when only a date is present.

This commit is contained in:
Isira Seneviratne 2020-11-03 16:24:46 +05:30
parent 9cf9e7e980
commit 4fe28d7e3a
1 changed files with 7 additions and 1 deletions

View File

@ -21,7 +21,9 @@ import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeParseException;
import java.util.Collections;
import java.util.HashMap;
@ -184,7 +186,11 @@ public class YoutubeParsingHelper {
try {
return OffsetDateTime.parse(textualUploadDate);
} catch (DateTimeParseException e) {
throw new ParsingException("Could not parse date: \"" + textualUploadDate + "\"", e);
try {
return LocalDate.parse(textualUploadDate).atStartOfDay().atOffset(ZoneOffset.UTC);
} catch (DateTimeParseException e1) {
throw new ParsingException("Could not parse date: \"" + textualUploadDate + "\"", e1);
}
}
}