Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions program.rb
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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