@@ -135,12 +135,12 @@ async def zci_extra(q: str,
135
135
web_fallback : bool = True ,
136
136
priority : Tuple [str ] = DEFAULT_PRIORITIES ,
137
137
urls : bool = True ,
138
- ** kwargs ) -> Tuple [str , bool , str ]:
138
+ ** kwargs ) -> Tuple [str , str ]:
139
139
'''A helper method to get a single (and hopefully the best) ZCI result.
140
140
priority=list can be used to set the order in which fields will be checked for answers.
141
141
Use web_fallback=True to fall back to grabbing the first web result.
142
142
passed to query. This method will fall back to 'Sorry, no results.'
143
- if it cannot find anything. Returns a tuple with [result, result_found, result_type] which
143
+ if it cannot find anything. Returns a tuple with [result, result_type] which
144
144
allows to determine how the result was retrieved.'''
145
145
146
146
logger .info (f"Performing DDG ZCI: '{ q } '" )
@@ -149,8 +149,7 @@ async def zci_extra(q: str,
149
149
150
150
ddg = await query (f'\\ { q } ' , ** kwargs )
151
151
response = ''
152
- found = True
153
- result_type = ''
152
+ result_type = getattr (ddg , 'type' , '' )
154
153
155
154
for p in priority :
156
155
ps = p .split ('.' )
@@ -181,15 +180,12 @@ async def zci_extra(q: str,
181
180
if not response and web_fallback :
182
181
logger .debug ("Trying web fallback..." )
183
182
if ddg .redirect .url :
184
- found = True
185
- result_type = ddg .type
186
183
response = ddg .redirect .url
187
184
188
185
# Final fallback
189
186
if not response :
190
187
logger .info ("No results!" )
191
- found = False
192
188
response = 'Sorry, no results.'
193
189
194
190
logger .debug (f"Final response: { response !r} " )
195
- return (response , found , result_type )
191
+ return (response , result_type )
0 commit comments