2015-01-20 17:40:30 +01:00
< ? php
class EZTVBridge extends BridgeAbstract {
2016-08-27 21:03:26 +02:00
public $maintainer = " alexAubin " ;
public $name = " EZTV " ;
public $uri = " https://eztv.ch/ " ;
public $description = " Returns list of *recent* torrents for a specific show on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name. " ;
2015-11-05 16:50:18 +01:00
2016-08-27 21:03:26 +02:00
public $parameters = array ( array (
'i' => array (
2016-08-22 01:25:56 +02:00
'name' => 'Show ids' ,
'exampleValue' => 'showID1,showID2,…' ,
'required' => true
2016-08-27 21:03:26 +02:00
)
));
2015-11-05 16:50:18 +01:00
2016-08-25 01:24:53 +02:00
public function collectData (){
2015-01-20 17:40:30 +01:00
// Make timestamp from relative released time in table
function makeTimestamp ( $relativeReleaseTime ){
$relativeDays = 0 ;
$relativeHours = 0 ;
foreach ( explode ( " " , $relativeReleaseTime ) as $relativeTimeElement ) {
if ( substr ( $relativeTimeElement , - 1 ) == " d " ) $relativeDays = substr ( $relativeTimeElement , 0 , - 1 );
if ( substr ( $relativeTimeElement , - 1 ) == " h " ) $relativeHours = substr ( $relativeTimeElement , 0 , - 1 );
}
return mktime ( date ( 'h' ) - $relativeHours , 0 , 0 , date ( 'm' ), date ( 'd' ) - $relativeDays , date ( 'Y' ));
}
// Loop on show ids
2016-08-28 01:25:33 +02:00
$showList = explode ( " , " , $this -> getInput ( 'i' ));
2015-01-20 17:40:30 +01:00
foreach ( $showList as $showID ){
// Get show page
2016-08-28 14:08:12 +02:00
$html = $this -> getSimpleHTMLDOM ( $this -> uri . 'shows/' . rawurlencode ( $showID ) . '/' )
or $this -> returnServerError ( 'Could not request EZTV for id "' . $showID . '"' );
2015-01-20 17:40:30 +01:00
// 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
2016-08-22 18:55:59 +02:00
$item = array ();
2016-08-28 14:08:12 +02:00
$item [ 'uri' ] = $this -> uri . $epinfo -> href ;
2016-08-22 18:55:59 +02:00
$item [ 'id' ] = $item [ 'uri' ];
$item [ 'timestamp' ] = makeTimestamp ( $released -> plaintext );
$item [ 'title' ] = $epinfo -> plaintext ;
$item [ 'content' ] = $epinfo -> alt ;
if ( isset ( $item [ 'title' ]))
2015-01-20 17:40:30 +01:00
$this -> items [] = $item ;
}
}
}
}