aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-03-10 11:10:16 +0100
committerChocobozzz <me@florianbigard.com>2023-03-10 15:45:52 +0100
commit4899138ec5995075c3681ccbd9f6b163fb915991 (patch)
tree285973833829de6c20a0aeb95142a07e839db29f /client/src/app/+videos
parent085aba61c35ad63155a46453dff7752840e82146 (diff)
downloadPeerTube-4899138ec5995075c3681ccbd9f6b163fb915991.tar.gz
PeerTube-4899138ec5995075c3681ccbd9f6b163fb915991.tar.zst
PeerTube-4899138ec5995075c3681ccbd9f6b163fb915991.zip
Add ability for plugins to add metadata
Diffstat (limited to 'client/src/app/+videos')
-rw-r--r--client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html7
-rw-r--r--client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts32
2 files changed, 37 insertions, 2 deletions
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 @@
62 <span i18n class="attribute-label">Duration</span> 62 <span i18n class="attribute-label">Duration</span>
63 <span class="attribute-value">{{ video.duration | myDurationFormatter }}</span> 63 <span class="attribute-value">{{ video.duration | myDurationFormatter }}</span>
64</div> 64</div>
65
66<div class="attribute attribute-plugin" *ngFor="let metadata of pluginMetadata">
67 <span class="attribute-label">{{ metadata.label }}</span>
68
69 <span *ngIf="metadata.value" class="attribute-value">{{ metadata.value }}</span>
70 <span *ngIf="metadata.safeHTML" class="attribute-value" [innerHTML]="metadata.safeHTML"></span>
71</div>
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 @@
1import { Component, Input } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { HooksService } from '@app/core'
2import { VideoDetails } from '@app/shared/shared-main' 3import { VideoDetails } from '@app/shared/shared-main'
3 4
5type PluginMetadata = {
6 label: string
7
8 value?: string
9 safeHTML?: string
10}
11
4@Component({ 12@Component({
5 selector: 'my-video-attributes', 13 selector: 'my-video-attributes',
6 templateUrl: './video-attributes.component.html', 14 templateUrl: './video-attributes.component.html',
7 styleUrls: [ './video-attributes.component.scss' ] 15 styleUrls: [ './video-attributes.component.scss' ]
8}) 16})
9export class VideoAttributesComponent { 17export class VideoAttributesComponent implements OnInit {
10 @Input() video: VideoDetails 18 @Input() video: VideoDetails
11 19
20 pluginMetadata: PluginMetadata[] = []
21
22 constructor (private hooks: HooksService) { }
23
24 async ngOnInit () {
25 this.pluginMetadata = await this.hooks.wrapFunResult(
26 this.buildPluginMetadata.bind(this),
27 { video: this.video },
28 'video-watch',
29 'filter:video-watch.video-plugin-metadata.result'
30 )
31 }
32
12 getVideoHost () { 33 getVideoHost () {
13 return this.video.channel.host 34 return this.video.channel.host
14 } 35 }
@@ -18,4 +39,11 @@ export class VideoAttributesComponent {
18 39
19 return this.video.tags 40 return this.video.tags
20 } 41 }
42
43 // Used for plugin hooks
44 private buildPluginMetadata (_options: {
45 video: VideoDetails
46 }): PluginMetadata[] {
47 return []
48 }
21} 49}