From d8bed9aa7512b26b8210b6fe36f7a2d2faed7943 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 20 Jan 2015 17:40:30 +0100 Subject: [PATCH] Adding bridge for EZTV --- bridges/EZTVBridge.php | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 bridges/EZTVBridge.php diff --git a/bridges/EZTVBridge.php b/bridges/EZTVBridge.php new file mode 100644 index 00000000..3f66ea40 --- /dev/null +++ b/bridges/EZTVBridge.php @@ -0,0 +1,81 @@ +returnError('You must provide a list of ID (?i=showID1,showID2,...)', 400); + + // Loop on show ids + $showList = explode(",",$param['i']); + foreach($showList as $showID){ + + // Get show page + $html = file_get_html('https://eztv.ch/shows/'.rawurlencode($showID).'/') or $this->returnError('Could not request EZTV for id "'.$showID.'"', 404); + + // Loop on each element that look like an episode entry... + foreach($html->find('.forum_header_border') as $element) { + + // Filter entries that are not episode entries + $ep = $element->find('td',1); + if (empty($ep)) continue; + $epinfo = $ep->find('.epinfo',0); + $released = $element->find('td',3); + if (empty($epinfo)) continue; + if (empty($released->plaintext)) continue; + + // Filter entries that are older than 1 week + if ($released->plaintext == '>1 week') continue; + + // Fill item + $item = new \Item(); + $item->uri = 'https://eztv.ch/'.$epinfo->href; + $item->id = $item->uri; + $item->timestamp = makeTimestamp($released->plaintext); + $item->title = $epinfo->plaintext; + $item->content = $epinfo->alt; + if(!empty($item->title)) + $this->items[] = $item; + } + } + } + + public function getName(){ + return 'EZTV'; + } + + public function getURI(){ + return 'https://eztv.ch/'; + } + + public function getCacheDuration(){ + return 3600; // 1 hour + } +}