Skip to content

Commit

Permalink
Merge pull request #415 from wb9688/fix-ytinitialdata
Browse files Browse the repository at this point in the history
Fix parsing new ytInitialData
  • Loading branch information
TobiGr authored Oct 16, 2020
2 parents 1a9bc8c + be9a6f9 commit f82eda9
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,13 @@ public static Calendar parseDateFrom(String textualUploadDate) throws ParsingExc

public static JsonObject getInitialData(String html) throws ParsingException {
try {
String initialData = Parser.matchGroup1("window\\[\"ytInitialData\"\\]\\s*=\\s*(\\{.*?\\});", html);
return JsonParser.object().from(initialData);
try {
final String initialData = Parser.matchGroup1("window\\[\"ytInitialData\"\\]\\s*=\\s*(\\{.*?\\});", html);
return JsonParser.object().from(initialData);
} catch (Parser.RegexException e) {
final String initialData = Parser.matchGroup1("var\\s*ytInitialData\\s*=\\s*(\\{.*?\\});", html);
return JsonParser.object().from(initialData);
}
} catch (JsonParserException | Parser.RegexException e) {
throw new ParsingException("Could not get ytInitialData", e);
}
Expand Down

0 comments on commit f82eda9

Please sign in to comment.