2
0
mirror of https://github.com/TeamNewPipe/NewPipeExtractor synced 2025-08-31 06:15:37 +00:00

Fix getUploadDate() for premiered videos with a given date

Detect publishDate and uploadDate
This commit is contained in:
TobiGr
2020-02-25 22:54:37 +01:00
parent d1b7461d0e
commit fc465c8bf7

View File

@@ -134,7 +134,13 @@ public class YoutubeStreamExtractor extends StreamExtractor {
}
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 {
@@ -147,7 +153,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
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) {}