I have the following function to search for movie via Rotten Tomatoes API by its title, which may accidentally be spelled not in basic English. I use HTTParty gem to wrap the API.
def self.search_by_title(title)
options = {query: {apikey: "secret", page_limit: "1" }}
response = self.get("http://api.rottentomatoes.com/api/public/v1.0/movies.json?q=#{CGI.escape(title)}", options)
movie = JSON.parse(response.body)
end
So if I make, let's say, the following request (search for "Rashômon" movie):
http://api.rottentomatoes.com/api/public/v1.0/movies.json?q=#{CGI.escape(Rashômon)}&apikey=apikey
it returns empty hash
{"total"=>0, "movies"=>[], "links"=>{"self"=>"http://api.rottentomatoes.com/api/public/v1.0/movies.json?q=Rash%C3%83%C2%B4mon&page_limit=1&page=1"}
If I instead use just "Rashomon" it is OK. But I obtain these titles via 3d party API and sometimes it gives titles in such format.
I know that I should probably search by other identifications (imdb_id, english name etc., but sometimes I cannot provide these variables and use search_by_title as a fallback function.
Is there any way to get around it?