I don't even want an "algorihtm" per se. Just search, show results and a download or paly. That's it.
Freetube but if you want HD you have to separate out the video and audio downloads then combine them after. A little annoying but it does have download right there in the client
By algorithm I mean a scoring function to tell which video is relevant to the search.