Skip to content

Commit

Permalink
Merge pull request #20 from daktak/development
Browse files Browse the repository at this point in the history
Update user agent
  • Loading branch information
daktak authored Oct 19, 2017
2 parents 9e3b5a4 + 491270a commit 4b8d3ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/src/main/java/org/afhdownloader/Download.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public String parseUrl(String url) {
Log.d(LOGTAG, "Fetch: "+url);
ArrayList<String> urls = new ArrayList<String>();
try {

Document doc = Jsoup.connect(url).timeout(10*1000).get();
String userAgent = getString(R.string.user_agent);
Document doc = Jsoup.connect(url).timeout(10*1000).followRedirects(true).userAgent(userAgent).get();
SharedPreferences mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String selector = mySharedPreferences.getString("prefSelector",getString(R.string.selector_val)).trim();
//String selector = getString(R.string.selector_val);
Expand Down Expand Up @@ -135,7 +135,8 @@ public String getMD5(String url) {
String md5S ="";
try {
Log.d(LOGTAG, "md5 url: "+url);
Document doc = Jsoup.connect(url).timeout(10 * 1000).get();
String userAgent = getString(R.string.user_agent);
Document doc = Jsoup.connect(url).timeout(10 * 1000).followRedirects(true).userAgent(userAgent).get();
/*
SharedPreferences mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String select_md5 = mySharedPreferences.getString("prefSelector",getString(R.string.md5_sel_val)).trim();
Expand All @@ -157,6 +158,7 @@ public ArrayList<String> getDLUrl(String url){
SharedPreferences mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
String data = mySharedPreferences.getString("prefMirrorData",getString(R.string.mirrordata_val)) + url;
String mUrl = mySharedPreferences.getString("prefMirrorURL",getString(R.string.mirrorurl_val));
String userAgent = getString(R.string.user_agent);
Log.d(LOGTAG, "Download parse: " +url);

ArrayList<String> urls = new ArrayList<String>();
Expand All @@ -165,7 +167,7 @@ public ArrayList<String> getDLUrl(String url){
HttpURLConnection httpcon = (HttpURLConnection) ((new URL(mUrl).openConnection()));
httpcon.setDoOutput(true);
httpcon.setRequestMethod("POST");
httpcon.setRequestProperty("User-Agent","Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0");
httpcon.setRequestProperty("User-Agent",userAgent);
httpcon.setRequestProperty("X-MOD-SBB-CTYPE","xhr");
httpcon.connect();

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
<string name="md5calc_ext" translatable="false">.calc.md5</string>
<string name="md5_ext" translatable="false">.md5</string>
<string name="head_selector" translatable="false">h1</string>
<string name="user_agent" translatable="false">Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0</string>
</resources>

0 comments on commit 4b8d3ac

Please sign in to comment.