EZTVBridge.php 2.7 KB

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