1

We have a Drupal 9 site that is using Media's Remote Video for YouTube videos. We need to pull the YouTube video's description but I do not see any way to accomplish this. The end result will be to display the YouTube description in a View.

EDIT: The screenshot shows that there is no "description" field in the Remote Video's field mapping.enter image description here

1
  • I think you can accomplish this with YouTube API somehow, maybe in a custom field formatter extending the default remote video formatter stackoverflow.com/a/5155064/2199525
    – leymannx
    Commented Nov 2, 2021 at 18:21

1 Answer 1

2

Media has the ability to map remote media metadata to fields on the media entity. To do this, create a media type whose Media Source is remote video, hit save, then add your fields. Edit the media type again, then map the metadata to the fields you created.

When you create a media entity of that type, Drupal will grab the metadata from the source (e.g. YouTube, Vimeo, etc.) and then map the metadata to the fields you configured for them. There is an outstanding issue to refresh this metadata after the entity is created, as currently it only does this mapping on creation.

Also, if I remember correctly, this only works on public videos. The video cannot be unlisted, private, age-restricted, or worse, 404. Otherwise, this mechanism will fail getting the metadata.

2
  • Thank you for the information. I had already actually read those instructions. The problem is that there isn't a description field in the metadata mapping. I added a screenshot to my original post to show where's I'm referring to. TI tried searching but could not find any posts where this issue is even mentioned but it seems like there should be a way to pull in a remote YouTube videos's description into Media. Commented Nov 2, 2021 at 18:44
  • @quantumized you can create a new plugin @MediaSource plugin or override the definition of core/modules/media/src/Plugin/media/Source/OEmbed.php plugin and attempt grabbing a description from the returned resource (see getMetadata()). Currently, it has a fixed list of attributes mapped (see getMetadataAttributes()). The availability of description in this API will depend on whether the remote resource returns one.
    – Joseph
    Commented Nov 2, 2021 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.