Arte7Bridge.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. class Arte7Bridge extends BridgeAbstract {
  3. const MAINTAINER = 'mitsukarenai';
  4. const NAME = 'Arte +7';
  5. const URI = 'https://www.arte.tv/';
  6. const CACHE_TIMEOUT = 1800; // 30min
  7. const DESCRIPTION = 'Returns newest videos from ARTE +7';
  8. const API_TOKEN = 'Nzc1Yjc1ZjJkYjk1NWFhN2I2MWEwMmRlMzAzNjI5NmU3NWU3ODg4ODJjOWMxNTMxYzEzZGRjYjg2ZGE4MmIwOA';
  9. const PARAMETERS = array(
  10. 'Catégorie (Français)' => array(
  11. 'catfr' => array(
  12. 'type' => 'list',
  13. 'name' => 'Catégorie',
  14. 'values' => array(
  15. 'Toutes les vidéos (français)' => null,
  16. 'Actu & société' => 'ACT',
  17. 'Séries & fiction' => 'SER',
  18. 'Cinéma' => 'CIN',
  19. 'Arts & spectacles classiques' => 'ARS',
  20. 'Culture pop' => 'CPO',
  21. 'Découverte' => 'DEC',
  22. 'Histoire' => 'HIST',
  23. 'Science' => 'SCI',
  24. 'Autre' => 'AUT'
  25. )
  26. )
  27. ),
  28. 'Catégorie (Allemand)' => array(
  29. 'catde' => array(
  30. 'type' => 'list',
  31. 'name' => 'Catégorie',
  32. 'values' => array(
  33. 'Alle Videos (deutsch)' => null,
  34. 'Aktuelles & Gesellschaft' => 'ACT',
  35. 'Fernsehfilme & Serien' => 'SER',
  36. 'Kino' => 'CIN',
  37. 'Kunst & Kultur' => 'ARS',
  38. 'Popkultur & Alternativ' => 'CPO',
  39. 'Entdeckung' => 'DEC',
  40. 'Geschichte' => 'HIST',
  41. 'Wissenschaft' => 'SCI',
  42. 'Sonstiges' => 'AUT'
  43. )
  44. )
  45. )
  46. );
  47. public function collectData(){
  48. switch($this->queriedContext) {
  49. case 'Catégorie (Français)':
  50. $category = $this->getInput('catfr');
  51. $lang = 'fr';
  52. break;
  53. case 'Catégorie (Allemand)':
  54. $category = $this->getInput('catde');
  55. $lang = 'de';
  56. break;
  57. }
  58. $url = 'https://api.arte.tv/api/opa/v3/videos?sort=-lastModified&limit=10&language='
  59. . $lang
  60. . ($category != null ? '&category.code=' . $category : '');
  61. $header = array(
  62. 'Authorization: Bearer ' . self::API_TOKEN
  63. );
  64. $input = getContents($url, $header) or die('Could not request ARTE.');
  65. $input_json = json_decode($input, true);
  66. foreach($input_json['videos'] as $element) {
  67. $item = array();
  68. $item['uri'] = $element['url'];
  69. $item['id'] = $element['id'];
  70. $item['timestamp'] = strtotime($element['videoRightsBegin']);
  71. $item['title'] = $element['title'];
  72. if(!empty($element['subtitle']))
  73. $item['title'] = $element['title'] . ' | ' . $element['subtitle'];
  74. $item['duration'] = round((int)$element['durationSeconds'] / 60);
  75. $item['content'] = $element['teaserText']
  76. . '<br><br>'
  77. . $item['duration']
  78. . 'min<br><a href="'
  79. . $item['uri']
  80. . '"><img src="'
  81. . $element['mainImage']['url']
  82. . '" /></a>';
  83. $this->items[] = $item;
  84. }
  85. }
  86. }