Skip to content

Commit

Permalink
Fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiGr committed Jun 8, 2021
1 parent d8672a4 commit e831c0e
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,10 @@ private Map<String, ItagItem> getItags(final String streamingDataKey,
@Override
public List<Frameset> getFrames() throws ExtractionException {
try {
if (!playerResponse.has("storyboards")) {
// this might be the case when the video is very short
return Collections.emptyList();
}
final JsonObject storyboards = playerResponse.getObject("storyboards");
final JsonObject storyboardsRenderer;
if (storyboards.has("playerLiveStoryboardSpecRenderer")) {
Expand Down Expand Up @@ -1081,10 +1085,13 @@ public List<Frameset> getFrames() throws ExtractionException {
final int totalCount = Integer.parseInt(parts[2]);
final int framesPerPageX = Integer.parseInt(parts[3]);
final int framesPerPageY = Integer.parseInt(parts[4]);
final String baseUrl = url.replace("$L", String.valueOf(i - 1)).replace("$N", parts[6]) + "&sigh=" + parts[7];
final String baseUrl = url
.replace("$L", String.valueOf(i - 1))
.replace("$N", parts[6]) + "&sigh=" + parts[7];
final List<String> urls;
if (baseUrl.contains("$M")) {
final int totalPages = (int) Math.ceil(totalCount / (double) (framesPerPageX * framesPerPageY));
final int totalPages =
(int) Math.ceil(totalCount / (double) (framesPerPageX * framesPerPageY));
urls = new ArrayList<>(totalPages);
for (int j = 0; j < totalPages; j++) {
urls.add(baseUrl.replace("$M", String.valueOf(j)));
Expand Down

0 comments on commit e831c0e

Please sign in to comment.