ZoneTelechargementBridge.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. class ZoneTelechargementBridge extends BridgeAbstract {
  3. public function loadMetadatas() {
  4. $this->maintainer = 'ORelio';
  5. $this->name = $this->getName();
  6. $this->uri = $this->getURI();
  7. $this->description = 'RSS proxy returning the newest releases.<br />You may specify a category found in RSS URLs, else main feed is selected.';
  8. $this->update = "2016-03-16";
  9. $this->parameters[] =
  10. '[
  11. {
  12. "name" : "Category",
  13. "identifier" : "category"
  14. }
  15. ]';
  16. }
  17. public function collectData(array $param) {
  18. function StripCDATA($string) {
  19. $string = str_replace('<![CDATA[', '', $string);
  20. $string = str_replace(']]>', '', $string);
  21. return $string;
  22. }
  23. $category = '/';
  24. if (!empty($param['category']))
  25. $category = '/'.$param['category'].'/';
  26. $url = $this->getURI().$category.'rss.xml';
  27. $html = $this->file_get_html($url) or $this->returnError('Could not request Zone Telechargement: '.$url, 500);
  28. foreach($html->find('item') as $element) {
  29. $item = new \Item();
  30. $item->title = $element->find('title', 0)->plaintext;
  31. $item->uri = str_replace('http://', 'https://', $element->find('guid', 0)->plaintext);
  32. $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
  33. $item->content = StripCDATA($element->find('description', 0)->innertext);
  34. $this->items[] = $item;
  35. $limit++;
  36. }
  37. }
  38. public function getName() {
  39. return 'Zone Telechargement Bridge';
  40. }
  41. public function getURI() {
  42. return 'https://www.zone-telechargement.com/';
  43. }
  44. public function getCacheDuration() {
  45. return 3600;
  46. }
  47. }