LesJoiesDuCodeBridge.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. class LesJoiesDuCodeBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "superbaillot.net";
  5. $this->name = "Les Joies Du Code";
  6. $this->uri = "http://lesjoiesducode.fr/";
  7. $this->description = "LesJoiesDuCode";
  8. $this->update = "04/02/2015";
  9. }
  10. public function collectData(array $param){
  11. $html = $this->file_get_html('http://lesjoiesducode.fr/') or $this->returnError('Could not request LesJoiesDuCode.', 404);
  12. foreach($html->find('div.blog-post') as $element) {
  13. $item = new Item();
  14. $temp = $element->find('h1 a', 0);
  15. $titre = html_entity_decode($temp->innertext);
  16. $url = $temp->href;
  17. $temp = $element->find('div.blog-post-content', 0);
  18. // retrieve .gif instead of static .jpg
  19. $images = $temp->find('p img');
  20. foreach($images as $image){
  21. $img_src = str_replace(".jpg",".gif",$image->src);
  22. $image->src = $img_src;
  23. }
  24. $content = $temp->innertext;
  25. $auteur = $temp->find('i', 0);
  26. $pos = strpos($auteur->innertext, "by");
  27. if($pos > 0)
  28. {
  29. $auteur = trim(str_replace("*/", "", substr($auteur->innertext, ($pos + 2))));
  30. $item->name = $auteur;
  31. }
  32. $item->content .= trim($content);
  33. $item->uri = $url;
  34. $item->title = trim($titre);
  35. $this->items[] = $item;
  36. }
  37. }
  38. public function getName(){
  39. return 'Les Joies Du Code';
  40. }
  41. public function getURI(){
  42. return 'http://lesjoiesducode.fr/';
  43. }
  44. public function getCacheDuration(){
  45. return 7200; // 2h hours
  46. }
  47. public function getDescription(){
  48. return "Les Joies Du Code via rss-bridge";
  49. }
  50. }
  51. ?>