From dd3b7b90fb5d1a250f77056e39dd7e47a95c440a Mon Sep 17 00:00:00 2001 From: Ghislain Loas <ghislo@sandbox.pergame.net> Date: Wed, 8 Jul 2015 13:20:50 +0200 Subject: [PATCH] update fnac summary --- library/Class/WebService/AllServices.php | 18 ++++++++--------- library/Class/WebService/Fnac.php | 25 +++++++++++++++++++++++- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/library/Class/WebService/AllServices.php b/library/Class/WebService/AllServices.php index b11bed6d6e2..df5010518ee 100644 --- a/library/Class/WebService/AllServices.php +++ b/library/Class/WebService/AllServices.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_WebService_AllServices { @@ -35,9 +35,9 @@ class Class_WebService_AllServices { 'rend_livres_similaires(@isbn)', 'rend_images(@isbn)']], - 'AmazonSonores' => ['valeurs' => ['ean' => '0794881405923', - 'asin' => 'B00005BH6V', - 'volume' => '1', + 'AmazonSonores' => ['valeurs' => ['ean' => '0794881405923', + 'asin' => 'B00005BH6V', + 'volume' => '1', 'track' => '1'], 'services' => ['rend_notice_ean(@ean)', 'getImages(@ean)']], @@ -62,12 +62,12 @@ class Class_WebService_AllServices { 'Fnac' => ['valeurs' => ['isbn' => '978-2-7427-6501-0'], 'services' => ['getResume(@isbn)']], - 'OAI' => ['valeurs' => ['oai_handler' => 'http://oai.bnf.fr/oai2/OAIHandler', + 'OAI' => ['valeurs' => ['oai_handler' => 'http://oai.bnf.fr/oai2/OAIHandler', 'set' => 'gallica'], 'services' => ['getSetsFromHandler(@oai_handler)', 'getRecordsFromHandlerAndSet(@oai_handler, @set)']], - 'SRU' => ['valeurs' => ['service_url' => 'http://bvpb.mcu.es/i18n/sru/sru.cmd', + 'SRU' => ['valeurs' => ['service_url' => 'http://bvpb.mcu.es/i18n/sru/sru.cmd', 'query' => 'spain'], 'services' => ['search(@service_url, @query)']]]; @@ -164,7 +164,7 @@ class Class_WebService_AllServices { public static function createSecurityKey() { return md5("IMG".date("DxzxYxM")."VIG"); } - + public function testService($id_service,$id_fonction) { if(!$id_service) return false; @@ -175,13 +175,13 @@ class Class_WebService_AllServices { { $num_fonction++; if($id_fonction and $num_fonction != $id_fonction) continue; - + // On met les arguments foreach($this->services[$id_service]["valeurs"] as $param => $valeur) { $instruction=str_replace("@".$param,"'".$valeur."'",$instruction); } - + // on fabrique l'instruction d'appel au web service et on l'execute $instruction="\$test=\$cls->".$instruction.";"; eval($instruction); diff --git a/library/Class/WebService/Fnac.php b/library/Class/WebService/Fnac.php index c549c366026..1026ff23e0d 100644 --- a/library/Class/WebService/Fnac.php +++ b/library/Class/WebService/Fnac.php @@ -59,7 +59,7 @@ class Class_WebService_Fnac extends Class_WebService_Abstract { public function getUrlLireLaSuite($data) { - $pos = striPos($data,"resume"); + $pos = striPos($data,"summary"); if(!$pos) return ''; @@ -76,6 +76,9 @@ class Class_WebService_Fnac extends Class_WebService_Abstract { if ($pos = striPos($html, "avisEdContent")) return $this->extractLireLaSuiteDivAvisEditeurFromHTML($html); + if ($pos = striPos($html, "ficheResume")) + return $this->extractSummaryFromProduct($html); + if (!$pos = striPos($html, "laSuite bigLaSuite")) return $this->extractLireLaSuiteDivFromHTML($html); @@ -91,6 +94,26 @@ class Class_WebService_Fnac extends Class_WebService_Abstract { } + protected function extractSummaryFromProduct($html) { + $section_html = 'ficheResume'; + if(!$sub_html = striPos($html, $section_html)) + return ''; + + $sub_html = $sub_html + strlen($section_html); + $sub_html_end = strPos($html, "</section", $sub_html); + $section = substr($html, $sub_html, ($sub_html_end - $sub_html)); + + $start_string = 'whiteContent">'; + if (!$pos = striPos($section, $start_string)) + return ''; + + $pos = $pos + strlen($start_string); + $posfin = strPos($section, "</div>", $pos); + + return trim(substr($section, $pos, ($posfin - $pos))); + } + + protected function extractResumeFormBlk($html) { $start_string = 'resMarkContent">'; -- GitLab