From e1dac3abb3dd44aa2cb81bd7d0b08eae41d44541 Mon Sep 17 00:00:00 2001 From: Mitsukarenai Date: Fri, 30 Oct 2015 11:26:49 +0100 Subject: [PATCH] [Arte] update bridges (new website) - fix #165 --- bridges/Arte7deBridge.php | 85 ++++++++++++++++++--------------------- bridges/Arte7frBridge.php | 85 ++++++++++++++++++--------------------- 2 files changed, 78 insertions(+), 92 deletions(-) diff --git a/bridges/Arte7deBridge.php b/bridges/Arte7deBridge.php index 3075f861..4b4538a7 100644 --- a/bridges/Arte7deBridge.php +++ b/bridges/Arte7deBridge.php @@ -2,64 +2,57 @@ /** * RssBridgeArte7de * Returns images from given page and tags -* 2014-05-25 * * @name Arte +7 DE -* @homepage http://www.arte.tv/guide/de/ +* @homepage http://www.arte.tv/guide/de/plus7 * @description Returns newest videos from ARTE +7 (german) * @maintainer mitsukarenai +* @update 2015-10-30 +* @use1(cat="category") */ class Arte7deBridge extends BridgeAbstract{ public function collectData(array $param){ - $input_json = json_decode(file_get_contents('http://www.arte.tv/guide/de/plus7.json'), TRUE) or $this->returnError('Could not request ARTE.', 404); - - foreach($input_json['videos'] as $element) { + function extractVideoset($category='alle-videos') + { + $url = 'http://www.arte.tv/guide/de/plus7/'.$category; + $input = file_get_contents($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; + } + + $category='alle-videos'; + if (!empty($param['cat'])) + $category=$param['cat']; + $input_json = extractVideoset($category); + + foreach($input_json['videos'] as $element) { $item = new \Item(); $item->uri = $element['url']; - $item->postid = $item->uri; - - $date = $element['airdate_long']; - $date = explode(' ', $date); - $day = (int)$date['1']; - $month=FALSE; - switch ($date['2']) { - case 'Januar': - $month=1;break; - case 'Februar': - $month=2;break; - case 'März': - $month=3;break; - case 'April': - $month=4;break; - case 'Mai': - $month=5;break; - case 'Juni': - $month=6;break; - case 'Juli': - $month=7;break; - case 'August': - $month=8;break; - case 'September': - $month=9;break; - case 'Oktober': - $month=10;break; - case 'November': - $month=11;break; - case 'Dezember': - $month=12;break; - } - $year=(int)date('Y'); - $heure=explode(':', $date['4']); - $hour=(int)$heure['0']; - $minute=(int)$heure['1']; - - - $item->timestamp = mktime($hour, $minute, 0, $month, $day, $year); - $item->thumbnailUri = $element['image_url']; + $item->id = $element['id']; + $hack_broadcast_time = $element['rights_end']; + $hack_broadcast_time = strtok($hack_broadcast_time, 'T'); + $hack_broadcast_time = strtok('T'); + $item->timestamp = strtotime($element['scheduled_on'].'T'.$hack_broadcast_time); + $item->thumbnailUri = $element['thumbnail_url']; $item->title = $element['title']; - $item->content = $element['desc'].'

'.$element['video_channels'].', '.$element['duration'].'min
'; + if (!empty($element['subtitle'])) + $item->title = $element['title'].' | '.$element['subtitle']; + $item->duration = round((int)$element['duration']/60); + $item->content = $element['teaser'].'

'.$item->duration.'min
'; $this->items[] = $item; } } diff --git a/bridges/Arte7frBridge.php b/bridges/Arte7frBridge.php index 4587cd79..95c898e7 100644 --- a/bridges/Arte7frBridge.php +++ b/bridges/Arte7frBridge.php @@ -2,64 +2,57 @@ /** * RssBridgeArte7fr * Returns images from given page and tags -* 2014-05-25 * * @name Arte +7 FR -* @homepage http://www.arte.tv/guide/fr/ +* @homepage http://www.arte.tv/guide/fr/plus7 * @description Returns newest videos from ARTE +7 (french) * @maintainer mitsukarenai +* @update 2015-10-30 +* @use1(cat="category") */ class Arte7frBridge extends BridgeAbstract{ public function collectData(array $param){ - $input_json = json_decode(file_get_contents('http://www.arte.tv/guide/fr/plus7.json'), TRUE) or $this->returnError('Could not request ARTE.', 404); - - foreach($input_json['videos'] as $element) { + function extractVideoset($category='toutes-les-videos') + { + $url = 'http://www.arte.tv/guide/fr/plus7/'.$category; + $input = file_get_contents($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; + } + + $category='toutes-les-videos'; + if (!empty($param['cat'])) + $category=$param['cat']; + $input_json = extractVideoset($category); + + foreach($input_json['videos'] as $element) { $item = new \Item(); $item->uri = $element['url']; - $item->postid = $item->uri; - - $date = $element['airdate_long']; - $date = explode(' ', $date); - $day = (int)$date['1']; - $month=FALSE; - switch ($date['2']) { - case 'janvier': - $month=1;break; - case 'février': - $month=2;break; - case 'mars': - $month=3;break; - case 'avril': - $month=4;break; - case 'mai': - $month=5;break; - case 'juin': - $month=6;break; - case 'juillet': - $month=7;break; - case 'août': - $month=8;break; - case 'septembre': - $month=9;break; - case 'octobre': - $month=10;break; - case 'novembre': - $month=11;break; - case 'décembre': - $month=12;break; - } - $year=(int)date('Y'); - $heure=explode('h', $date['4']); - $hour=(int)$heure['0']; - $minute=(int)$heure['1']; - - - $item->timestamp = mktime($hour, $minute, 0, $month, $day, $year); - $item->thumbnailUri = $element['image_url']; + $item->id = $element['id']; + $hack_broadcast_time = $element['rights_end']; + $hack_broadcast_time = strtok($hack_broadcast_time, 'T'); + $hack_broadcast_time = strtok('T'); + $item->timestamp = strtotime($element['scheduled_on'].'T'.$hack_broadcast_time); + $item->thumbnailUri = $element['thumbnail_url']; $item->title = $element['title']; - $item->content = $element['desc'].'

'.$element['video_channels'].', '.$element['duration'].'min
'; + if (!empty($element['subtitle'])) + $item->title = $element['title'].' | '.$element['subtitle']; + $item->duration = round((int)$element['duration']/60); + $item->content = $element['teaser'].'

'.$item->duration.'min
'; $this->items[] = $item; } }