1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 02:53:09 +01:00

minor commit:

-removed now-redundant language code check
This commit is contained in:
Adam Howard 2015-11-10 17:09:26 +00:00
parent 9e7d9ee973
commit 27b450f1e3
3 changed files with 5 additions and 13 deletions

View File

@ -94,9 +94,9 @@ public class VideoItemListFragment extends ListFragment {
try {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
String searchLanguageKey = getContext().getString(R.string.searchLanguage);
String searchLanguage = sp.getString(searchLanguageKey, "");
String searchLanguage = sp.getString(searchLanguageKey, "en");
SearchEngine.Result result = engine.search(query, page, searchLanguage);
Log.i(TAG, "countryCode passed:\""+searchLanguage+"\"");
Log.i(TAG, "language code passed:\""+searchLanguage+"\"");
if(run) {
h.post(new ResultRunnable(result, requestId));
}

View File

@ -61,23 +61,17 @@ public class YoutubeSearchEngine implements SearchEngine {
String site;
String url = builder.build().toString();
//if we've been passed a valid, non-empty language code, append it to the URL
//if we've been passed a valid language code, append it to the URL
if(languageCode.length() > 0) {
if(languageCode.length() == 2) {
//assert Pattern.matches("[a-z]{2}(-([A-Z]{2}|[0-9]{1,3}))?", languageCode);
Log.i(TAG, "URI: \""+builder+"\"");
site = Downloader.download(url, languageCode);
}
else {
Log.e(TAG, "invalid language code passed to search(): \""+languageCode+"\"");
site = Downloader.download(url);
}
}
else {
site = Downloader.download(url);
}
//String site = Downloader.download(url);
Document doc = Jsoup.parse(site, url);
Result result = new Result();
Element list = doc.select("ol[class=\"item-section\"]").first();

View File

@ -51,7 +51,6 @@
android:title="@string/showNextAndSimilarTitle"
android:defaultValue="true" />
<!-- This function is not yet available
<ListPreference
android:key="@string/searchLanguage"
android:title="@string/searchLanguageTitle"
@ -59,5 +58,4 @@
android:entryValues="@array/languageCodes"
android:defaultValue="en" />
-->
</PreferenceScreen>