1
0

EZTVBridge.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * RssBridgeEZTV
  4. * Monitor torrent for shows on EZTV
  5. * 2015-01-20
  6. *
  7. * @name EZTV
  8. * @homepage https://eztv.ch/
  9. * @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.
  10. * @maintainer alexAubin
  11. * @update 2014-01-20
  12. * @use1(i="showID1,showID2,...")
  13. */
  14. class EZTVBridge extends BridgeAbstract{
  15. public function collectData(array $param){
  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. // Check for ID provided
  27. if (!isset($param['i']))
  28. $this->returnError('You must provide a list of ID (?i=showID1,showID2,...)', 400);
  29. // Loop on show ids
  30. $showList = explode(",",$param['i']);
  31. foreach($showList as $showID){
  32. // Get show page
  33. $html = file_get_html('https://eztv.ch/shows/'.rawurlencode($showID).'/') or $this->returnError('Could not request EZTV for id "'.$showID.'"', 404);
  34. // Loop on each element that look like an episode entry...
  35. foreach($html->find('.forum_header_border') as $element) {
  36. // Filter entries that are not episode entries
  37. $ep = $element->find('td',1);
  38. if (empty($ep)) continue;
  39. $epinfo = $ep->find('.epinfo',0);
  40. $released = $element->find('td',3);
  41. if (empty($epinfo)) continue;
  42. if (empty($released->plaintext)) continue;
  43. // Filter entries that are older than 1 week
  44. if ($released->plaintext == '&gt;1 week') continue;
  45. // Fill item
  46. $item = new \Item();
  47. $item->uri = 'https://eztv.ch/'.$epinfo->href;
  48. $item->id = $item->uri;
  49. $item->timestamp = makeTimestamp($released->plaintext);
  50. $item->title = $epinfo->plaintext;
  51. $item->content = $epinfo->alt;
  52. if(!empty($item->title))
  53. $this->items[] = $item;
  54. }
  55. }
  56. }
  57. public function getName(){
  58. return 'EZTV';
  59. }
  60. public function getURI(){
  61. return 'https://eztv.ch/';
  62. }
  63. public function getCacheDuration(){
  64. return 3600; // 1 hour
  65. }
  66. }