Skip to content

Commit

Permalink
Fix getUploadDate() for premiered videos with a given date
Browse files Browse the repository at this point in the history
Detect publishDate and uploadDate
  • Loading branch information
TobiGr committed Feb 25, 2020
1 parent d1b7461 commit fc465c8
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ public String getTextualUploadDate() throws ParsingException {
}

try {
// return playerResponse.getObject("microformat").getObject("playerMicroformatRenderer").getString("publishDate");
JsonObject micro = playerResponse.getObject("microformat").getObject("playerMicroformatRenderer");
if (micro.getString("uploadDate") != null && !micro.getString("uploadDate").isEmpty()) {
return micro.getString("uploadDate");
}
if (micro.getString("publishDate") != null && !micro.getString("publishDate").isEmpty()) {
return micro.getString("publishDate");
}
} catch (Exception ignored) {}

try {
Expand All @@ -147,7 +153,7 @@ public String getTextualUploadDate() throws ParsingException {
return new SimpleDateFormat("yyyy-MM-dd").format(parsedTime.getTime());
} catch (Exception ignored) {}

try { // Premiered Premiered Feb 21, 2020
try { // Premiered Feb 21, 2020
Date d = new SimpleDateFormat("MMM dd, YYYY", Locale.ENGLISH).parse(time);
return new SimpleDateFormat("yyyy-MM-dd").format(d.getTime());
} catch (Exception ignored) {}
Expand Down

0 comments on commit fc465c8

Please sign in to comment.