parent
9e7d9ee973
commit
27b450f1e3
|
@ -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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue