From ff5ac1659f9010ec333a4a8ac851c0a8a0769b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sun, 28 Aug 2016 11:50:01 +0200 Subject: [PATCH] [Arte7bridge] code simplification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/Arte7Bridge.php | 45 +++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php index 9510dd1..19e039f 100644 --- a/bridges/Arte7Bridge.php +++ b/bridges/Arte7Bridge.php @@ -43,30 +43,31 @@ ) ); - protected function extractVideoset($category='toutes-les-videos', $lang='fr'){ - $url = 'http://www.arte.tv/guide/'.$lang.'/plus7/'.$category; - $input = $this->getContents($url) or die('Could not request ARTE.'); - if(strpos($input, 'categoryVideoSet') !== FALSE){ - $input = explode('categoryVideoSet: ', $input); - $input = explode('}},', $input[1]); - $input = $input[0].'}}'; - }else{ - $input = explode('videoSet: ', $input); - $input = explode('}]},', $input[1]); - $input = $input[0].'}]}'; - } - $input = json_decode($input, TRUE); - return $input; - } - public function collectData(){ - $category='toutes-les-videos'; $lang='fr'; - if (!empty($this->getInput('catfr'))) - $category=$this->getInput('catfr'); - if (!empty($this->getInput('catde'))) - { $category=$this->getInput('catde'); $lang='de'; } - $input_json = $this->extractVideoset($category, $lang); + switch($this->queriedContext){ + case 'Catégorie (Français)': + $category=$this->getInput('catfr'); + $lang='fr'; + break; + case 'Catégorie (Allemand)': + $category=$this->getInput('catde'); + $lang='de'; + break; + } + + $url = $this->uri.'guide/'.$lang.'/plus7/'.$category; + $input = $this->getContents($url) or die('Could not request ARTE.'); + if(strpos($input, 'categoryVideoSet') !== FALSE){ + $input = explode('categoryVideoSet: ', $input); + $input = explode('}},', $input[1]); + $input = $input[0].'}}'; + }else{ + $input = explode('videoSet: ', $input); + $input = explode('}]},', $input[1]); + $input = $input[0].'}]}'; + } + $input_json = json_decode($input, TRUE); foreach($input_json['videos'] as $element) { $item = array();