X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=src%2Fmodules%2Fallocine.rb;h=b4b65f0a5cdebbc6417bf16ae0722194f5c7f48b;hb=40778efb4943c2f728258e865210fa169dfb3d15;hp=5a4e759a51646b1902ca5d55b125bfd26a3edf2b;hpb=5b3fa6fac8a53d1ce7d43d6c506db104a42c206a;p=pompage.git diff --git a/src/modules/allocine.rb b/src/modules/allocine.rb index 5a4e759..b4b65f0 100644 --- a/src/modules/allocine.rb +++ b/src/modules/allocine.rb @@ -79,7 +79,7 @@ class Allocine < Basemodule # Voir le parent. def load(id, film) - loadPath("/film/fichefilm_gen_cfilm=#{id}.html") + loadPath("/film/fichefilm_gen_cfilm=#{id}.html", film) end def loadURL(url, film) @@ -105,8 +105,8 @@ class Allocine < Basemodule #convertit le code latin-1 en UTF8 html = Iconv.iconv("UTF-8", "ISO-8859-1", html)[0] - - if take?("image") + + if take?("image") && ($force || !film.possedeImage?) // =~ html unless $1.nil? @threadImage = Thread::start($1){|imageUrl| @@ -114,10 +114,7 @@ class Allocine < Basemodule 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 + film.setImage(connexionImage.get(imageUrlParsed.path).body) connexionImage.finish rescue Exception => e puts e.message @@ -129,24 +126,24 @@ class Allocine < Basemodule end end - #url - if take?("url") + if take?("url") && ($force || film.url == nil) + #url film.url = "http://www.allocine.fr" + path end if take?("titre") # Titre /(.*?)<\/title>/ =~ html - film.titre = $1 unless $1.nil? + film.titre = $1 end - if take?("annee") + if take?("annee") && ($force || film.annee == nil) # Année /<h4>Année de production : (\d+)<\/h4>/ =~ html film.annee = $1 unless $1.nil? end - if take?("realisateurs") + if take?("realisateurs") && ($force || film.realisateurs.empty?) # Réalisateurs film.realisateurs.clear /<h4>Réalisé par(.*?)<\/h4>/ =~ html @@ -155,7 +152,7 @@ class Allocine < Basemodule } unless $1.nil? end - if take?("acteurs") + if take?("acteurs") && ($force || film.acteurs.empty?) # Acteurs film.acteurs.clear /<h4>Avec(.*?)<\/h4>/ =~ html @@ -164,7 +161,7 @@ class Allocine < Basemodule } unless $1.nil? end - if take?("pays") + if take?("pays") && ($force || film.pays.empty?) # Pays film.pays.clear /<h4>Film (.*?)\. <\/h4>/ =~ html @@ -173,7 +170,7 @@ class Allocine < Basemodule } unless $1.nil? end - if take?("duree") + if take?("duree") && ($force || film.duree == nil) # Duree (capture des heures et des minutes séparement vue que c'est le bordel sur allocine /<h4>Durée :(?:.*?)(\d+)h/ =~ html heure = $1.nil? ? 0 : $1.to_i @@ -182,14 +179,14 @@ class Allocine < Basemodule film.duree = heure * 60 + min end - if take?("critiquenote") + if take?("critiquenote") && ($force || film.critiquePresse == nil || film.critiqueSpectateur == nil) # Critiques presse et spectateur /Presse.*etoile_([012345]).*Spectateurs.*etoile_([012345])"/m =~ html film.critiquePresse = $1 unless $1.nil? film.critiqueSpectateur = $2 unless $2.nil? end - if take?("genre") + if take?("genres") && ($force || film.genres.empty?) # Genre film.genres.clear /<h4>Genre : (.*?)<\/h4>/ =~ html @@ -198,7 +195,7 @@ class Allocine < Basemodule } unless $1.nil? end - if take?("synopsis") + if take?("synopsis") && ($force || film.synopsis == nil) # Synopsis /Synopsis.*?<h4>(.*?)<\/h4>/m =~ html unless $1.nil? @@ -208,7 +205,7 @@ class Allocine < Basemodule end end - if take?("budget") + if take?("budget") && ($force || film.budget == nil) # Budget /Budget<\/b> : (.+?) millions d'euros<\/h4>/ =~ html film.budget = $1 unless $1.nil?