@@ -5,7 +5,7 @@ class ChannelSearchException < InfoException
55 end
66end
77
8- def channel_search (query, page, channel)
8+ def channel_search (query, page, channel) : Array ( SearchItem )
99 response = YT_POOL .client & .get(" /channel/#{ channel } " )
1010
1111 if response.status_code == 404
@@ -24,25 +24,24 @@ def channel_search(query, page, channel)
2424 continuation_items = response_json[" onResponseReceivedActions" ]?
2525 .try & .[0 ][" appendContinuationItemsAction" ][" continuationItems" ]
2626
27- return 0 , [] of SearchItem if ! continuation_items
27+ return [] of SearchItem if ! continuation_items
2828
2929 items = [] of SearchItem
3030 continuation_items.as_a.select(& .as_h.has_key?(" itemSectionRenderer" )).each { |item |
3131 extract_item(item[" itemSectionRenderer" ][" contents" ].as_a[0 ])
3232 .try { |t | items << t }
3333 }
3434
35- return items.size, items
35+ return items
3636end
3737
38- def search (query, search_params = produce_search_params(content_type: " all" ), region = nil )
39- return 0 , [] of SearchItem if query.empty?
38+ def search (query, search_params = produce_search_params(content_type: " all" ), region = nil ) : Array ( SearchItem )
39+ return [] of SearchItem if query.empty?
4040
4141 client_config = YoutubeAPI ::ClientConfig .new(region: region)
4242 initial_data = YoutubeAPI .search(query, search_params, client_config: client_config)
43- items = extract_items(initial_data)
4443
45- return items.size, items
44+ return extract_items(initial_data)
4645end
4746
4847def produce_search_params (page = 1 , sort : String = " relevance" , date : String = " " , content_type : String = " " ,
@@ -217,7 +216,7 @@ def process_search_query(query, page, user, region)
217216 search_query = (query.split(" " ) - operators).join(" " )
218217
219218 if channel
220- count, items = channel_search(search_query, page, channel)
219+ items = channel_search(search_query, page, channel)
221220 elsif subscriptions
222221 if view_name
223222 items = PG_DB .query_all(" SELECT id,title,published,updated,ucid,author,length_seconds FROM (
@@ -227,16 +226,14 @@ def process_search_query(query, page, user, region)
227226 as document
228227 FROM #{ view_name }
229228 ) v_search WHERE v_search.document @@ plainto_tsquery($1) LIMIT 20 OFFSET $2;" , search_query, (page - 1 ) * 20 , as: ChannelVideo )
230- count = items.size
231229 else
232230 items = [] of ChannelVideo
233- count = 0
234231 end
235232 else
236233 search_params = produce_search_params(page: page, sort: sort, date: date, content_type: content_type,
237234 duration: duration, features: features)
238235
239- count, items = search(search_query, search_params, region).as( Tuple )
236+ items = search(search_query, search_params, region)
240237 end
241238
242239 # Light processing to flatten search results out of Categories.
@@ -254,5 +251,5 @@ def process_search_query(query, page, user, region)
254251 end
255252 end
256253
257- {search_query, items_without_category.size, items_without_category , operators}
254+ {search_query, items_without_category, operators}
258255end
0 commit comments