11class ChannelSearchException < InfoException
2+ def initialize (channel : String )
3+ super " Unable to find channel with id of '#{ channel } '. Are you sure that's an actual channel id?"
4+ end
25end
36
47def channel_search (query, page, channel)
@@ -9,7 +12,7 @@ def channel_search(query, page, channel)
912 response = YT_POOL .client & .get(" /c/#{ channel } " ) if response.status_code == 404
1013 initial_data = extract_initial_data(response.body)
1114 ucid = initial_data.dig?(" header" , " c4TabbedHeaderRenderer" , " channelId" ).try(& .as_s?)
12- raise ChannelSearchException .new(" Impossible to extract channel ID from page " ) if ! ucid
15+ raise ChannelSearchException .new(channel) if ! ucid
1316 else
1417 ucid = channel
1518 end
@@ -213,13 +216,7 @@ def process_search_query(query, page, user, region)
213216 search_query = (query.split(" " ) - operators).join(" " )
214217
215218 if channel
216- begin
217- count, items = channel_search(search_query, page, channel)
218- rescue ChannelSearchException
219- # most likely reason for this is that they provided an invalid channel id to the search
220- count = 0
221- items = [] of ChannelVideo
222- end
219+ count, items = channel_search(search_query, page, channel)
223220 elsif subscriptions
224221 if view_name
225222 items = PG_DB .query_all(" SELECT id,title,published,updated,ucid,author,length_seconds FROM (
0 commit comments