seenthis / seenthis_squelettes

plugin "squelettes" de seenthis
11 stars 6 forks source link

prise en charge des embed depuis france culture #259

Closed brunob closed 3 years ago

brunob commented 3 years ago

ref https://seenthis.net/messages/899380#message899589

brunob commented 3 years ago

Bon voilà, c'est pas super clean mais ça fonctionne :)

diff --git a/autoembed.php b/autoembed.php
index a3440a5..eb89f0c 100644
--- a/autoembed.php
+++ b/autoembed.php
@@ -65,6 +65,18 @@ function embed_url($url) {
                }
            }
        }
+       else if (preg_match(",^https?\://(www\.)?franceculture\.fr/emissions/,i", $url)) {
+           if ($page = file_get_contents($url)) {
+               if (preg_match('/"contentUrl": "([^"]+)",/s', $page, $i)) {
+                   $mp3 = $i[1];
+                   if (preg_match(',<meta property="og:image" content="(.*)",Uims', $page, $i1)) {
+                       $img = $i1[1];
+                   }
+                   $html = "<div class='audio'><audio controls><source src='$mp3' rel='enclosure'></audio></div>";
+                   if ($html) $code_ae = "<img src='$img' alt='' style='max-width: none; width: 99%; height: auto'/><div class='oembed-container'>$html</div>";
+               }
+           }
+       }
        else if (preg_match("/^http\:\/\/(www\.)?pastebin\.com\/(.*)/i", $url, $regs)) {
            $val = $regs[2];

Et ça donne ça :

Capture d’écran 2021-02-02 à 10 16 44

brunob commented 3 years ago

Et hop https://git.spip.net/spip-contrib-extensions/seenthis_autoembed/commit/1dee13ed1abd06b0e5f314df09001c9d31e1263a on ferme.