forked from HaveAGitGat/Tdarr_Plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
105 lines (100 loc) · 2.61 KB
/
index.ts
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import {
IpluginDetails,
IpluginInputArgs,
IpluginOutputArgs,
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = (): IpluginDetails => ({
name: 'Check DoVi Profile',
description: 'Check Dolby Vision profile of video',
style: {
borderColor: 'orange',
},
tags: 'video',
isStartPlugin: false,
pType: '',
requiresVersion: '2.11.01',
sidebarPosition: -1,
icon: 'faQuestion',
inputs: [],
outputs: [
{
number: 1,
tooltip: 'Dolby Vision Profile 4',
},
{
number: 2,
tooltip: 'Dolby Vision Profile 5',
},
{
number: 3,
tooltip: 'Dolby Vision Profile 7 with 1 stream',
},
{
number: 4,
tooltip: 'Dolby Vision Profile 7 with 2 streams',
},
{
number: 5,
tooltip: 'Dolby Vision Profile 8',
},
],
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
const lib = require('../../../../../methods/lib')();
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details);
let outputNum = -1;
let vsCount = 0;
if (args.inputFileObj?.mediaInfo?.track) {
args.inputFileObj.mediaInfo.track.forEach((stream) => {
if (stream['@type'].toLowerCase() === 'general') {
vsCount = +stream.VideoCount;
} else if (stream['@type'].toLowerCase() === 'video') {
if (stream.hasOwnProperty('HDR_Format_Profile')) {
const r = /dvhe\.0(.).*/;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const m = r.exec(stream.HDR_Format_Profile);
if (m) {
switch (m[1]) {
case '4':
outputNum = 1;
break;
case '5':
outputNum = 2;
break;
case '7':
if (vsCount === 1) {
outputNum = 3;
} else {
outputNum = 4;
}
break;
case '8':
outputNum = 5;
break;
default:
break;
}
}
}
}
});
} else {
throw new Error('Failed to identify DV profile');
}
if (outputNum === -1) {
throw new Error('Failed to identify DV profile');
}
return {
outputFileObj: args.inputFileObj,
outputNumber: outputNum,
variables: args.variables,
};
};
export {
details,
plugin,
};