1+ class ChannelSearchException < InfoException
2+ end
3+
14def channel_search (query, page, channel)
25 response = YT_POOL .client & .get(" /channel/#{ channel } " )
36
@@ -6,7 +9,7 @@ def channel_search(query, page, channel)
69 response = YT_POOL .client & .get(" /c/#{ channel } " ) if response.status_code == 404
710 initial_data = extract_initial_data(response.body)
811 ucid = initial_data.dig?(" header" , " c4TabbedHeaderRenderer" , " channelId" ).try(& .as_s?)
9- raise InfoException .new(" Impossible to extract channel ID from page" ) if ! ucid
12+ raise ChannelSearchException .new(" Impossible to extract channel ID from page" ) if ! ucid
1013 else
1114 ucid = channel
1215 end
@@ -210,7 +213,13 @@ def process_search_query(query, page, user, region)
210213 search_query = (query.split(" " ) - operators).join(" " )
211214
212215 if channel
213- count, items = channel_search(search_query, page, 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
214223 elsif subscriptions
215224 if view_name
216225 items = PG_DB .query_all(" SELECT id,title,published,updated,ucid,author,length_seconds FROM (
0 commit comments