Mosaic embed youtube broke - noembed.com

Recently, trying to embed youtube videos in mosaic has broken. It's due to Youtube changing their api slightly and noembed.com has not been updated with fixes.

I'm not confident that noembed.com will be maintained.
Note Future of this service · Issue #114 · leedo/noembed · GitHub also, where noembed seems to be moving under new maintenance.

Any thoughts on how to fix this in Mosaic? I'm not keen on relying on a 3rd party site to figure out embed codes for us, especially if it's maintenance has gone away. I'm not keen on rewriting all this perl into a plone package either. Maybe plone.org can host a noembed fork? What's the best way out of this one?

I use a custom fragment and that works:
If it is OK to paste all the iframe code from youtube: view/data/iframe is the complete embed code.
The CSS is to make it responsive, so I set the height (as percent of width) in the settings.

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
    xmlns:tal="http://xml.zope.org/namespaces/tal"
    xmlns:metal="http://xml.zope.org/namespaces/metal"
    xmlns:i18n="http://xml.zope.org/namespaces/i18n"
    lang="en"
    i18n:domain="medialog.dutchestheme">

  <div class="videoWrapper disabled-${view/data/disabled|None}"
    tal:condition="view/editmode|None">
      <div tal:replace="structure view/data/iframe"/>

  <style>
  .videoWrapper {
  	position: relative;
  	padding-bottom: ${view/data/height|None}%; /* 16:9 */
  	padding-top: 0;
  	height: 0;
  }
  .videoWrapper iframe {
  	position: absolute;
  	top: 0;
  	left: 0;
  	width: 100%;
  	height: 100%;
  }

  </style>
  </div>
</html>

Update: here is the XML

<model xmlns:form="http://namespaces.plone.org/supermodel/form"
  xmlns:indexer="http://namespaces.plone.org/supermodel/indexer"
  xmlns:marshal="http://namespaces.plone.org/supermodel/marshal"
  xmlns:security="http://namespaces.plone.org/supermodel/security"
  xmlns:users="http://namespaces.plone.org/supermodel/users"
  xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
  <field name="disabled" type="zope.schema.Bool">
      <required>false</required>
      <title>Hide fragment</title>
      <description>Click here to hide fragment</description>
  </field>
  <field name="iframe" type="zope.schema.Text">
    <description/>
    <required>True</required>
    <default></default>
    <title>Complete iframe code from youtube</title>
  </field>
  <field name="height" type="zope.schema.Float">
    <description>Divide height by width. 16:9 (9/16) = 56.25</description>
    <required>True</required>
    <title>Height (ratio) in percent</title>
    <default>56.25</default>
  </field>
  </schema>
</model>

and the py

def editmode(self):
form = self.request.form
if  '_layouteditor' in form:
    return True
if  'disabled' in self.data:
    return self.data['disabled']  == False
return True
1 Like

this is a good workaround, but I still am concerned that "core mosaic" (can I call it that?) is broken as long as noembed.com is broken. Insert->Media->Embed will not do youtube, and I think that's a big feature of mosaic.

Ok, it's in plone.app.standardtiles . I'd like to raise the question - should this package really depend on the proper functioning of noembed.com ? That site seems to be unmaintained.

I never use the standard embed, since it is not responsive..

That said: I did a test on a site that I am working on, and the standard approach works for me.

By standard approach, I mean

  1. In tinyMCE, select "insert media"
  2. Paste the Youtube Url.
  3. Save
  4. Reload (view) page

I noticed the same issue 2 days ago, was still investigating myself. At first only a few URL's/video's would break at noembed.com's api and return 503, but others kept working fine. (You can test at https://noembed/com/demo .

Also in my case some recent vidoes but also older ones (> 2 yeers) from a customers channel would randomly break and others still worked. With one video there was even a variation in it if you use youtu.be or youtube.com in the request URL to the service :-S . But it seems to deteriorate now with more and more videos becoming unavailable.

Another observation:
I customised/extended the default embed tile with some styling options and I also did some rewrites on the url to youtube-nocookie.com.

But now that I'm debugging my code tile that does this it seems 100% broken because I was depending on a url key being returned in the json response from noembed.com. It's no longer there in the answer and it's also not in the oEmbed answer I get directly from Youtube's oembed api. But I have no clue if noembed was adding this before or if Youtube changed this and noembed was only passing it along.

Fortunately in my project this extended Embed tile was already relabeled to a 'youtube tile', so I don't need the provider choosing and will query https://www.youtube.com/ directly.

I remember reading somewhere in november or december that Youtube is planning on removing the https://www.youtube-nocookie.com option alltogether in the near future: take it with tracking/advertising cookies or host your video's somewhere else. :-/

Maybe, but on the other hand it is quite weird (from a UI point of view) that there is a (Media) tile to insert video, but no tile to insert an image.

Inserting them from the same place (TinyMCE) is as logic (I think).

Alternatively, you could make a theme fragment (or tile) just for youtube and put all the 'iframe stuff' inside the template and replace only the url.

1 Like

I am sorry for this :frowning:

NOEMBED_ENDPOINT was always a module global in plone.app.standardtiles/embed.py at master · plone/plone.app.standardtiles · GitHub so that it could be customized in policy package to point to local deployment, but of course that was never documented anywhere. Also, an environment variable could have been better choice. Module globals just were a convention back then.

Also, there was no obvious easy-to-use alternative, because available libraries were generic oEmbed libraries requiring some custom configuration for each supported service.

Fix for this particular Youtube issue is here Fix YouTube provider to use https instead of http by datakurre · Pull Request #5 · noembed/noembed · GitHub

With a little bit of love that tile could also support maxwidth and maxheight options supported by noembed.

1 Like

Some has done it GitHub - iamcal/oembed: The oEmbed Spec

Would anyone be able to test and help to finish this Replace dependency on noembed with python-oembed and list of providers by datakurre · Pull Request #110 · plone/plone.app.standardtiles · GitHub ?

The branch would

2 Likes

Hi Asko. No reason to feel guily about this. I was always aware of this feature and dependency on noembed, but too lazy to host our separate noembed.com service.

I've debugged this issue quite a bit this week to see if I could find a pattern and I'm not so sure if the https is the only reason for the breakage. I've tested quite a bit of video's on different channels and for some noembed.com breaks and for others the service works flawlessly. I'm also uncertain if the still working lookups (80%?) I counted wored because of caching of still succesful responses, then I would have expected to slowly see more and more queries fail.

Maybe we should/could host a noembed.com copy on one of the Plone Foundation managed servers?

1 Like

Noembed does have memcached support in its code. (And Plone uses ram.cache with just URL as its cache key.)

Plone Foundation Code of Conduct