FIX qques bugs...
[pompage.git] / src / modules / allocine.rb
index 7f232f2..23a26b8 100644 (file)
@@ -25,7 +25,12 @@ end
 class Allocine  < Basemodule\r
    \r
    def createConnexion\r
-      @connexion = Net::HTTP::new('www.allocine.fr').start if @connexion == nil || !@connexion.started?\r
+      begin\r
+         @connexion = Net::HTTP::new('www.allocine.fr').start if @connexion == nil || !@connexion.started?\r
+      rescue \r
+         Puts "Impossible de se connecter à Allocine. Retry.."\r
+         retry\r
+      end\r
    end\r
    \r
    def fermerConnexion      \r
@@ -36,7 +41,7 @@ class Allocine  < Basemodule
    # voir le parent.\r
    def rechercherFilm(titre)\r
       createConnexion\r
-\r
+      \r
       begin\r
          reponse = nil\r
          begin\r
@@ -93,9 +98,9 @@ class Allocine  < Basemodule
          @threadImage = Thread::start($1){|imageUrl|\r
             nbRetry = 0\r
             begin\r
-               imageUrl = URI.parse(imageUrl)               \r
-               connexionImage = Net::HTTP::new(imageUrl.host).start\r
-               image = connexionImage.get(imageUrl.path).body\r
+               imageUrlParsed = URI.parse(imageUrl)               \r
+               connexionImage = Net::HTTP::new(imageUrlParsed.host).start\r
+               image = connexionImage.get(imageUrlParsed.path).body\r
                f = File::new($repBase + "/" + $repAffichette + film.id.to_s + ".jpg", 'w').binmode\r
                f.write(image)\r
                f.close\r