diff --git a/program.rb b/program.rb new file mode 100755 index 0000000..4245a10 --- /dev/null +++ b/program.rb @@ -0,0 +1,22 @@ +#!/usr/bin/ruby + +require 'net/http' +require 'uri' +require 'json' + +name = ARGV[0] + +# if there is no movie in the entry, the error message show up +if (!name.nil?) + # the uri to get the movie information from the open movie data base api https://www.omdbapi.com/ + # the parameter s fetch a list of movies associte to the name + uri = URI('http://www.omdbapi.com/?s=' + name +'&y=&r=json') + res = Net::HTTP.get(uri) + # Parsing the response in a json object + json = JSON.parse(res) + # I take the first movie from the list of movies + puts "Title: " + json["Search"][0]["Title"] + puts "Year: " +json["Search"][0]["Year"] +else + puts "no argument" +end diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..021d7be --- /dev/null +++ b/readme.md @@ -0,0 +1,12 @@ +voici un petit programme qui va cherhcer le titre et l'année d'un film +avec le API de imdb (www.omdbapi.com) + +Pour executer le programme : +./program.rb arg +ou +ruby program.rb arg + +Samuel Laroche LARS14039507 +samuel.laroche.1@etsmtl.net +Étudiant à l'ETS en génie logiciel +stage 2