From b4f595eb75cf63e634ac273271ad5b2a9cc7a061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Mauduit?= Date: Wed, 7 Dec 2016 22:09:24 +0100 Subject: [PATCH 01/19] Make Downloader class a Singleton --- app/src/main/java/org/schabi/newpipe/App.java | 2 +- .../main/java/org/schabi/newpipe/Downloader.java | 15 +++++++++++++++ .../org/schabi/newpipe/report/ErrorActivity.java | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 7e93969bc..f9b95c457 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -62,7 +62,7 @@ public class App extends Application { } //init NewPipe - NewPipe.init(new Downloader()); + NewPipe.init(Downloader.getInstance()); // Initialize image loader ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build(); diff --git a/app/src/main/java/org/schabi/newpipe/Downloader.java b/app/src/main/java/org/schabi/newpipe/Downloader.java index 04098a4d7..1cc4fcdf2 100644 --- a/app/src/main/java/org/schabi/newpipe/Downloader.java +++ b/app/src/main/java/org/schabi/newpipe/Downloader.java @@ -36,6 +36,21 @@ 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 Downloader instance = null; + + private Downloader() {} + + public static Downloader getInstance() { + if(instance == null) { + synchronized (Downloader.class) { + if (instance == null) { + instance = new Downloader(); + } + } + } + return instance; + } + /**Download the text file at the supplied URL as in download(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 diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index 49cfe0471..85151efb3 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -473,7 +473,7 @@ public class ErrorActivity extends AppCompatActivity { public void run() { String ipRange = "none"; try { - Downloader dl = new Downloader(); + Downloader dl = Downloader.getInstance(); String ip = dl.download("https://ifcfg.me/ip"); ipRange = Parser.matchGroup1("([0-9]*\\.[0-9]*\\.)[0-9]*\\.[0-9]*", ip) From 3391067cab10b9fedda5cb0a73728cee258cc206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Mauduit?= Date: Wed, 7 Dec 2016 22:16:28 +0100 Subject: [PATCH 02/19] Adding cookies member to Downloader --- .../main/java/org/schabi/newpipe/Downloader.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/Downloader.java b/app/src/main/java/org/schabi/newpipe/Downloader.java index 1cc4fcdf2..3c701fde3 100644 --- a/app/src/main/java/org/schabi/newpipe/Downloader.java +++ b/app/src/main/java/org/schabi/newpipe/Downloader.java @@ -35,6 +35,7 @@ import javax.net.ssl.HttpsURLConnection; 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 String mCookies = ""; private static Downloader instance = null; @@ -51,6 +52,14 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { 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), * 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 @@ -89,6 +98,10 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { con.setRequestMethod("GET"); con.setRequestProperty("User-Agent", USER_AGENT); + if (getCookies().length() > 0) { + con.setRequestProperty("Cookie", getCookies()); + } + in = new BufferedReader( new InputStreamReader(con.getInputStream())); String inputLine; From 54eb353d0def4d8268ccc94533064f67beda9b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Mauduit?= Date: Wed, 7 Dec 2016 18:34:39 +0100 Subject: [PATCH 03/19] Add ReCaptcha Activity * ReCaptchas are implemented using a simple WebView with Javascript enable. * All HTTP responses inside the WebView are catched (using onPageFinished()) ** When Google reCatcha cookies are detected, register cookies to the Downloader class and Return to MainActivity --- app/src/main/AndroidManifest.xml | 3 + .../org/schabi/newpipe/ReCaptchaActivity.java | 138 ++++++++++++++++++ .../main/res/layout/activity_recaptcha.xml | 10 ++ app/src/main/res/values/strings.xml | 2 + 4 files changed, 153 insertions(+) create mode 100644 app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java create mode 100644 app/src/main/res/layout/activity_recaptcha.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 447d01ddc..5ce399d91 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -153,6 +153,9 @@ android:label="@string/title_activity_channel" android:theme="@style/AppTheme.NoActionBar" /> + \ No newline at end of file diff --git a/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java b/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java new file mode 100644 index 000000000..f503bfcff --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java @@ -0,0 +1,138 @@ +package org.schabi.newpipe; + +import android.app.Activity; +import android.content.Intent; +import android.os.Build; +import android.os.Bundle; +import android.support.v4.app.NavUtils; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.view.MenuItem; +import android.webkit.CookieManager; +import android.webkit.ValueCallback; +import android.webkit.WebSettings; +import android.webkit.WebView; +import android.webkit.WebViewClient; + +/** + * Created by beneth on 06.12.16. + * + * Copyright (C) Christian Schabesberger 2015 + * ReCaptchaActivity.java is part of NewPipe. + * + * NewPipe is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * NewPipe is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NewPipe. If not, see . + */ +public class ReCaptchaActivity extends AppCompatActivity { + public static final String TAG = ReCaptchaActivity.class.toString(); + public static final String YT_URL = "https://www.youtube.com"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_recaptcha); + + ActionBar actionBar = getSupportActionBar(); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setTitle(R.string.reCaptcha_title); + actionBar.setDisplayShowTitleEnabled(true); + + WebView myWebView = (WebView) findViewById(R.id.reCaptchaWebView); + + // Enable Javascript + WebSettings webSettings = myWebView.getSettings(); + webSettings.setJavaScriptEnabled(true); + + ReCaptchaWebViewClient webClient = new ReCaptchaWebViewClient(this); + myWebView.setWebViewClient(webClient); + + // Cleaning cache, history and cookies from webView + myWebView.clearCache(true); + myWebView.clearHistory(); + android.webkit.CookieManager cookieManager = CookieManager.getInstance(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + cookieManager.removeAllCookies(new ValueCallback() { + @Override + public void onReceiveValue(Boolean aBoolean) {} + }); + } else { + cookieManager.removeAllCookie(); + } + + myWebView.loadUrl(YT_URL); + } + + private class ReCaptchaWebViewClient extends WebViewClient { + private Activity context; + private String mCookies; + + ReCaptchaWebViewClient(Activity ctx) { + context = ctx; + } + + @Override + public void onPageFinished(WebView view, String url) { + String cookies = CookieManager.getInstance().getCookie(url); + + // find cookies : s_gl & goojf and Add cookies to Downloader + if (find_access_cookies(cookies)) { + // Give cookies to Downloader class + Downloader.setCookies(mCookies); + + // Closing activity and return to parent. + Intent intent = new Intent(context, org.schabi.newpipe.MainActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + NavUtils.navigateUpTo(context, intent); + } + } + + private boolean find_access_cookies(String cookies) { + boolean ret = false; + String c_s_gl = ""; + String c_goojf = ""; + + String[] parts = cookies.split("; "); + for (String part : parts) { + if (part.trim().startsWith("s_gl")) { + c_s_gl = part.trim(); + } + if (part.trim().startsWith("goojf")) { + c_goojf = part.trim(); + } + } + if (c_s_gl.length() > 0 && c_goojf.length() > 0) { + ret = true; + //mCookies = c_s_gl + "; " + c_goojf; + // Youtube seems to also need the other cookies: + mCookies = cookies; + } + + return ret; + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + switch (id) { + case android.R.id.home: { + Intent intent = new Intent(this, org.schabi.newpipe.MainActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + NavUtils.navigateUpTo(this, intent); + return true; + } + default: + return false; + } + } +} diff --git a/app/src/main/res/layout/activity_recaptcha.xml b/app/src/main/res/layout/activity_recaptcha.xml new file mode 100644 index 000000000..0a3b03010 --- /dev/null +++ b/app/src/main/res/layout/activity_recaptcha.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dfd247dd7..208cac70d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -269,6 +269,8 @@ "when a user tries to pick up one of cards.\n\n" Settings + reCaptcha + reCaptcha Challenge From a5ac528c02c15879ac354e091d3d99c64a5fdaa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Mauduit?= Date: Wed, 7 Dec 2016 19:22:27 +0100 Subject: [PATCH 04/19] Add reCaptchaException --- .../java/org/schabi/newpipe/Downloader.java | 18 ++++++++++--- .../newpipe/extractor/DashMpdParser.java | 5 +++- .../schabi/newpipe/extractor/Downloader.java | 8 +++--- .../exceptions/reCaptchaException.java | 27 +++++++++++++++++++ .../youtube/YoutubeStreamExtractor.java | 5 +++- 5 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/extractor/exceptions/reCaptchaException.java diff --git a/app/src/main/java/org/schabi/newpipe/Downloader.java b/app/src/main/java/org/schabi/newpipe/Downloader.java index 3c701fde3..748d6bd4d 100644 --- a/app/src/main/java/org/schabi/newpipe/Downloader.java +++ b/app/src/main/java/org/schabi/newpipe/Downloader.java @@ -1,5 +1,7 @@ package org.schabi.newpipe; +import org.schabi.newpipe.extractor.exceptions.reCaptchaException; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -65,7 +67,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { * @param siteUrl the URL of the text file to return the contents of * @param language the language (usually a 2-character code) to set as the preferred language * @return the contents of the specified text file*/ - public String download(String siteUrl, String language) throws IOException { + public String download(String siteUrl, String language) throws IOException, reCaptchaException { Map requestProperties = new HashMap<>(); requestProperties.put("Accept-Language", language); return download(siteUrl, requestProperties); @@ -78,7 +80,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { * @param customProperties set request header properties * @return the contents of the specified text file * @throws IOException*/ - public String download(String siteUrl, Map customProperties) throws IOException { + public String download(String siteUrl, Map customProperties) throws IOException, reCaptchaException { URL url = new URL(siteUrl); HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); Iterator it = customProperties.entrySet().iterator(); @@ -90,7 +92,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { } /**Common functionality between download(String url) and download(String url, String language)*/ - private static String dl(HttpsURLConnection con) throws IOException { + private static String dl(HttpsURLConnection con) throws IOException, reCaptchaException { StringBuilder response = new StringBuilder(); BufferedReader in = null; @@ -113,6 +115,14 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { throw new IOException("unknown host or no network", uhe); //Toast.makeText(getActivity(), uhe.getMessage(), Toast.LENGTH_LONG).show(); } catch(Exception e) { + /* + * HTTP 429 == Too Many Request + * Receive from Youtube.com = ReCaptcha challenge request + * See : https://github.com/rg3/youtube-dl/issues/5138 + */ + if (con.getResponseCode() == 429) { + throw new reCaptchaException("reCaptcha Challenge requested"); + } throw new IOException(e); } finally { if(in != null) { @@ -127,7 +137,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { * Primarily intended for downloading web pages. * @param siteUrl the URL of the text file to download * @return the contents of the specified text file*/ - public String download(String siteUrl) throws IOException { + public String download(String siteUrl) throws IOException, reCaptchaException { URL url = new URL(siteUrl); HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); //HttpsURLConnection con = NetCipher.getHttpsURLConnection(url); diff --git a/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java b/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java index db26e3871..7dcbc16a8 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java @@ -3,6 +3,7 @@ package org.schabi.newpipe.extractor; import android.util.Xml; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.exceptions.reCaptchaException; import org.schabi.newpipe.extractor.stream_info.AudioStream; import org.xmlpull.v1.XmlPullParser; @@ -43,13 +44,15 @@ public class DashMpdParser { } public static List getAudioStreams(String dashManifestUrl) - throws DashMpdParsingException { + throws DashMpdParsingException, reCaptchaException { String dashDoc; Downloader downloader = NewPipe.getDownloader(); try { dashDoc = downloader.download(dashManifestUrl); } catch(IOException ioe) { throw new DashMpdParsingException("Could not get dash mpd: " + dashManifestUrl, ioe); + } catch (reCaptchaException e) { + throw new reCaptchaException("reCaptcha Challenge needed"); } Vector audioStreams = new Vector<>(); try { diff --git a/app/src/main/java/org/schabi/newpipe/extractor/Downloader.java b/app/src/main/java/org/schabi/newpipe/extractor/Downloader.java index 14475dba7..f25375113 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/Downloader.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/Downloader.java @@ -1,5 +1,7 @@ package org.schabi.newpipe.extractor; +import org.schabi.newpipe.extractor.exceptions.reCaptchaException; + import java.io.IOException; import java.util.Map; @@ -31,7 +33,7 @@ public interface Downloader { * @param language the language (usually a 2-character code) to set as the preferred language * @return the contents of the specified text file * @throws IOException*/ - String download(String siteUrl, String language) throws IOException; + String download(String siteUrl, String language) throws IOException, reCaptchaException; /**Download the text file at the supplied URL as in download(String), * but set the HTTP header field "Accept-Language" to the supplied string. @@ -39,12 +41,12 @@ public interface Downloader { * @param customProperties set request header properties * @return the contents of the specified text file * @throws IOException*/ - String download(String siteUrl, Map customProperties) throws IOException; + String download(String siteUrl, Map customProperties) throws IOException, reCaptchaException; /**Download (via HTTP) the text file located at the supplied URL, and return its contents. * Primarily intended for downloading web pages. * @param siteUrl the URL of the text file to download * @return the contents of the specified text file * @throws IOException*/ - String download(String siteUrl) throws IOException; + String download(String siteUrl) throws IOException, reCaptchaException; } diff --git a/app/src/main/java/org/schabi/newpipe/extractor/exceptions/reCaptchaException.java b/app/src/main/java/org/schabi/newpipe/extractor/exceptions/reCaptchaException.java new file mode 100644 index 000000000..a9107f15e --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/extractor/exceptions/reCaptchaException.java @@ -0,0 +1,27 @@ +package org.schabi.newpipe.extractor.exceptions; + +/** + * Created by beneth on 07.12.16. + * + * Copyright (C) Christian Schabesberger 2016 + * reCaptchaException.java is part of NewPipe. + * + * NewPipe is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * NewPipe is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NewPipe. If not, see . + */ + +public class reCaptchaException extends ExtractionException { + public reCaptchaException(String message) { + super(message); + } +} diff --git a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java index e1cbdd1a6..aa07bf96f 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java @@ -11,6 +11,7 @@ import org.mozilla.javascript.ScriptableObject; import org.schabi.newpipe.extractor.AbstractStreamInfo; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.exceptions.reCaptchaException; import org.schabi.newpipe.extractor.stream_info.AudioStream; import org.schabi.newpipe.extractor.Downloader; import org.schabi.newpipe.extractor.NewPipe; @@ -280,7 +281,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { } } - private String getPlayerUrlFromRestrictedVideo(String pageUrl) throws ParsingException { + private String getPlayerUrlFromRestrictedVideo(String pageUrl) throws ParsingException, reCaptchaException { try { Downloader downloader = NewPipe.getDownloader(); String playerUrl = ""; @@ -302,6 +303,8 @@ public class YoutubeStreamExtractor extends StreamExtractor { } catch (IOException e) { throw new ParsingException( "Could load decryption code form restricted video for the Youtube service.", e); + } catch (reCaptchaException e) { + throw new reCaptchaException("reCaptcha Challenge requested"); } } From 53796043c3dcd0b5be475080a9bb3814dba2d865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Mauduit?= Date: Wed, 7 Dec 2016 22:19:43 +0100 Subject: [PATCH 05/19] Start reCaptchaActivity when reCaptcha is requested and fix Typo * Fix typo setSearchWorkerResultListner to setSearchWorkerResultListener --- .../SearchInfoItemFragment.java | 12 +++++++++- .../newpipe/search_fragment/SearchWorker.java | 23 +++++++++++++------ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/search_fragment/SearchInfoItemFragment.java b/app/src/main/java/org/schabi/newpipe/search_fragment/SearchInfoItemFragment.java index 782f7a78b..e710bbbd9 100644 --- a/app/src/main/java/org/schabi/newpipe/search_fragment/SearchInfoItemFragment.java +++ b/app/src/main/java/org/schabi/newpipe/search_fragment/SearchInfoItemFragment.java @@ -18,6 +18,7 @@ import android.view.inputmethod.InputMethodManager; import android.widget.ProgressBar; import android.widget.Toast; +import org.schabi.newpipe.ReCaptchaActivity; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.search.SearchResult; import org.schabi.newpipe.info_list.InfoItemBuilder; @@ -149,7 +150,7 @@ public class SearchInfoItemFragment extends Fragment { } SearchWorker sw = SearchWorker.getInstance(); - sw.setSearchWorkerResultListner(new SearchWorker.SearchWorkerResultListner() { + sw.setSearchWorkerResultListener(new SearchWorker.SearchWorkerResultListener() { @Override public void onResult(SearchResult result) { infoListAdapter.addStreamItemList(result.resultList); @@ -174,6 +175,15 @@ public class SearchInfoItemFragment extends Fragment { isLoading = false; loadingIndicator.setVisibility(View.GONE); } + + @Override + public void onReCaptchaChallenge() { + Toast.makeText(getActivity(), "ReCaptcha Challenge requested", + Toast.LENGTH_LONG).show(); + // Starting ReCaptcha Challenge Activity + Intent i = new Intent(getActivity(), ReCaptchaActivity.class); + getActivity().startActivity(i); + } }); } diff --git a/app/src/main/java/org/schabi/newpipe/search_fragment/SearchWorker.java b/app/src/main/java/org/schabi/newpipe/search_fragment/SearchWorker.java index b6be1e259..7ce0d30c5 100644 --- a/app/src/main/java/org/schabi/newpipe/search_fragment/SearchWorker.java +++ b/app/src/main/java/org/schabi/newpipe/search_fragment/SearchWorker.java @@ -8,6 +8,7 @@ import android.util.Log; import android.view.View; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.exceptions.reCaptchaException; import org.schabi.newpipe.extractor.search.SearchEngine; import org.schabi.newpipe.extractor.search.SearchResult; import org.schabi.newpipe.report.ErrorActivity; @@ -40,10 +41,11 @@ import java.io.IOException; public class SearchWorker { private static final String TAG = SearchWorker.class.toString(); - public interface SearchWorkerResultListner { + public interface SearchWorkerResultListener { void onResult(SearchResult result); void onNothingFound(final int stringResource); void onError(String message); + void onReCaptchaChallenge(); } private class ResultRunnable implements Runnable { @@ -56,7 +58,7 @@ public class SearchWorker { @Override public void run() { if(this.requestId == SearchWorker.this.requestId) { - searchWorkerResultListner.onResult(result); + searchWorkerResultListener.onResult(result); } } } @@ -121,11 +123,18 @@ public class SearchWorker { } // hard errors: + } catch (reCaptchaException e) { + h.post(new Runnable() { + @Override + public void run() { + searchWorkerResultListener.onReCaptchaChallenge(); + } + }); } catch(IOException e) { h.post(new Runnable() { @Override public void run() { - searchWorkerResultListner.onNothingFound(R.string.network_error); + searchWorkerResultListener.onNothingFound(R.string.network_error); } }); e.printStackTrace(); @@ -133,7 +142,7 @@ public class SearchWorker { h.post(new Runnable() { @Override public void run() { - searchWorkerResultListner.onError(e.getMessage()); + searchWorkerResultListener.onError(e.getMessage()); } }); } catch(ExtractionException e) { @@ -155,7 +164,7 @@ public class SearchWorker { } private static SearchWorker searchWorker = null; - private SearchWorkerResultListner searchWorkerResultListner = null; + private SearchWorkerResultListener searchWorkerResultListener = null; private SearchRunnable runnable = null; private int requestId = 0; //prevents running requests that have already ben expired @@ -163,8 +172,8 @@ public class SearchWorker { return searchWorker == null ? (searchWorker = new SearchWorker()) : searchWorker; } - public void setSearchWorkerResultListner(SearchWorkerResultListner listener) { - searchWorkerResultListner = listener; + public void setSearchWorkerResultListener(SearchWorkerResultListener listener) { + searchWorkerResultListener = listener; } private SearchWorker() { From 5cc1bbc4bb500d2b764be523cd57d5a4327134fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Mauduit?= Date: Wed, 7 Dec 2016 22:11:39 +0100 Subject: [PATCH 06/19] Add missing Override decorator --- app/src/main/java/org/schabi/newpipe/MainActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 5d4729e90..bfeb74287 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -46,6 +46,7 @@ public class MainActivity extends AppCompatActivity { .findFragmentById(R.id.search_fragment); } + @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); From 05189dadbf128d040059540a68607fd61a7b489e Mon Sep 17 00:00:00 2001 From: Coffeemakr Date: Mon, 19 Dec 2016 13:32:03 +0100 Subject: [PATCH 07/19] Fix banner extaction --- .../extractor/services/youtube/YoutubeChannelExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java index 7f2a9ecdd..62e63ab1b 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java @@ -136,7 +136,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor { if(!isAjaxPage) { Element el = doc.select("div[id=\"gh-banner\"]").first().select("style").first(); String cssContent = el.html(); - String url = "https:" + Parser.matchGroup1("url\\((.*)\\)", cssContent); + String url = "https:" + Parser.matchGroup1("url\\(([^)]+)\\)", cssContent); if (url.contains("s.ytimg.com")) { bannerUrl = null; } else { From 83837bde111e490f0640bc260a10947de7323f35 Mon Sep 17 00:00:00 2001 From: Coffeemakr Date: Mon, 19 Dec 2016 19:28:05 +0100 Subject: [PATCH 08/19] Google begins with page 1 so we add 1 to our page starting with 0 --- .../newpipe/extractor/services/youtube/YoutubeSearchEngine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java index 3eb8ffb14..ab815d9a1 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java @@ -53,7 +53,7 @@ public class YoutubeSearchEngine extends SearchEngine { String url = "https://www.youtube.com/results" + "?search_query=" + URLEncoder.encode(query, CHARSET_UTF_8) - + "&page=" + Integer.toString(page) + + "&page=" + Integer.toString(page + 1) + "&filters=" + "video"; String site; From cb1fe5f017513e72aa2a890a47b320822d69664f Mon Sep 17 00:00:00 2001 From: Coffeemakr Date: Mon, 19 Dec 2016 19:36:24 +0100 Subject: [PATCH 09/19] Try to fix travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d66b06423..d9ce7a7ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ android: - build-tools-23.0.3 # The SDK version used to compile NewPipe - - android-24 + - android-25 # Additional components - extra-android-support From f4aabdd9b85286e3cfe095ab00640c8a367fe7c3 Mon Sep 17 00:00:00 2001 From: Coffeemakr Date: Mon, 19 Dec 2016 19:40:28 +0100 Subject: [PATCH 10/19] Accept SDK Licenses --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index d9ce7a7ee..52483ec2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,3 +33,7 @@ before_script: - adb shell input keyevent 82 & script: ./gradlew --info build connectedCheck + +licenses: + - 'android-sdk-license-.+' + From dd3251c08d2f7e114d7f2524dd089e5a5155e1ea Mon Sep 17 00:00:00 2001 From: ksyko Date: Wed, 21 Dec 2016 20:38:51 +0530 Subject: [PATCH 11/19] Fixes spelling --- app/src/main/res/values/colors.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 269034168..941e1b741 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -13,7 +13,7 @@ #FFFFFF - #AA000000 + #AA000000 #EEFFFFFF #66000000 #323232 @@ -34,4 +34,4 @@ #616161 - \ No newline at end of file + From 820e6067198763ffb6a1aeedc0350b3bbc9f9566 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Wed, 21 Dec 2016 21:00:05 +0100 Subject: [PATCH 12/19] fix duration_background name --- app/src/main/res/layout/video_item.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/video_item.xml b/app/src/main/res/layout/video_item.xml index d98bc92ac..90ac3ef83 100644 --- a/app/src/main/res/layout/video_item.xml +++ b/app/src/main/res/layout/video_item.xml @@ -48,7 +48,7 @@ android:paddingLeft="@dimen/video_item_search_duration_horizontal_padding" android:textAppearance="?android:attr/textAppearanceSmall" android:textSize="@dimen/video_item_search_duration_text_size" - android:background="@color/duration_dackground_color" + android:background="@color/duration_background_color" android:textColor="@color/duration_text_color"/> From 79a9497e65e4c80f1ed6f9f4ba69189a0c62eb51 Mon Sep 17 00:00:00 2001 From: ngoisaosang Date: Thu, 22 Dec 2016 17:40:01 +0700 Subject: [PATCH 13/19] Fix travis build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 52483ec2a..851dbe9b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ android: # Additional components - extra-android-support - extra-android-m2repository + - extra-android-m2repository # Emulators - sys-img-armeabi-v7a-android-21 From 25d0e3973647f4cf53b1c8f8230cd8209f26e042 Mon Sep 17 00:00:00 2001 From: ngoisaosang Date: Thu, 22 Dec 2016 22:45:42 +0700 Subject: [PATCH 14/19] Update gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ef7ae5ac8..f46d6535c 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' + classpath 'com.android.tools.build:gradle:2.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From b8b22d4d913f52bedb8099f1649bd4104e7deb3d Mon Sep 17 00:00:00 2001 From: ngoisaosang Date: Fri, 23 Dec 2016 13:47:20 +0700 Subject: [PATCH 15/19] Fix travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 851dbe9b0..b997d6a0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ android: # Additional components - extra-android-support - extra-android-m2repository - - extra-android-m2repository + - extra-google-m2repository # Emulators - sys-img-armeabi-v7a-android-21 From f61d779108d1864827b65648f9ce3c242be025da Mon Sep 17 00:00:00 2001 From: ngoisaosang Date: Sat, 24 Dec 2016 07:25:27 +0700 Subject: [PATCH 16/19] Try to fix travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b997d6a0e..32629b1cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,5 +36,5 @@ before_script: script: ./gradlew --info build connectedCheck licenses: - - 'android-sdk-license-.+' + - '.+' From 937a387f4e97a5ce7df0d69f3d5be6cb0b2ce218 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 24 Dec 2016 15:19:40 +0100 Subject: [PATCH 17/19] rename reCaptchaException to ReCaptchaException --- app/src/main/java/org/schabi/newpipe/Downloader.java | 12 ++++++------ .../org/schabi/newpipe/extractor/DashMpdParser.java | 8 ++++---- .../org/schabi/newpipe/extractor/Downloader.java | 8 ++++---- ...CaptchaException.java => ReCaptchaException.java} | 6 +++--- .../services/youtube/YoutubeStreamExtractor.java | 8 ++++---- .../schabi/newpipe/search_fragment/SearchWorker.java | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) rename app/src/main/java/org/schabi/newpipe/extractor/exceptions/{reCaptchaException.java => ReCaptchaException.java} (84%) diff --git a/app/src/main/java/org/schabi/newpipe/Downloader.java b/app/src/main/java/org/schabi/newpipe/Downloader.java index 748d6bd4d..a441e8978 100644 --- a/app/src/main/java/org/schabi/newpipe/Downloader.java +++ b/app/src/main/java/org/schabi/newpipe/Downloader.java @@ -1,6 +1,6 @@ package org.schabi.newpipe; -import org.schabi.newpipe.extractor.exceptions.reCaptchaException; +import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import java.io.BufferedReader; import java.io.IOException; @@ -67,7 +67,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { * @param siteUrl the URL of the text file to return the contents of * @param language the language (usually a 2-character code) to set as the preferred language * @return the contents of the specified text file*/ - public String download(String siteUrl, String language) throws IOException, reCaptchaException { + public String download(String siteUrl, String language) throws IOException, ReCaptchaException { Map requestProperties = new HashMap<>(); requestProperties.put("Accept-Language", language); return download(siteUrl, requestProperties); @@ -80,7 +80,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { * @param customProperties set request header properties * @return the contents of the specified text file * @throws IOException*/ - public String download(String siteUrl, Map customProperties) throws IOException, reCaptchaException { + public String download(String siteUrl, Map customProperties) throws IOException, ReCaptchaException { URL url = new URL(siteUrl); HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); Iterator it = customProperties.entrySet().iterator(); @@ -92,7 +92,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { } /**Common functionality between download(String url) and download(String url, String language)*/ - private static String dl(HttpsURLConnection con) throws IOException, reCaptchaException { + private static String dl(HttpsURLConnection con) throws IOException, ReCaptchaException { StringBuilder response = new StringBuilder(); BufferedReader in = null; @@ -121,7 +121,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { * See : https://github.com/rg3/youtube-dl/issues/5138 */ if (con.getResponseCode() == 429) { - throw new reCaptchaException("reCaptcha Challenge requested"); + throw new ReCaptchaException("reCaptcha Challenge requested"); } throw new IOException(e); } finally { @@ -137,7 +137,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { * Primarily intended for downloading web pages. * @param siteUrl the URL of the text file to download * @return the contents of the specified text file*/ - public String download(String siteUrl) throws IOException, reCaptchaException { + public String download(String siteUrl) throws IOException, ReCaptchaException { URL url = new URL(siteUrl); HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); //HttpsURLConnection con = NetCipher.getHttpsURLConnection(url); diff --git a/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java b/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java index 7dcbc16a8..c8ef7f1ac 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java @@ -3,7 +3,7 @@ package org.schabi.newpipe.extractor; import android.util.Xml; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.exceptions.reCaptchaException; +import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import org.schabi.newpipe.extractor.stream_info.AudioStream; import org.xmlpull.v1.XmlPullParser; @@ -44,15 +44,15 @@ public class DashMpdParser { } public static List getAudioStreams(String dashManifestUrl) - throws DashMpdParsingException, reCaptchaException { + throws DashMpdParsingException, ReCaptchaException { String dashDoc; Downloader downloader = NewPipe.getDownloader(); try { dashDoc = downloader.download(dashManifestUrl); } catch(IOException ioe) { throw new DashMpdParsingException("Could not get dash mpd: " + dashManifestUrl, ioe); - } catch (reCaptchaException e) { - throw new reCaptchaException("reCaptcha Challenge needed"); + } catch (ReCaptchaException e) { + throw new ReCaptchaException("reCaptcha Challenge needed"); } Vector audioStreams = new Vector<>(); try { diff --git a/app/src/main/java/org/schabi/newpipe/extractor/Downloader.java b/app/src/main/java/org/schabi/newpipe/extractor/Downloader.java index f25375113..fe85696b5 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/Downloader.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/Downloader.java @@ -1,6 +1,6 @@ package org.schabi.newpipe.extractor; -import org.schabi.newpipe.extractor.exceptions.reCaptchaException; +import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import java.io.IOException; import java.util.Map; @@ -33,7 +33,7 @@ public interface Downloader { * @param language the language (usually a 2-character code) to set as the preferred language * @return the contents of the specified text file * @throws IOException*/ - String download(String siteUrl, String language) throws IOException, reCaptchaException; + String download(String siteUrl, String language) throws IOException, ReCaptchaException; /**Download the text file at the supplied URL as in download(String), * but set the HTTP header field "Accept-Language" to the supplied string. @@ -41,12 +41,12 @@ public interface Downloader { * @param customProperties set request header properties * @return the contents of the specified text file * @throws IOException*/ - String download(String siteUrl, Map customProperties) throws IOException, reCaptchaException; + String download(String siteUrl, Map customProperties) throws IOException, ReCaptchaException; /**Download (via HTTP) the text file located at the supplied URL, and return its contents. * Primarily intended for downloading web pages. * @param siteUrl the URL of the text file to download * @return the contents of the specified text file * @throws IOException*/ - String download(String siteUrl) throws IOException, reCaptchaException; + String download(String siteUrl) throws IOException, ReCaptchaException; } diff --git a/app/src/main/java/org/schabi/newpipe/extractor/exceptions/reCaptchaException.java b/app/src/main/java/org/schabi/newpipe/extractor/exceptions/ReCaptchaException.java similarity index 84% rename from app/src/main/java/org/schabi/newpipe/extractor/exceptions/reCaptchaException.java rename to app/src/main/java/org/schabi/newpipe/extractor/exceptions/ReCaptchaException.java index a9107f15e..a28ec99f9 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/exceptions/reCaptchaException.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/exceptions/ReCaptchaException.java @@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.exceptions; * Created by beneth on 07.12.16. * * Copyright (C) Christian Schabesberger 2016 - * reCaptchaException.java is part of NewPipe. + * ReCaptchaException.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,8 +20,8 @@ package org.schabi.newpipe.extractor.exceptions; * along with NewPipe. If not, see . */ -public class reCaptchaException extends ExtractionException { - public reCaptchaException(String message) { +public class ReCaptchaException extends ExtractionException { + public ReCaptchaException(String message) { super(message); } } diff --git a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java index aa07bf96f..5910a1efb 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java @@ -11,7 +11,7 @@ import org.mozilla.javascript.ScriptableObject; import org.schabi.newpipe.extractor.AbstractStreamInfo; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.exceptions.reCaptchaException; +import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import org.schabi.newpipe.extractor.stream_info.AudioStream; import org.schabi.newpipe.extractor.Downloader; import org.schabi.newpipe.extractor.NewPipe; @@ -281,7 +281,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { } } - private String getPlayerUrlFromRestrictedVideo(String pageUrl) throws ParsingException, reCaptchaException { + private String getPlayerUrlFromRestrictedVideo(String pageUrl) throws ParsingException, ReCaptchaException { try { Downloader downloader = NewPipe.getDownloader(); String playerUrl = ""; @@ -303,8 +303,8 @@ public class YoutubeStreamExtractor extends StreamExtractor { } catch (IOException e) { throw new ParsingException( "Could load decryption code form restricted video for the Youtube service.", e); - } catch (reCaptchaException e) { - throw new reCaptchaException("reCaptcha Challenge requested"); + } catch (ReCaptchaException e) { + throw new ReCaptchaException("reCaptcha Challenge requested"); } } diff --git a/app/src/main/java/org/schabi/newpipe/search_fragment/SearchWorker.java b/app/src/main/java/org/schabi/newpipe/search_fragment/SearchWorker.java index 7ce0d30c5..6156d356d 100644 --- a/app/src/main/java/org/schabi/newpipe/search_fragment/SearchWorker.java +++ b/app/src/main/java/org/schabi/newpipe/search_fragment/SearchWorker.java @@ -8,7 +8,7 @@ import android.util.Log; import android.view.View; import org.schabi.newpipe.extractor.exceptions.ExtractionException; -import org.schabi.newpipe.extractor.exceptions.reCaptchaException; +import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import org.schabi.newpipe.extractor.search.SearchEngine; import org.schabi.newpipe.extractor.search.SearchResult; import org.schabi.newpipe.report.ErrorActivity; @@ -123,7 +123,7 @@ public class SearchWorker { } // hard errors: - } catch (reCaptchaException e) { + } catch (ReCaptchaException e) { h.post(new Runnable() { @Override public void run() { From 3767a96e0f3de084ab6869238bdfe0883a1dd141 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 24 Dec 2016 16:06:24 +0100 Subject: [PATCH 18/19] moved on to version 0.8.6 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 59989613b..381ea7ad3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "org.schabi.newpipe" minSdkVersion 15 targetSdkVersion 25 - versionCode 19 - versionName "0.8.5" + versionCode 20 + versionName "0.8.6" } buildTypes { release { From 38c5cb50fbc173e25d61b7313cba6d47057355eb Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 24 Dec 2016 17:11:29 +0100 Subject: [PATCH 19/19] fixed Downloader.getInstance() in unit tests --- .../extractor/youtube/YoutubeChannelExtractorTest.java | 2 +- .../newpipe/extractor/youtube/YoutubeSearchEngineTest.java | 2 +- .../newpipe/extractor/youtube/YoutubeSearchResultTest.java | 2 +- .../extractor/youtube/YoutubeStreamExtractorDefaultTest.java | 2 +- .../extractor/youtube/YoutubeStreamExtractorGemaTest.java | 2 +- .../youtube/YoutubeStreamExtractorLiveStreamTest.java | 4 ++-- .../youtube/YoutubeStreamExtractorRestrictedTest.java | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeChannelExtractorTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeChannelExtractorTest.java index b47677a16..d4aaf51b9 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeChannelExtractorTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeChannelExtractorTest.java @@ -32,7 +32,7 @@ public class YoutubeChannelExtractorTest extends AndroidTestCase { @Override public void setUp() throws Exception { super.setUp(); - NewPipe.init(new Downloader()); + NewPipe.init(Downloader.getInstance()); extractor = NewPipe.getService("Youtube") .getChannelExtractorInstance("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", 0); } diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java index 71e63b7f0..9cd89446d 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java @@ -35,7 +35,7 @@ public class YoutubeSearchEngineTest extends AndroidTestCase { @Override public void setUp() throws Exception { super.setUp(); - NewPipe.init(new Downloader()); + NewPipe.init(Downloader.getInstance()); SearchEngine engine = NewPipe.getService("Youtube").getSearchEngineInstance(); result = engine.search("this is something boring", 0, "de").getSearchResult(); diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchResultTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchResultTest.java index 5d68903cf..8f4a18b37 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchResultTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchResultTest.java @@ -38,7 +38,7 @@ public class YoutubeSearchResultTest extends AndroidTestCase { @Override public void setUp() throws Exception { super.setUp(); - NewPipe.init(new Downloader()); + NewPipe.init(Downloader.getInstance()); SuggestionExtractor engine = new YoutubeSuggestionExtractor(0); suggestionReply = engine.suggestionList("hello", "de"); } diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java index abde32ed7..880f018e2 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java @@ -38,7 +38,7 @@ public class YoutubeStreamExtractorDefaultTest extends AndroidTestCase { public void setUp() throws Exception { super.setUp(); - NewPipe.init(new Downloader()); + NewPipe.init(Downloader.getInstance()); extractor = NewPipe.getService("Youtube") .getExtractorInstance("https://www.youtube.com/watch?v=YQHsXMglC9A"); } diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorGemaTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorGemaTest.java index 3e6cf8d2c..6f1587c9a 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorGemaTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorGemaTest.java @@ -39,7 +39,7 @@ public class YoutubeStreamExtractorGemaTest extends AndroidTestCase { public void testGemaError() throws IOException, ExtractionException { if(testActive) { try { - NewPipe.init(new Downloader()); + NewPipe.init(Downloader.getInstance()); NewPipe.getService("Youtube") .getExtractorInstance("https://www.youtube.com/watch?v=3O1_3zBUKM8"); } catch(YoutubeStreamExtractor.GemaException ge) { diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorLiveStreamTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorLiveStreamTest.java index 72fcfd45d..9150ba93f 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorLiveStreamTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorLiveStreamTest.java @@ -38,9 +38,9 @@ public class YoutubeStreamExtractorLiveStreamTest extends AndroidTestCase { //todo: make the extractor not throw over a livestream /* - NewPipe.init(new Downloader()); + NewPipe.init(Downloader.getInstance()); extractor = NewPipe.getService("Youtube") - .getExtractorInstance("https://www.youtube.com/watch?v=J0s6NjqdjLE", new Downloader()); + .getExtractorInstance("https://www.youtube.com/watch?v=J0s6NjqdjLE", Downloader.getInstance()); */ } diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java index 092b082c7..1a7195f8c 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java @@ -17,7 +17,7 @@ public class YoutubeStreamExtractorRestrictedTest extends AndroidTestCase { public void setUp() throws Exception { super.setUp(); - NewPipe.init(new Downloader()); + NewPipe.init(Downloader.getInstance()); extractor = NewPipe.getService("Youtube") .getExtractorInstance("https://www.youtube.com/watch?v=i6JTvzrpBy0"); }