X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodules%2Fallocine.rb;h=c26c214d0e85ef5e65eb9510965cef5d53a1d916;hb=171308744ae16e63958d4b83dc135aa7bbdeab8f;hp=01764f82eed968800aa218e532add70e312a0d8d;hpb=c3b0deb3d8c9f439739c79806e915c29bc1d4b84;p=pompage.git
diff --git a/src/modules/allocine.rb b/src/modules/allocine.rb
index 01764f8..c26c214 100644
--- a/src/modules/allocine.rb
+++ b/src/modules/allocine.rb
@@ -20,12 +20,16 @@ module Net
end
end
-
-# un module d'importation pour le site "www.allocine.fr"
+# Un module d'importation pour le site "www.allocine.fr".
class Allocine < Basemodule
def createConnexion
- @connexion = Net::HTTP::new('www.allocine.fr').start if @connexion == nil || !@connexion.started?
+ begin
+ @connexion = Net::HTTP::new('www.allocine.fr').start if @connexion == nil || !@connexion.started?
+ rescue
+ Puts "[!] Impossible de se connecter à Allocine. Retry.."
+ retry
+ end
end
def fermerConnexion
@@ -33,10 +37,10 @@ class Allocine < Basemodule
@connexion = nil
end
- # voir le parent.
+ # Voir le parent.
def rechercherFilm(titre)
createConnexion
-
+
begin
reponse = nil
begin
@@ -75,11 +79,20 @@ class Allocine < Basemodule
# Voir le parent.
def load(id, film)
+ loadPath("/film/fichefilm_gen_cfilm=#{id}.html", film)
+ end
+
+ # Voir le parent.
+ def loadURL(url, film)
+ loadPath(URI.parse(url).path, film)
+ end
+
+ def loadPath(path, film)
createConnexion
html = nil
begin
- html = @connexion.get("/film/fichefilm_gen_cfilm=#{id}.html").body
+ html = @connexion.get(path).body
rescue Exception => e
p e
puts "[!] Erreur lors du chargement de #{film.fichiers[0]}, retry.."
@@ -87,96 +100,123 @@ class Allocine < Basemodule
createConnexion
retry
end
-
- // =~ html
- unless $1.nil?
- @threadImage = Thread::start($1){|imageUrl|
- begin
- imageUrl = URI.parse(imageUrl)
- connexionImage = Net::HTTP::new(imageUrl.host).start
- image = connexionImage.get(imageUrl.path).body
- f = File::new($repBase + "/" + $repAffichette + film.id.to_s + ".jpg", 'w').binmode
- f.write(image)
- f.close
- connexionImage.finish
- rescue Exception => e
- puts e.message
- puts e.backtrace
- puts "[!] Erreur lors du chargement de l'image #{imageUrl}, retry.."
- retry
- end
- }
- end
-
- #convertit le code latin-1 en UTF8
- html = Iconv.iconv("UTF-8", "ISO-8859-1", html)[0]
- #url
- film.url = "http://www.allocine.fr/film/fichefilm_gen_cfilm=#{id}.html"
- # Titre
- /