-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtransform.ts
More file actions
57 lines (54 loc) · 1.88 KB
/
transform.ts
File metadata and controls
57 lines (54 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import * as plexTypes from '../../plex/types';
import {
PseuplexMetadataIDString,
PseuplexMetadataItem,
PseuplexMetadataSource,
PseuplexMetadataTransformOptions,
PseuplexPartialMetadataIDString,
PseuplexRequestContext,
stringifyPseuplexMetadataID,
stringifyPartialPseuplexMetadataID,
stringifyPseuplexMetadataKeyFromIDString
} from '../../pseuplex';
import { combinePathSegments } from '../../utils/misc';
export const partialMetadataIdFromTemplateItem = (item: any): PseuplexPartialMetadataIDString => {
// TODO create a partial metadata ID from an item from your source
return stringifyPartialPseuplexMetadataID({
directory: item.type,
id: item.id,
});
};
export const fullMetadataIdFromTemplateItem = (item: any, opts?: {asUrl?: boolean}): PseuplexMetadataIDString => {
// TODO create a full metadata ID from an item from your source
return stringifyPseuplexMetadataID({
isURL: opts?.asUrl,
source: 'template', //PseuplexMetadataSource.Template,
directory: item.type,
id: item.id,
});
};
export const templateItemToPlexMetadata = (item: any, context: PseuplexRequestContext, options: PseuplexMetadataTransformOptions): PseuplexMetadataItem => {
// TODO convert your source's metadata to plex metadata
const partialMetadataId = partialMetadataIdFromTemplateItem(item);
const fullMetadataId = fullMetadataIdFromTemplateItem(item, {asUrl:false});
return {
// guid: fullMetadataIdFromTemplateItem(item, {asUrl:true}),
key: stringifyPseuplexMetadataKeyFromIDString(fullMetadataId),
ratingKey: fullMetadataId,
type: plexTypes.PlexMediaItemType.Movie,
//slug: item.slug,
title: item.name,
art: item.backdropArtUrl,
thumb: item.thumbUrl,
tagline: item.shortDescription,
summary: item.description,
year: item.year,
Pseuplex: {
isOnServer: false,
unavailable: true,
metadataIds: {
['template'/*PseuplexMetadataSource.Template*/]: partialMetadataId
}
},
};
};