From 4265d90b0061399e23b816e3880ee1be47ead96f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 10 Mar 2023 11:10:16 +0100 Subject: Add ability for plugins to add metadata --- .../metadata/video-attributes.component.html | 7 +++++ .../shared/metadata/video-attributes.component.ts | 32 ++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'client/src/app/+videos') diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html index 52ad1999d..0aa707666 100644 --- a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html +++ b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html @@ -62,3 +62,10 @@ Duration {{ video.duration | myDurationFormatter }} + +
+ {{ metadata.label }} + + {{ metadata.value }} + +
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts index b8f564c4c..ebfb42711 100644 --- a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts +++ b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts @@ -1,14 +1,35 @@ -import { Component, Input } from '@angular/core' +import { Component, Input, OnInit } from '@angular/core' +import { HooksService } from '@app/core' import { VideoDetails } from '@app/shared/shared-main' +type PluginMetadata = { + label: string + + value?: string + safeHTML?: string +} + @Component({ selector: 'my-video-attributes', templateUrl: './video-attributes.component.html', styleUrls: [ './video-attributes.component.scss' ] }) -export class VideoAttributesComponent { +export class VideoAttributesComponent implements OnInit { @Input() video: VideoDetails + pluginMetadata: PluginMetadata[] = [] + + constructor (private hooks: HooksService) { } + + async ngOnInit () { + this.pluginMetadata = await this.hooks.wrapFunResult( + this.buildPluginMetadata.bind(this), + { video: this.video }, + 'video-watch', + 'filter:video-watch.video-plugin-metadata.result' + ) + } + getVideoHost () { return this.video.channel.host } @@ -18,4 +39,11 @@ export class VideoAttributesComponent { return this.video.tags } + + // Used for plugin hooks + private buildPluginMetadata (_options: { + video: VideoDetails + }): PluginMetadata[] { + return [] + } } -- cgit v1.2.3