Add support for Libsyn

Created on 3 March 2023, almost 2 years ago
Updated 27 April 2023, over 1 year ago

Problem/Motivation

We use libsyn to host talking drupal podcast episodes. I am trying to set up libsyn as a custom provider.
When I add an embed link from libysn: `https://oembed.libsyn.com/embed?item_id=26035914`
I get an error `The provided URL does not represent a valid oEmbed resource.`

Steps to reproduce

Enable oembed_providers
Go to custom providers
Add oEmbed provider

  1. Provider URL: https://libsyn.com
  2. Endpoint schemes
  3. https://*.libsyn.com/*
  4. http://*.libsyn.com/*
  5. https://oembed.libsyn.com/*
  6. Endpoint URL
  7. https://oembed.libsyn.com/

I've tried with JSON and discovery checked and off

Go to Buckets and create a new one using the libsyn provider
Create audio media reference on a page using the libsyn provider and source.

Add content and add https://oembed.libsyn.com/embed?item_id=26035914 to the url field.

Here is an embed for an example:
<iframe title="Embed Player" style="border: medium none;" src="https://play.libsyn.com/embed/episode/id/26035914/height/192/theme/modern/size/large/thumbnail/yes/custom-color/87A93A/time-start/00:00:00/playlist-height/200/direction/backward/download/yes" scrolling="no" allowfullscreen="" webkitallowfullscreen="true" mozallowfullscreen="true" oallowfullscreen="true" msallowfullscreen="true" width="100%" height="192"></iframe>

Embedly
https://oembed.libsyn.com/embed?item_id=26035914

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Closed: works as designed

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States nicxvan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States Chris Burge

    Their oEmbed implementation works: https://oembed.libsyn.com/?url=https://oembed.libsyn.com/embed?item_id=26035914

    {
      "version": 1,
      "type": "rich",
      "provider_name": "Libsyn",
      "provider_url": "https://www.libsyn.com",
      "height": 90,
      "width": 600,
      "title": "Talking Drupal #388 - Valhalla Content Hub",
      "description": "Today we are talking about Valhalla Content Hub with Shane Thomas. For show notes visit: www.talkingDrupal.com/388  Topics  Joining Netlify Changes at Gatsby What is a content hub How does that differ from a content repo What is Valhalla How does it work Data stitching with GraphQL Can you massage / normalize data Benefits Privacy Production examples How is it structured Do you have to use Gatsby Integrations with Drupal Timing Cost How to sign up   Resources  Valhalla   Guests Shane Thomas - www.codekarate.com/ @smthomas3  Hosts Nic Laflin - www.nLighteneddevelopment.com @nicxvan John Picozzi - www.epam.com @johnpicozzi Jacob Rockowitz - www.jrockowitz.com @jrockowitz  MOTW  Correspondent Martin Anderson-Clutz - @mandclu Entity Share You configure one site to be the Server that provides the entities, and content types or bundles will be available, and in which languages. ",
      "author_name": "Talking Drupal",
      "author_url": "http://www.talkingdrupal.com",
      "html": "<iframe title=\"Libsyn Player\" style=\"border: none\" src=\"//html5-player.libsyn.com/embed/episode/id/26035914/height/90/theme/custom/thumbnail/yes/direction/forward/render-playlist/no/custom-color/88AA3C/\" height=\"90\" width=\"600\" scrolling=\"no\"  allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>",
      "thumbnail_url": "https://assets.libsyn.com/secure/item/26035914"
    }
    

    What is the 'Provider name' for your custom provider? Based on the response from the provider, it'll need to be 'Libsyn' (case sensitive). See #3298738: Document that provider_name should match the one return by the oEmbed endpoint β†’ for details.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Thank you for replying! I missed your response.

    Using the json response you showed me I attached a screenshot of my config and unfortunately it's still not working, I'm not sure what I am missing.

    I am using this url in the url field of the media entity: https://oembed.libsyn.com/embed?item_id=26035914

    I get the following error: The provided URL does not represent a valid oEmbed resource.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Missed screenshot.

  • πŸ‡ΊπŸ‡ΈUnited States Chris Burge

    See \Drupal\media\OEmbed\ResourceFetcher::createResource():

      protected function createResource(array $data, $url) {
        $data += [
          'title' => NULL,
          'author_name' => NULL,
          'author_url' => NULL,
          'provider_name' => NULL,
          'cache_age' => NULL,
          'thumbnail_url' => NULL,
          'thumbnail_width' => NULL,
          'thumbnail_height' => NULL,
          'width' => NULL,
          'height' => NULL,
          'url' => NULL,
          'html' => NULL,
          'version' => NULL,
        ];
    
        if ($data['version'] !== '1.0') { // <--- HERE
          throw new ResourceException("Resource version must be '1.0'", $url, $data);
        }
    

    Version must be "1.0".

    Now take a look at the response from the provider:

    {
      "version": 1, <---- HERE
      "type": "rich",
      "provider_name": "Libsyn",
      "provider_url": "https://www.libsyn.com",
      "height": 90,
      "width": 600,
    

    Version is "1", not "1.0".

    Now, take a look at https://oembed.com/ at "2.3.4. Response parameters"

    Responses can specify a resource type, such as photo or video. Each type has specific parameters associated with it. The following response parameters are valid for all response types:

    type (required)
         The resource type. Valid values, along with value-specific parameters, are described below.
    version (required)
         The oEmbed version number. This must be 1.0.

    Conclusion: The provider's response is invalid.

  • Status changed to Closed: works as designed over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States Chris Burge

    You could write a pretty simple custom module to change the version from "1" to "1.0".

    my_module.service.yml:

    services:
      media.oembed.resource_fetcher:
        class: Drupal\my_module\OEmbed\ResourceFetcher
        arguments: ['@http_client', '@media.oembed.provider_repository', '@cache.default']
    

    my_module/src/OEmbed/ResourceFetcher.php:

    
    namespace Drupal\my_module\OEmbed;
    
    use Drupal\media\OEmbed\ResourceFetcher as CoreResourceFetcher;
    
    /**
     * Fetches and caches oEmbed resources.
     */
    class ResourceFetcher extends CoreResourceFetcher {
    
      /**
       * {@inheritdoc}
       */
      protected function createResource(array $data, $url) {
        if ($data'provider_name' == 'Libsyn') {
          $data['version'] = '1.0';
        }
        return parent::createResource($data, $url)
      }
    
    }
    
    
Production build 0.71.5 2024