Score:1

Is there a way to pull the 'description' metadata from Media's Remote Videos?

ng flag

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

leymannx avatar
ne flag
I think you can accomplish this with YouTube API somehow, maybe in a custom field formatter extending the default remote video formatter https://stackoverflow.com/a/5155064/2199525
Score:2
in flag

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.

quantumized avatar
ng flag
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.
in flag
@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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.