1
0

MalikiBridge.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. class MalikiBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "mitsukarenai";
  5. $this->name = "Maliki";
  6. $this->uri = "http://www.maliki.com/";
  7. $this->description = "Returns Maliki's newest strips";
  8. $this->update = "2014-05-30";
  9. }
  10. public function collectData(array $param){
  11. $html = file_get_html('http://www.maliki.com/') or $this->returnError('Could not request Maliki.', 404);
  12. $count=0;
  13. $latest=1; $latest_title="";
  14. $latest = $html->find('div.conteneur_page a', 1)->href;
  15. $latest_title = $html->find('div.conteneur_page img', 0)->title;
  16. function MalikiExtractContent($url) {
  17. $html2 = file_get_html($url);
  18. $text = 'http://www.maliki.com/'.$html2->find('img', 0)->src;
  19. $text = '<img alt="" src="'.$text.'"/><br>'.$html2->find('div.imageetnews', 0)->plaintext;
  20. return $text;
  21. }
  22. $item = new \Item();
  23. $item->uri = 'http://www.maliki.com/'.$latest;
  24. $item->title = $latest_title;
  25. $item->timestamp = time();
  26. $item->content = MalikiExtractContent($item->uri);
  27. $this->items[] = $item;
  28. foreach($html->find('div.boite_strip') as $element) {
  29. if(!empty($element->find('a',0)->href) and $count < 3) {
  30. $item = new \Item();
  31. $item->uri = 'http://www.maliki.com/'.$element->find('a',0)->href;
  32. $item->title = $element->find('img',0)->title;
  33. $item->timestamp = strtotime(str_replace('/', '-', $element->find('span.stylepetit', 0)->innertext));
  34. $item->content = MalikiExtractContent($item->uri);
  35. $this->items[] = $item;
  36. $count++;
  37. }
  38. }
  39. }
  40. public function getName(){
  41. return 'Maliki';
  42. }
  43. public function getURI(){
  44. return 'http://www.maliki.com/';
  45. }
  46. public function getCacheDuration(){
  47. return 86400*6; // 6 days
  48. }
  49. }