Skip to content

A self-hosted media server and file management system

feat: mal-sync json metadata block

aminnausinf22755ed50ac
diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vue
index 79f793e3..92f6fa37 100755
--- a/resources/js/components/video/VideoPlayer.vue
+++ b/resources/js/components/video/VideoPlayer.vue
@@ -452,6 +452,7 @@ const initVideoPlayer = async () => {
metadataId.value = stateVideo.value?.metadata ? stateVideo.value?.metadata.id : NaN;
handleInitMediaSession();
+ addJsonLd();
if (!isFullScreen.value && !isAutoPlay.value) {
onPlayerPause();
@@ -1169,6 +1170,43 @@ const stopScrub = () => {
isScrubbing.value = false;
};
+//#region Experiments
+
+const addJsonLd = () => {
+ const existingScript = document.getElementById('mal-sync-jsonld');
+ if (existingScript) {
+ existingScript.remove();
+ }
+
+ if (stateVideo.value.metadata?.media_type === MediaType.AUDIO) return;
+
+ const script = document.createElement('script');
+ script.id = 'mal-sync-jsonld';
+ script.type = 'application/ld+json';
+
+ const jsonLd = {
+ '@context': 'https://schema.org',
+ '@type': 'TVEpisode',
+ partOfSeason: {
+ '@type': 'TVSeason',
+ seasonNumber: stateVideo.value.season ?? 1,
+ partOfSeries: {
+ '@type': 'TVSeries',
+ name: stateFolder.value.title,
+ },
+ },
+ episodeNumber: stateVideo.value.episode,
+ name: `Episode ${stateVideo.value.episode}`,
+ };
+
+ script.textContent = JSON.stringify(jsonLd);
+ document.head.appendChild(script);
+
+ console.log(jsonLd);
+};
+
+//#endregion
+
//#region Hooks
provide('player', player);