EZTVBridge.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. class EZTVBridge extends BridgeAbstract {
  3. const MAINTAINER = 'alexAubin';
  4. const NAME = 'EZTV';
  5. const URI = 'https://eztv.ch/';
  6. const DESCRIPTION = 'Returns list of *recent* torrents for a specific show
  7. on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name.';
  8. const PARAMETERS = array( array(
  9. 'i' => array(
  10. 'name' => 'Show ids',
  11. 'exampleValue' => 'showID1,showID2,…',
  12. 'required' => true
  13. )
  14. ));
  15. public function collectData(){
  16. // Make timestamp from relative released time in table
  17. function makeTimestamp($relativeReleaseTime){
  18. $relativeDays = 0;
  19. $relativeHours = 0;
  20. foreach(explode(' ', $relativeReleaseTime) as $relativeTimeElement) {
  21. if(substr($relativeTimeElement, -1) == 'd') $relativeDays = substr($relativeTimeElement, 0, -1);
  22. if(substr($relativeTimeElement, -1) == 'h') $relativeHours = substr($relativeTimeElement, 0, -1);
  23. }
  24. return mktime(date('h') - $relativeHours, 0, 0, date('m'), date('d') - $relativeDays, date('Y'));
  25. }
  26. // Loop on show ids
  27. $showList = explode(',', $this->getInput('i'));
  28. foreach($showList as $showID) {
  29. // Get show page
  30. $html = getSimpleHTMLDOM(self::URI . 'shows/' . rawurlencode($showID) . '/')
  31. or returnServerError('Could not request EZTV for id "' . $showID . '"');
  32. // Loop on each element that look like an episode entry...
  33. foreach($html->find('.forum_header_border') as $element) {
  34. // Filter entries that are not episode entries
  35. $ep = $element->find('td', 1);
  36. if(empty($ep)) continue;
  37. $epinfo = $ep->find('.epinfo', 0);
  38. $released = $element->find('td', 3);
  39. if(empty($epinfo)) continue;
  40. if(empty($released->plaintext)) continue;
  41. // Filter entries that are older than 1 week
  42. if($released->plaintext == '&gt;1 week') continue;
  43. // Fill item
  44. $item = array();
  45. $item['uri'] = self::URI . $epinfo->href;
  46. $item['id'] = $item['uri'];
  47. $item['timestamp'] = makeTimestamp($released->plaintext);
  48. $item['title'] = $epinfo->plaintext;
  49. $item['content'] = $epinfo->alt;
  50. if(isset($item['title']))
  51. $this->items[] = $item;
  52. }
  53. }
  54. }
  55. }