1
0
Fork 0
forked from blallo/rss-bridge

[Arte7bridge] code simplification

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-28 11:50:01 +02:00
parent fb05976fa6
commit ff5ac1659f

View file

@ -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(){ public function collectData(){
$category='toutes-les-videos'; $lang='fr'; switch($this->queriedContext){
if (!empty($this->getInput('catfr'))) case 'Catégorie (Français)':
$category=$this->getInput('catfr'); $category=$this->getInput('catfr');
if (!empty($this->getInput('catde'))) $lang='fr';
{ $category=$this->getInput('catde'); $lang='de'; } break;
$input_json = $this->extractVideoset($category, $lang); 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) { foreach($input_json['videos'] as $element) {
$item = array(); $item = array();