Update extractor version and add head request to downloader
This commit is contained in:
parent
37c02e4dd8
commit
912086506c
2 changed files with 20 additions and 4 deletions
|
|
@ -57,7 +57,7 @@ dependencies {
|
||||||
exclude module: 'support-annotations'
|
exclude module: 'support-annotations'
|
||||||
})
|
})
|
||||||
|
|
||||||
implementation 'com.github.teamnewpipe:NewPipeExtractor:06f2144e4daa10'
|
implementation 'com.github.teamnewpipe:NewPipeExtractor:v0.17.4'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
testImplementation 'org.mockito:mockito-core:2.23.0'
|
testImplementation 'org.mockito:mockito-core:2.23.0'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DownloadResponse(body.string(), response.headers().toMultimap());
|
return new DownloadResponse(response.code(), body.string(), response.headers().toMultimap());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -275,6 +275,22 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DownloadResponse(body.string(), response.headers().toMultimap());
|
return new DownloadResponse(response.code(), body.string(), response.headers().toMultimap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DownloadResponse head(String siteUrl) throws IOException, ReCaptchaException {
|
||||||
|
final Request request = new Request.Builder()
|
||||||
|
.head().url(siteUrl)
|
||||||
|
.addHeader("User-Agent", USER_AGENT)
|
||||||
|
.build();
|
||||||
|
final Response response = client.newCall(request).execute();
|
||||||
|
|
||||||
|
if (response.code() == 429) {
|
||||||
|
throw new ReCaptchaException("reCaptcha Challenge requested", siteUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DownloadResponse(response.code(), null, response.headers().toMultimap());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue