X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodules%2Fallocine.rb;h=9c0cbffdeb04f3e914e9a0db31f802e2342cef10;hb=339621e8669fbd4b09e2d0825f5521469503837b;hp=23a26b890ba26ba735f6ecfc7e50fb44f51182cb;hpb=28e1ecf7c5b45d5deeb87d488f32d44e0ea2fd11;p=pompage.git
diff --git a/src/modules/allocine.rb b/src/modules/allocine.rb
index 23a26b8..9c0cbff 100644
--- a/src/modules/allocine.rb
+++ b/src/modules/allocine.rb
@@ -20,7 +20,6 @@ module Net
end
end
-
# un module d'importation pour le site "www.allocine.fr"
class Allocine < Basemodule
@@ -28,7 +27,7 @@ class Allocine < Basemodule
begin
@connexion = Net::HTTP::new('www.allocine.fr').start if @connexion == nil || !@connexion.started?
rescue
- Puts "Impossible de se connecter à Allocine. Retry.."
+ Puts "[!] Impossible de se connecter à Allocine. Retry.."
retry
end
end
@@ -80,11 +79,20 @@ class Allocine < Basemodule
# Voir le parent.
def load(id, film)
+ loadPath("/film/fichefilm_gen_cfilm=#{id}.html", film)
+ end
+
+ def loadURL(url, film)
+ loadPath(URI.parse(url).path, film)
+ end
+
+ # Voir le parent.
+ 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.."
@@ -92,92 +100,116 @@ class Allocine < Basemodule
createConnexion
retry
end
-
- // =~ html
- unless $1.nil?
- @threadImage = Thread::start($1){|imageUrl|
- nbRetry = 0
- begin
- imageUrlParsed = URI.parse(imageUrl)
- connexionImage = Net::HTTP::new(imageUrlParsed.host).start
- image = connexionImage.get(imageUrlParsed.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 if (nbRetry += 1) < 5
- 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
- /