1

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?

MrLore
  • 3,759
  • 2
  • 28
  • 36
Ilya Cherevkov
  • 1,743
  • 2
  • 17
  • 47
  • 1
    Could this answer help you in some way? http://stackoverflow.com/questions/522715/removing-accents-diacritics-from-string-while-preserving-other-special-chars-tr – Jakob W Feb 19 '13 at 20:58
  • Perfect!! Thank you so much! You can post it as answer – Ilya Cherevkov Feb 19 '13 at 22:56
  • 1
    You're welcome! I tried but it was auto-converted to a comment because it was too simple. Just give the comment an upvote instead ;-) – Jakob W Feb 20 '13 at 14:55

0 Answers0