def get_result_list(query_str): user_prefs = core.get_user_prefs() pref_defs = get_pref_defs(user_prefs) query_str = core.normalize_query_str(query_str) pref_match = get_pref_match(query_str) results = [] if pref_match: pref_key_query = pref_match.group(1) pref_value_query = pref_match.group(2) for pref_def in pref_defs: # If key name in query exactly match a preference key name if core.normalize_query_str(pref_def['id']) == pref_key_query: # Get list of available values for the given preference results = get_value_result_list( user_prefs, pref_def, pref_value_query) break # If no exact match, filter list of available preferences by query if not results: results = get_pref_result_list( user_prefs, pref_defs, pref_key_query) else: # Should show all available preferences if query is empty # or if query does not match results = get_pref_result_list(user_prefs, pref_defs) return results
def get_copied_ref(ref_uid): user_prefs = core.get_user_prefs() ref = core.get_ref(ref_uid, user_prefs) return get_ref_content( ref, ref_format=user_prefs['refformat'], include_verse_numbers=user_prefs['versenumbers'])
def get_result_list(query_str): query_str = core.normalize_query_str(query_str) user_prefs = core.get_user_prefs() html = get_search_html(query_str, user_prefs) parser = SearchResultParser(user_prefs) parser.feed(html) return parser.results
def set_pref(pref_id, value_id): user_prefs = core.get_user_prefs() user_prefs[pref_id] = value_id # If new language is set, ensure that preferred version is updated also if pref_id == 'language': bible = core.get_bible(language_id=value_id) user_prefs['version'] = bible['default_version'] cache.clear_cache() core.set_user_prefs(user_prefs)
def get_search_html(query_str): version = core.get_user_prefs()['version'] url = 'https://www.bible.com/search/bible?q={}&version_id={}'.format( urllib.quote_plus(query_str.encode('utf-8')), version) entry_key = '{}/{}.html'.format(version, query_str) search_html = cache.get_cache_entry_content(entry_key) if not search_html: search_html = web.get_url_content(url) cache.add_cache_entry(entry_key, search_html) return search_html
def main(ref_uid): user_prefs = core.get_user_prefs() ref = core.get_ref(ref_uid, user_prefs) print(json.dumps({ 'alfredworkflow': { 'arg': ref_uid, 'variables': { 'copied_ref': get_copied_ref_from_object(ref, user_prefs), 'full_ref_name': core.get_full_ref_name(ref) } } }))
def get_result_list(query_str): query_str = normalize_query_str(query_str) query = get_query_object(query_str) if not query: return [] user_prefs = core.get_user_prefs() bible = core.get_bible(user_prefs['language']) book_metadata = core.get_book_metadata() if 'chapter' not in query: query['chapter'] = 1 chosen_version = choose_best_version(user_prefs, bible, query) # Build and return result list from books matching the query return [get_result(book, query, chosen_version, book_metadata[book['id']]) for book in get_matching_books(bible['books'], query)]
def get_result_list(query_str): query_str = normalize_query_str(query_str) query = get_query_object(query_str) if not query: return [] user_prefs = core.get_user_prefs() bible = core.get_bible(user_prefs['language']) if 'chapter' not in query: query['chapter'] = 1 chosen_version = choose_best_version(user_prefs, bible, query) # Build and return result list from books matching the query return [ get_result(book, query, chosen_version, user_prefs) for book in get_matching_books(bible['books'], query) ]
def get_copied_ref(ref_uid): user_prefs = core.get_user_prefs() ref = core.get_ref(ref_uid, user_prefs) return get_copied_ref_from_object(ref, user_prefs)
def main(ref_uid): user_prefs = core.get_user_prefs() ref = core.get_ref(ref_uid, user_prefs) print(core.get_full_ref_name(ref).encode('utf-8'), end=''.encode('utf-8'))