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 { try {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
String searchLanguageKey = getContext().getString(R.string.searchLanguage); 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); SearchEngine.Result result = engine.search(query, page, searchLanguage);
Log.i(TAG, "countryCode passed:\""+searchLanguage+"\""); Log.i(TAG, "language code passed:\""+searchLanguage+"\"");
if(run) { if(run) {
h.post(new ResultRunnable(result, requestId)); h.post(new ResultRunnable(result, requestId));
} }

View File

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

View File

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