X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=src%2Fmodules%2Fallocine.rb;h=56a2ed24fb0f1a34c2618673a65455c82be7c8e8;hb=ebe735cec6c5f3c9ba410b8ea7127585898d5755;hp=b4b65f0a5cdebbc6417bf16ae0722194f5c7f48b;hpb=40778efb4943c2f728258e865210fa169dfb3d15;p=pompage.git diff --git a/src/modules/allocine.rb b/src/modules/allocine.rb index b4b65f0..56a2ed2 100644 --- a/src/modules/allocine.rb +++ b/src/modules/allocine.rb @@ -20,7 +20,7 @@ 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 @@ -37,7 +37,7 @@ class Allocine < Basemodule @connexion = nil end - # voir le parent. + # Voir le parent. def rechercherFilm(titre) createConnexion @@ -68,7 +68,7 @@ class Allocine < Basemodule reponses = {} unless titre.nil? or titre.empty? - r = html.scan(/(.*?)<\/a>(?:<\/h4>
 (.*?)<\/h5>){0,1}(?:


<\/h4>){0,1}(?:

de (.*?)<\/h4>){0,1}(?:

 avec (.*?)<\/h4>){0,1}(?:

 \((.*?)\)<\/h4>){0,1}/) + r = html.scan(/(.*?)<\/a>(?:<\/h4>
 (.*?)<\/h5>)?(?:


de (.*?)<\/h4>)?(?:


avec (.*?)<\/h4>)?(?:

 \((.*?)\)<\/h4>)?/) r.each{|f| reponses[f[1].virerBalisesHTML + (f[2] != nil ? " " + f[2].virerBalisesHTML : "") + (f[3] != nil ? " de " + f[3].virerBalisesHTML : "") + (f[4] != nil ? " avec " + f[4].virerBalisesHTML : "") + (f[5] != nil ? " (" + f[5].virerBalisesHTML + ")" : "")] = f[0] @@ -82,11 +82,11 @@ class Allocine < Basemodule loadPath("/film/fichefilm_gen_cfilm=#{id}.html", film) end + # Voir le parent. def loadURL(url, film) loadPath(URI.parse(url).path, film) end - # Voir le parent. def loadPath(path, film) createConnexion @@ -103,9 +103,10 @@ class Allocine < Basemodule puts "Pompage de #{film.titre} (#{film.fichiers[0]}) ..." - #convertit le code latin-1 en UTF8 + # convertit le code latin-1 en UTF8 html = Iconv.iconv("UTF-8", "ISO-8859-1", html)[0] + # pompage de l'image dans un thread séparé if take?("image") && ($force || !film.possedeImage?) // =~ html unless $1.nil? @@ -166,7 +167,7 @@ class Allocine < Basemodule film.pays.clear /

Film (.*?)\. <\/h4>/ =~ html $1.split(',').each{|pays| - film.pays << Pays::ajouter(pays) unless pays.nil? + film.pays << Pays::ajouter(pays.strip) unless pays.nil? } unless $1.nil? end @@ -212,9 +213,10 @@ class Allocine < Basemodule end fermerConnexion - end + end def finish + # on attend que tous les threads de pompage d'image aient terminé @threadImage.join if defined? @threadImage end end \ No newline at end of file