EZTVBridge.php 2.5 KB

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