Skip to content

Commit

Permalink
Merge pull request #112, add missing onError calls to callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias123567 authored Apr 8, 2023
1 parent e5e91a6 commit e8a9726
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/main/java/com/github/kiulian/downloader/parser/ParserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ private VideoInfo parseVideoWeb(String videoId, YoutubeCallback<VideoInfo> callb
JSONObject playerResponse = args.getJSONObject("player_response");

if (!playerResponse.containsKey("streamingData") && !playerResponse.containsKey("videoDetails")) {
throw new YoutubeException.BadPageException("streamingData and videoDetails not found");
YoutubeException e = new YoutubeException.BadPageException("streamingData and videoDetails not found");
if (callback != null) {
callback.onError(e);
}
throw e;
}

VideoDetails videoDetails = parseVideoDetails(videoId, playerResponse);
Expand All @@ -158,8 +162,15 @@ private VideoInfo parseVideoWeb(String videoId, YoutubeCallback<VideoInfo> callb
}
JSONObject context = playerConfig.getJSONObject("args").getJSONObject("player_response").getJSONObject("responseContext");
String clientVersion = extractor.extractClientVersionFromContext(context);
List<Format> formats = parseFormats(playerResponse, jsUrl, clientVersion);

List<Format> formats;
try {
formats = parseFormats(playerResponse, jsUrl, clientVersion);
} catch (YoutubeException e) {
if (callback != null) {
callback.onError(e);
}
throw e;
}
List<SubtitlesInfo> subtitlesInfo = parseCaptions(playerResponse);
return new VideoInfo(videoDetails, formats, subtitlesInfo);
} else {
Expand Down

0 comments on commit e8a9726

Please sign in to comment.