|
20 | 20 | import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; |
21 | 21 | import org.schabi.newpipe.extractor.linkhandler.LinkHandler; |
22 | 22 | import org.schabi.newpipe.extractor.localization.DateWrapper; |
| 23 | +import org.schabi.newpipe.extractor.localization.Localization; |
23 | 24 | import org.schabi.newpipe.extractor.localization.TimeAgoParser; |
| 25 | +import org.schabi.newpipe.extractor.localization.TimeAgoPatternsManager; |
24 | 26 | import org.schabi.newpipe.extractor.services.youtube.ItagItem; |
25 | 27 | import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper; |
26 | 28 | import org.schabi.newpipe.extractor.stream.AudioStream; |
|
42 | 44 | import java.nio.charset.StandardCharsets; |
43 | 45 | import java.text.SimpleDateFormat; |
44 | 46 | import java.util.ArrayList; |
| 47 | +import java.util.Calendar; |
45 | 48 | import java.util.Collections; |
46 | 49 | import java.util.Date; |
47 | 50 | import java.util.HashMap; |
@@ -134,6 +137,15 @@ public String getTextualUploadDate() throws ParsingException { |
134 | 137 | //return playerResponse.getObject("microformat").getObject("playerMicroformatRenderer").getString("publishDate"); |
135 | 138 | } catch (Exception ignored) {} |
136 | 139 |
|
| 140 | + try { |
| 141 | + if (getVideoPrimaryInfoRenderer().getObject("dateText").getString("simpleText").startsWith("Premiered")) { |
| 142 | + String timeAgo = getVideoPrimaryInfoRenderer().getObject("dateText").getString("simpleText").substring(10); |
| 143 | + TimeAgoParser timeAgoParser = TimeAgoPatternsManager.getTimeAgoParserFor(Localization.fromLocalizationCode("en")); |
| 144 | + Calendar parsedTimeAgo = timeAgoParser.parse(timeAgo).date(); |
| 145 | + return new SimpleDateFormat("yyyy-MM-dd").format(parsedTimeAgo.getTime()); |
| 146 | + } |
| 147 | + } catch (Exception ignored) {} |
| 148 | + |
137 | 149 | try { |
138 | 150 | // TODO this parses English formatted dates only, we need a better approach to parse the textual date |
139 | 151 | Date d = new SimpleDateFormat("dd MMM yyyy", Locale.ENGLISH).parse( |
|
0 commit comments