File tree Expand file tree Collapse file tree
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -197,8 +197,13 @@ public static Calendar parseDateFrom(String textualUploadDate) throws ParsingExc
197197
198198 public static JsonObject getInitialData (String html ) throws ParsingException {
199199 try {
200- String initialData = Parser .matchGroup1 ("window\\ [\" ytInitialData\" \\ ]\\ s*=\\ s*(\\ {.*?\\ });" , html );
201- return JsonParser .object ().from (initialData );
200+ try {
201+ final String initialData = Parser .matchGroup1 ("window\\ [\" ytInitialData\" \\ ]\\ s*=\\ s*(\\ {.*?\\ });" , html );
202+ return JsonParser .object ().from (initialData );
203+ } catch (Parser .RegexException e ) {
204+ final String initialData = Parser .matchGroup1 ("var\\ s*ytInitialData\\ s*=\\ s*(\\ {.*?\\ });" , html );
205+ return JsonParser .object ().from (initialData );
206+ }
202207 } catch (JsonParserException | Parser .RegexException e ) {
203208 throw new ParsingException ("Could not get ytInitialData" , e );
204209 }
You can’t perform that action at this time.
0 commit comments