Class Downloader
java.lang.Object
org.schabi.newpipe.extractor.downloader.Downloader
A base for downloader implementations that NewPipe will use
to download needed resources during extraction.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ResponseDo a request using the specifiedRequestobject.Do a GET request to get the resource that the url is pointing to.
This method callsget(String, Map, Localization)with the default preferred localization.Do a GET request with the specified headers.Do a GET request with the specified headers.
It will set theAccept-Languageheader to the language of the localization parameter.get(String url, Localization localization) Do a GET request to get the resource that the url is pointing to.
It will set theAccept-Languageheader to the language of the localization parameter.Do a HEAD request.Do a HEAD request with the specified headers.Do a POST request with the specified headers, sending the data array.Do a POST request with the specified headers, sending the data array.postWithContentType(String url, Map<String, List<String>> headers, byte[] dataToSend, String contentType) Convenient method to send a POST request using the specified value of theContent-Typeheader.postWithContentType(String url, Map<String, List<String>> headers, byte[] dataToSend, Localization localization, String contentType) Convenient method to send a POST request using the specified value of theContent-Typeheader with a givenLocalization.Convenient method to send a POST request the JSON mime type as the value of theContent-Typeheader.postWithContentTypeJson(String url, Map<String, List<String>> headers, byte[] dataToSend, Localization localization) Convenient method to send a POST request the JSON mime type as the value of theContent-Typeheader with a givenLocalization.toString()
-
Constructor Details
-
Downloader
public Downloader()
-
-
Method Details
-
get
Do a GET request to get the resource that the url is pointing to.
This method callsget(String, Map, Localization)with the default preferred localization. It should only be used when the resource that will be fetched won't be affected by the localization.- Parameters:
url- the URL that is pointing to the wanted resource- Returns:
- the result of the GET request
- Throws:
IOExceptionReCaptchaException
-
get
Do a GET request to get the resource that the url is pointing to.
It will set theAccept-Languageheader to the language of the localization parameter.- Parameters:
url- the URL that is pointing to the wanted resourcelocalization- the source of the value of theAccept-Languageheader- Returns:
- the result of the GET request
- Throws:
IOExceptionReCaptchaException
-
get
public Response get(String url, @Nullable Map<String, List<String>> headers) throws IOException, ReCaptchaExceptionDo a GET request with the specified headers.- Parameters:
url- the URL that is pointing to the wanted resourceheaders- a list of headers that will be used in the request. Any default headers should be overridden by these.- Returns:
- the result of the GET request
- Throws:
IOExceptionReCaptchaException
-
get
public Response get(String url, @Nullable Map<String, List<String>> headers, Localization localization) throws IOException, ReCaptchaExceptionDo a GET request with the specified headers.
It will set theAccept-Languageheader to the language of the localization parameter.- Parameters:
url- the URL that is pointing to the wanted resourceheaders- a list of headers that will be used in the request. Any default headers should be overridden by these.localization- the source of the value of theAccept-Languageheader- Returns:
- the result of the GET request
- Throws:
IOExceptionReCaptchaException
-
head
Do a HEAD request.- Parameters:
url- the URL that is pointing to the wanted resource- Returns:
- the result of the HEAD request
- Throws:
IOExceptionReCaptchaException
-
head
public Response head(String url, @Nullable Map<String, List<String>> headers) throws IOException, ReCaptchaExceptionDo a HEAD request with the specified headers.- Parameters:
url- the URL that is pointing to the wanted resourceheaders- a list of headers that will be used in the request. Any default headers should be overridden by these.- Returns:
- the result of the HEAD request
- Throws:
IOExceptionReCaptchaException
-
post
public Response post(String url, @Nullable Map<String, List<String>> headers, @Nullable byte[] dataToSend) throws IOException, ReCaptchaExceptionDo a POST request with the specified headers, sending the data array.- Parameters:
url- the URL that is pointing to the wanted resourceheaders- a list of headers that will be used in the request. Any default headers should be overridden by these.dataToSend- byte array that will be sent when doing the request.- Returns:
- the result of the POST request
- Throws:
IOExceptionReCaptchaException
-
post
public Response post(String url, @Nullable Map<String, List<String>> headers, @Nullable byte[] dataToSend, Localization localization) throws IOException, ReCaptchaExceptionDo a POST request with the specified headers, sending the data array.
It will set theAccept-Languageheader to the language of the localization parameter.- Parameters:
url- the URL that is pointing to the wanted resourceheaders- a list of headers that will be used in the request. Any default headers should be overridden by these.dataToSend- byte array that will be sent when doing the request.localization- the source of the value of theAccept-Languageheader- Returns:
- the result of the POST request
- Throws:
IOExceptionReCaptchaException
-
postWithContentType
public Response postWithContentType(String url, @Nullable Map<String, List<String>> headers, @Nullable byte[] dataToSend, Localization localization, String contentType) throws IOException, ReCaptchaExceptionConvenient method to send a POST request using the specified value of theContent-Typeheader with a givenLocalization.- Parameters:
url- the URL that is pointing to the wanted resourceheaders- a list of headers that will be used in the request. Any default headers should be overridden by these.dataToSend- byte array that will be sent when doing the request.localization- the source of the value of theAccept-LanguageheadercontentType- the mime type of the body sent, which will be set as the value of theContent-Typeheader- Returns:
- the result of the POST request
- Throws:
IOExceptionReCaptchaException- See Also:
-
postWithContentType
public Response postWithContentType(String url, @Nullable Map<String, List<String>> headers, @Nullable byte[] dataToSend, String contentType) throws IOException, ReCaptchaExceptionConvenient method to send a POST request using the specified value of theContent-Typeheader.- Parameters:
url- the URL that is pointing to the wanted resourceheaders- a list of headers that will be used in the request. Any default headers should be overridden by these.dataToSend- byte array that will be sent when doing the request.contentType- the mime type of the body sent, which will be set as the value of theContent-Typeheader- Returns:
- the result of the POST request
- Throws:
IOExceptionReCaptchaException- See Also:
-
postWithContentTypeJson
public Response postWithContentTypeJson(String url, @Nullable Map<String, List<String>> headers, @Nullable byte[] dataToSend, Localization localization) throws IOException, ReCaptchaExceptionConvenient method to send a POST request the JSON mime type as the value of theContent-Typeheader with a givenLocalization.- Parameters:
url- the URL that is pointing to the wanted resourceheaders- a list of headers that will be used in the request. Any default headers should be overridden by these.dataToSend- byte array that will be sent when doing the request.localization- the source of the value of theAccept-Languageheader- Returns:
- the result of the POST request
- Throws:
IOExceptionReCaptchaException- See Also:
-
postWithContentTypeJson
public Response postWithContentTypeJson(String url, @Nullable Map<String, List<String>> headers, @Nullable byte[] dataToSend) throws IOException, ReCaptchaExceptionConvenient method to send a POST request the JSON mime type as the value of theContent-Typeheader.- Parameters:
url- the URL that is pointing to the wanted resourceheaders- a list of headers that will be used in the request. Any default headers should be overridden by these.dataToSend- byte array that will be sent when doing the request.- Returns:
- the result of the POST request
- Throws:
IOExceptionReCaptchaException- See Also:
-
execute
Do a request using the specifiedRequestobject.- Returns:
- the result of the request
- Throws:
IOExceptionReCaptchaException
-
toString
-