+
+proc getAutoPlayVideo*(searchResult: SearchResult): SearchResult =
+ # Take a search result and fetch its first recommendation
+ let videoId = searchResult.url.split("=")[1]
+ let client = newHttpClient()
+ let response = get(client, &"{invidiousInstance}/api/v1/videos/{videoId}")
+ let jsonData = parseJson($response.body)
+ let firstRecommendation = jsonData["recommendedVideos"][0]
+ (firstRecommendation["title"].getStr(), makeUrl(firstRecommendation["videoId"].getStr()))