mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 00:50:32 +00:00
Adding cookies member to Downloader
This commit is contained in:
parent
b4f595eb75
commit
3391067cab
@ -35,6 +35,7 @@ import javax.net.ssl.HttpsURLConnection;
|
|||||||
public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
||||||
|
|
||||||
private static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0";
|
private static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0";
|
||||||
|
private static String mCookies = "";
|
||||||
|
|
||||||
private static Downloader instance = null;
|
private static Downloader instance = null;
|
||||||
|
|
||||||
@ -51,6 +52,14 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static synchronized void setCookies(String cookies) {
|
||||||
|
Downloader.mCookies = cookies;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized String getCookies() {
|
||||||
|
return Downloader.mCookies;
|
||||||
|
}
|
||||||
|
|
||||||
/**Download the text file at the supplied URL as in download(String),
|
/**Download the text file at the supplied URL as in download(String),
|
||||||
* but set the HTTP header field "Accept-Language" to the supplied string.
|
* but set the HTTP header field "Accept-Language" to the supplied string.
|
||||||
* @param siteUrl the URL of the text file to return the contents of
|
* @param siteUrl the URL of the text file to return the contents of
|
||||||
@ -89,6 +98,10 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
|||||||
con.setRequestMethod("GET");
|
con.setRequestMethod("GET");
|
||||||
con.setRequestProperty("User-Agent", USER_AGENT);
|
con.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
|
|
||||||
|
if (getCookies().length() > 0) {
|
||||||
|
con.setRequestProperty("Cookie", getCookies());
|
||||||
|
}
|
||||||
|
|
||||||
in = new BufferedReader(
|
in = new BufferedReader(
|
||||||
new InputStreamReader(con.getInputStream()));
|
new InputStreamReader(con.getInputStream()));
|
||||||
String inputLine;
|
String inputLine;
|
||||||
|
Loading…
Reference in New Issue
Block a user