Browse Source

Report de r119147 : version 2.1.1 : nouveau provider arte.tv

on doit pas mal fourber car arte ne met pas oembed en avant, mais au final on y arrive :)

sur une suggestion de francky https://contrib.spip.net/oEmbed-4407#comment503461
Author: bruno@eliaz.fr
Date: 2019-12-19 22:29:24 +0100 (Jeu, 19 déc 2019)
svn/root/oembed
cedric@yterium.com 2 years ago
parent
commit
c0860a395b
  1. 2
      .gitattributes
  2. 1
      inc/oembed.php
  3. 43
      oembed/input/posttraite_api_arte_tv.php
  4. 19
      oembed/input/pretraite_api_arte_tv.php
  5. 2
      paquet.xml

2
.gitattributes

@ -30,6 +30,7 @@ modeles/oembed_rich.html -text
modeles/oembed_video.html -text
modeles/text_oembed.html -text
modeles/toot.html -text
oembed/input/posttraite_api_arte_tv.php -text
oembed/input/posttraite_facebook_video.php -text
oembed/input/posttraite_huffduffer_rich.php -text
oembed/input/posttraite_instagram_rich.php -text
@ -43,6 +44,7 @@ oembed/input/posttraite_slideshare_rich.php -text
oembed/input/posttraite_soundcloud_rich.php -text
oembed/input/posttraite_twitter.php -text
oembed/input/posttraite_youtube_video.php -text
oembed/input/pretraite_api_arte_tv.php -text
oembed/input/pretraite_publish_twitter_com.php -text
oembed/input/pretraite_www_youtube_com.php -text
oembed/input/vignettes/soundcloud.png -text

1
inc/oembed.php

@ -81,6 +81,7 @@ function oembed_lister_providers() {
'http://www.facebook.com/questions/*' => 'https://www.facebook.com/plugins/post/oembed.json/',
'http://www.facebook.com/notes/*' => 'https://www.facebook.com/plugins/post/oembed.json/',
'http://www.facebook.com/*/videos/*' => 'https://www.facebook.com/plugins/video/oembed.json/',
'http://*.arte.tv/*/videos/*' => 'https://api.arte.tv/api/player/v1/oembed/',
'http://egliseinfo.catholique.fr/*' => 'http://egliseinfo.catholique.fr/api/oembed',

43
oembed/input/posttraite_api_arte_tv.php

@ -0,0 +1,43 @@
<?php
/**
* Plugin oEmbed
* Licence GPL3
*
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
function oembed_input_posttraite_api_arte_tv_dist($data) {
// récupérer l'image dans la meta og:image de la page source
if ($res = recuperer_url($data['oembed_url_source'], array('taille_max'=>16384))
and $res['page']) {
$metas = extraire_balises($res['page'], 'meta');
$src = '';
$has_image = false;
foreach ($metas as $meta) {
$property = extraire_attribut($meta, 'property');
if ($property == 'og:image') {
$src = extraire_attribut($meta, 'content');
}
if ($src) {
break;
}
}
if ($src) {
$data['thumbnail_url'] = $src;
}
}
// nettoyer l'iframe envoyée par arte.tv & modifier son src pour utiliser la v5 du player qui prend en charge l'autoplay
if ($iframe = extraire_balise($data['html'], 'iframe')) {
$iframe_cor = vider_attribut($iframe, 'height');
$iframe_cor = vider_attribut($iframe_cor, 'scrolling');
$iframe_cor = vider_attribut($iframe_cor, 'style');
$iframe_cor = inserer_attribut($iframe_cor, 'src', str_replace('/v3/', '/v5/', extraire_attribut($iframe_cor, 'src')));
$data['html'] = str_replace($data['html'], $iframe, $iframe_cor);
}
return $data;
}

19
oembed/input/pretraite_api_arte_tv.php

@ -0,0 +1,19 @@
<?php
/**
* Plugin oEmbed
* Licence GPL3
*
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
function oembed_input_pretraite_api_arte_tv_dist($data_url, $args) {
if (preg_match(',(?:www\\.)?arte.tv/(\\w{2})/videos/([a-zA-Z0-9\\-]+)/.*?,', $args['url'], $regs)) {
$data_url = $args['endpoint'] . $regs[1] . '/' . $regs[2];
}
return $data_url;
}

2
paquet.xml

@ -1,7 +1,7 @@
<paquet
prefix="oembed"
categorie="multimedia"
version="2.1.0"
version="2.1.1"
etat="stable"
compatibilite="[3.0.0;3.3.*]"
logo="prive/themes/spip/images/oembed-64.png"

Loading…
Cancel
Save