@pixwel/pixwel-sdk 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ declare module "@pixwel/pixwel-sdk" {
2
+ export class Filename {
3
+ constructor(data:object);
4
+ static render(allTags:any[], allTypes:any[], asset:object, options:object, mediaType?:string):string;
5
+ }
6
+ export class Ingest {
7
+ constructor(data:object);
8
+ selected:object;
9
+ static mapFromMediainfo(info:object, mediaType:string):object;
10
+ static mapFromFilename(info:object, mediaType:string):object;
11
+ static assemble(ingest:object, filename:object, mediainfo:object, order:object, watermarks:object[]):Ingest;
12
+ }
13
+ export class Order {
14
+ constructor(data:object);
15
+ }
16
+ }
package/dist/index.js CHANGED
@@ -40,15 +40,6 @@ Object.defineProperty(exports, 'IngestFile', {
40
40
  }
41
41
  });
42
42
 
43
- var _IngestFileDrop = require('./src/IngestFileDrop');
44
-
45
- Object.defineProperty(exports, 'IngestFileDrop', {
46
- enumerable: true,
47
- get: function get() {
48
- return _interopRequireDefault(_IngestFileDrop).default;
49
- }
50
- });
51
-
52
43
  var _Order = require('./src/Order');
53
44
 
54
45
  Object.defineProperty(exports, 'Order', {
@@ -45,19 +45,19 @@ var Filename = function () {
45
45
  var mediaType = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
46
46
 
47
47
  if (!asset.project) {
48
- throw "missing asset.project";
48
+ throw new Error("missing asset.project");
49
49
  }
50
50
 
51
51
  if (asset.project && !asset.project.filePrefix) {
52
- throw "missing asset.project.filePrefix";
52
+ throw new Error("missing asset.project.filePrefix");
53
53
  }
54
54
 
55
55
  if (!asset.name) {
56
- throw "missing asset.name";
56
+ throw new Error("missing asset.name");
57
57
  }
58
58
 
59
59
  if (!asset.type) {
60
- throw "missing asset.type";
60
+ throw new Error("missing asset.type");
61
61
  }
62
62
 
63
63
  var defaults = {
@@ -82,35 +82,25 @@ var Filename = function () {
82
82
  options = _lodash2.default.merge(defaults, options);
83
83
 
84
84
  if (!options.language) {
85
- throw "missing options.language";
86
- }
87
-
88
- if (!options.tags.SubDub.sub && !options.tags.SubDub.dub && !options.tags.Text) {
89
- throw "missing options.tags.Text or options.tags.SubDub";
85
+ throw new Error("missing options.language");
90
86
  }
91
87
 
92
88
  if (mediaType && mediaType == "video" && !options.tags.Codec) {
93
- throw "missing options.tags.Codec";
89
+ throw new Error("missing options.tags.Codec");
94
90
  }
95
91
 
96
92
  if (mediaType && mediaType == "video" && !options.tags.Resolution) {
97
- throw "missing options.tags.Resolution";
93
+ throw new Error("missing options.tags.Resolution");
98
94
  }
99
95
 
100
96
  if (mediaType && mediaType == "video" && !options.tags.Framerate) {
101
- throw "missing options.tags.Framerate";
97
+ throw new Error("missing options.tags.Framerate");
102
98
  }
103
99
 
104
100
  if (mediaType == "video" && !options.tags["Frame Mode"]) {
105
- throw "missing options.tags[Frame Mode]";
101
+ throw new Error("missing options.tags[Frame Mode]");
106
102
  }
107
103
 
108
- // currently, slurpee's filename.ts will render this, but we can add this back in later when
109
- // filename.ts starts to rely on Filename.render
110
- // if ((options.tags.SubDub.dub || options.tags.SubDub.sub) && options.tags.Text) {
111
- // throw 'conflicting options supplied: SubDub and Text';
112
- // }
113
-
114
104
  function assetType(asset, types) {
115
105
  if (/trailer/.test(asset.type)) {
116
106
  return false;
@@ -118,7 +108,7 @@ var Filename = function () {
118
108
 
119
109
  var matchingType = _lodash2.default.find(types, { name: asset.type });
120
110
  if (!matchingType) {
121
- throw "Asset type \"" + asset.type + "\" could not be found";
111
+ throw new Error("Asset type \"" + asset.type + "\" could not be found");
122
112
  }
123
113
 
124
114
  return matchingType.file || matchingType.name.replace(".", "-").toUpperCase();
@@ -169,6 +159,9 @@ var Filename = function () {
169
159
  }
170
160
 
171
161
  function locale(country, language) {
162
+ if (language.includes('-')) {
163
+ country = '';
164
+ }
172
165
  return [language, country].filter(function (str) {
173
166
  return !!str && str !== "WW";
174
167
  }).join("-");
@@ -24,28 +24,29 @@ var Ingest = function () {
24
24
  }
25
25
 
26
26
  _createClass(Ingest, null, [{
27
- key: "mapMetaToTags",
27
+ key: "mapFromMediainfo",
28
28
 
29
29
  /**
30
- * [mapMetaToTags description]
31
- * @param {[type]} info [description]
32
- * @return {[type]} [description]
30
+ * Maps mediainfo metadata into ingest Tag format
31
+ * @param {*} info
32
+ * @param {*} mediaType
33
33
  */
34
- value: function mapMetaToTags(info, mediaType) {
35
-
36
- var tags = {
37
- Aspect: "",
38
- Standard: "",
39
- Resolution: "",
40
- Codec: "",
41
- "Frame Mode": "",
42
- Text: "",
43
- Usage: "",
34
+ value: function mapFromMediainfo(info, mediaType) {
35
+ var schema = {
36
+ Aspect: null,
37
+ Standard: null,
38
+ Resolution: null,
39
+ Codec: null,
40
+ "Frame Mode": null,
41
+ Text: null,
42
+ Usage: null,
44
43
  Extra: [],
45
- Framerate: "",
46
- Duration: ""
44
+ Framerate: null,
45
+ Duration: null
47
46
  };
48
47
 
48
+ var tags = {};
49
+
49
50
  if (!info.File) {
50
51
  throw "missing info.File";
51
52
  }
@@ -55,34 +56,34 @@ var Ingest = function () {
55
56
  }
56
57
 
57
58
  var general = void 0;
58
- if (!Array.isArray(info['File']['track'])) {
59
- general = info['File']['track'];
59
+ if (!Array.isArray(info["File"]["track"])) {
60
+ general = info["File"]["track"];
60
61
  } else {
61
- general = _lodash2.default.find(info['File']['track'], { _type: 'General' });
62
+ general = _lodash2.default.find(info["File"]["track"], { _type: "General" });
62
63
  }
63
64
 
64
65
  switch (mediaType) {
65
- case 'video':
66
- mediaType = 'Video';
66
+ case "video":
67
+ mediaType = "Video";
67
68
  break;
68
- case 'image':
69
- mediaType = 'Image';
69
+ case "image":
70
+ mediaType = "Image";
70
71
  break;
71
72
  default:
72
- if (general.Format && general.Format == 'MXF') {
73
- tags.Usage = 'broadcast';
73
+ if (general.Format && general.Format == "MXF") {
74
+ tags.Usage = "broadcast";
74
75
  }
75
76
  return tags;
76
77
  }
77
78
 
78
79
  var mediainfoDefaults = {
79
- Display_aspect_ratio: "",
80
+ DisplayAspectRatio: "",
80
81
  Format: "",
81
82
  Standard: "",
82
83
  Height: "",
83
84
  Width: "",
84
- Frame_rate: "",
85
- Scan_type: ""
85
+ FrameRate: "",
86
+ ScanType: ""
86
87
  };
87
88
 
88
89
  var media = _lodash2.default.find(info["File"]["track"], {
@@ -92,21 +93,41 @@ var Ingest = function () {
92
93
 
93
94
  var width = parseInt(media["Width"].replace(" ", "").match(/[0-9 ]+/));
94
95
  var height = parseInt(media["Height"].replace(" ", "").match(/[0-9 ]+/));
95
- tags.Resolution = width && height ? width + "x" + height : "";
96
-
97
- tags.Standard = media["Standard"] ? media["Standard"].toLowerCase() : "";
96
+ var Resolution = width && height ? width + "x" + height : null;
97
+ if (Resolution) {
98
+ tags.Resolution = Resolution;
99
+ }
98
100
 
99
- var scan = /Progressive/.test(media["Scan_type"]) ? "p" : "i";
100
- var dimension = /3D/.test(name) ? "3D" : "2D";
101
+ var Standard = media["Standard"] ? media["Standard"].toLowerCase() : null;
102
+ if (Standard) {
103
+ tags.Standard = Standard;
104
+ }
101
105
 
102
- var framerate = media["Frame_rate"].split(" ");
103
- if (framerate.length) {
104
- var f = framerate[0];
105
- if (f == "23.976") {
106
- f = "23.98";
107
- }
108
- f = parseFloat(f).toString();
109
- tags.Framerate = f != "NaN" ? f : "";
106
+ var framerate = media["FrameRate"];
107
+ switch (framerate) {
108
+ case "23.976":
109
+ framerate = "23.98";
110
+ break;
111
+ case "24.000":
112
+ framerate = "24";
113
+ break;
114
+ case "25.000":
115
+ framerate = "25";
116
+ break;
117
+ case "29.970":
118
+ framerate = "29.97";
119
+ break;
120
+ case "50.000":
121
+ framerate = "50";
122
+ break;
123
+ case "59.940":
124
+ framerate = "59.94";
125
+ break;
126
+ }
127
+ framerate = parseFloat(framerate).toString();
128
+ framerate = framerate != "NaN" ? framerate : null;
129
+ if (framerate) {
130
+ tags.Framerate = framerate;
110
131
  }
111
132
 
112
133
  if (!tags.Standard) {
@@ -124,16 +145,18 @@ var Ingest = function () {
124
145
  }
125
146
  }
126
147
 
127
- tags.Codec = function (codec) {
128
- switch (codec) {
129
- case "AVC":
130
- return "h264";
131
- case "ProRes":
132
- return "prores";
133
- default:
134
- return "";
135
- }
136
- }(media["Format"]);
148
+ var Codec = void 0;
149
+ switch (media["Format"]) {
150
+ case "AVC":
151
+ Codec = "h264";
152
+ break;
153
+ case "ProRes":
154
+ Codec = "prores";
155
+ break;
156
+ }
157
+ if (Codec) {
158
+ tags.Codec = Codec;
159
+ }
137
160
 
138
161
  if (tags.Codec == "h264") {
139
162
  tags.Usage = "online";
@@ -143,68 +166,198 @@ var Ingest = function () {
143
166
  tags.Usage = "broadcast";
144
167
  }
145
168
 
146
- if (general && general['Format'] == 'MXF') {
147
- tags.Usage = 'broadcast';
169
+ if (general && general["Format"] == "MXF") {
170
+ tags.Usage = "broadcast";
148
171
  }
149
172
 
150
- tags.Aspect = media["Display_aspect_ratio"] || "";
151
- tags["Frame Mode"] = media["Scan_type"].toLowerCase();
173
+ switch (media["DisplayAspectRatio"]) {
174
+ case "1.000":
175
+ tags.Aspect = "1:1";
176
+ break;
177
+ case "1.347":
178
+ tags.Aspect = "4:3";
179
+ break;
180
+ case "1.756":
181
+ tags.Aspect = "16:9";
182
+ break;
183
+ case "1.778":
184
+ tags.Aspect = "16:9";
185
+ break;
186
+ case "1.366":
187
+ tags.Aspect = "4:3";
188
+ break;
189
+ case "0.562":
190
+ tags.Aspect = "9:16";
191
+ break;
192
+ }
152
193
 
153
- return tags;
154
- }
155
- }, {
156
- key: "mapFromKnownData",
157
- value: function mapFromKnownData(context, order, tags) {
158
- var watermarks = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
194
+ var ScanType = media["ScanType"].toLowerCase() || null;
195
+ if (ScanType) {
196
+ tags["Frame Mode"] = ScanType;
197
+ }
159
198
 
199
+ var ingest = {
200
+ selected: {
201
+ download: {
202
+ tags: tags
203
+ }
204
+ }
205
+ };
160
206
 
161
- if (order.asset) {
162
- context = {
163
- asset: order.asset._id,
164
- project: order.project._id,
165
- assetType: order.assetType,
166
- purpose: "download"
167
- };
168
- }
207
+ return ingest;
208
+ }
209
+ /**
210
+ * Maps parsed filename data to a partial ingest record for later merging
211
+ * @param {*} filename
212
+ * @param {*} allTags
213
+ */
169
214
 
170
- var previewType = function () {
171
- if (order.isSub() && order.isDub()) return "both";
172
- if (order.isDub()) return "dub";
173
- if (order.isSub()) return "sub";
174
- }();
215
+ }, {
216
+ key: "mapFromFilename",
217
+ value: function mapFromFilename(filename, allTags) {
218
+ var tags = {
219
+ SubDub: {
220
+ sub: null,
221
+ dub: null
222
+ }
223
+ };
224
+ filename.file.tags.forEach(function (tag) {
225
+ var foundTag = _lodash2.default.find(allTags, { name: tag });
226
+ if (foundTag) {
227
+ if (foundTag.type == 'SubDub') {
228
+ if (foundTag.name == 'sub') {
229
+ tags.SubDub.sub = true;
230
+ }
231
+ if (foundTag.name == 'dub') {
232
+ tags.SubDub.dub = true;
233
+ }
234
+ } else {
235
+ tags[foundTag.type] = foundTag.name;
236
+ }
237
+ }
238
+ });
239
+ tags.Extra = filename.extra;
240
+ var ingest = {
241
+ selected: {
242
+ download: {
243
+ tags: tags
244
+ },
245
+ preview: {}
246
+ }
247
+ };
248
+ if (filename.file.tags.includes('sub') && filename.file.tags.includes('dub')) {
249
+ ingest.selected.preview.type = 'both';
250
+ } else if (filename.file.tags.includes('sub')) {
251
+ ingest.selected.preview.type = 'sub';
252
+ } else if (filename.file.tags.includes('dub')) {
253
+ ingest.selected.preview.type = 'dub';
254
+ }
255
+ if (filename.file.language) {
256
+ ingest.selected.preview.language = filename.file.language;
257
+ ingest.selected.download.language = filename.file.language;
258
+ }
259
+ if (filename.file.country) {
260
+ ingest.selected.download.country = filename.file.country;
261
+ }
262
+ return ingest;
263
+ }
264
+ /**
265
+ * Assembles Ingest based on weighted rules
266
+ * @param {*} context
267
+ * @param {*} filename
268
+ * @param {*} mediainfo
269
+ * @param {*} order
270
+ */
175
271
 
176
- var isPreviewEnabled = tags.Codec == "prores" && tags.Resolution.split("x")[1] == "1080" && (tags.Framerate == "23.98" || tags.Framerate == "25") && watermarks.length || null;
272
+ }, {
273
+ key: "assemble",
274
+ value: function assemble(original, filename, mediainfo, order) {
275
+ var watermarks = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
177
276
 
178
- var watermark = watermarks[0] ? watermarks[0]._id : "";
179
277
 
180
- return {
278
+ var defaults = {
181
279
  workRequest: order._id,
182
280
  selected: {
183
281
  download: {
184
282
  enabled: true,
185
- country: order.country,
186
- language: order.language,
187
- tags: tags,
283
+ tags: {
284
+ Extra: []
285
+ },
188
286
  embargo: {
189
287
  enabled: false
190
288
  }
191
289
  },
192
290
  preview: {
193
- enabled: isPreviewEnabled,
194
- language: order.language,
195
- revision: "Final",
196
- type: previewType,
197
- watermark: watermark,
291
+ enabled: false,
292
+ revision: 'Final',
293
+ type: 'none',
198
294
  embargo: {
199
295
  enabled: false
200
296
  }
201
297
  },
202
298
  thumbnail: {
203
- enabled: false
299
+ enabled: false,
300
+ position: 50
204
301
  }
205
- },
206
- context: context
302
+ }
207
303
  };
304
+
305
+ var ingest = _lodash2.default.merge(defaults, original, filename, mediainfo);
306
+
307
+ if (original.asset && original.asset.creative) {
308
+ ingest.selected.preview.revision = 'Unfinished';
309
+ }
310
+
311
+ if (!original.context.asset && filename.asset && filename.asset._id) {
312
+ ingest.selected.asset = filename.asset._id;
313
+ }
314
+
315
+ if (ingest.workRequest) {
316
+ ingest.selected.project = ingest.context.project;
317
+ ingest.selected.asset = ingest.context.asset;
318
+ ingest.selected.assetType = ingest.context.assetType;
319
+ }
320
+
321
+ if (ingest.workRequest) {
322
+ ingest.selected.download.tags.Extra = [];
323
+ }
324
+
325
+ if (original.context.tag) {
326
+ ingest.selected.download.tags.Extra = [original.context.tag];
327
+ }
328
+
329
+ if (order.territory) {
330
+ ingest.selected.download.country = order.territory;
331
+ }
332
+ if (order.language) {
333
+ ingest.selected.preview.language = order.language;
334
+ ingest.selected.download.language = order.language;
335
+ }
336
+ if (order._id) {
337
+ ingest.selected.download.tags.Text = 'txtd';
338
+ }
339
+ if (order.isSub() || order.isDub()) {
340
+ ingest.selected.download.tags.SubDub = {
341
+ sub: order.isSub(),
342
+ dub: order.isDub()
343
+ };
344
+ }
345
+ if (order.isSub()) {
346
+ ingest.selected.preview.type = "sub";
347
+ }
348
+ if (order.isDub()) {
349
+ ingest.selected.preview.type = "dub";
350
+ }
351
+ if (order.isSub() && order.isDub()) {
352
+ ingest.selected.preview.type = "both";
353
+ }
354
+
355
+ ingest.selected.preview.watermark = watermarks[0] ? watermarks[0]._id : "";
356
+
357
+ var tags = ingest.selected.download.tags;
358
+ ingest.selected.preview.enabled = !!(tags.Codec == "prores" && tags.Resolution.split("x")[1] == "1080" && (tags.Framerate == "23.98" || tags.Framerate == "25") && watermarks.length) || false;
359
+
360
+ return ingest;
208
361
  }
209
362
  }]);
210
363
 
package/dist/src/Order.js CHANGED
@@ -33,6 +33,10 @@ var Order = function () {
33
33
  };
34
34
  Object.assign(this, schema, data);
35
35
  }
36
+ /**
37
+ * Determines if an order should be classified as 'dubbed' based on its dng values
38
+ */
39
+
36
40
 
37
41
  _createClass(Order, [{
38
42
  key: "isDub",
@@ -40,14 +44,22 @@ var Order = function () {
40
44
  if (!this.dng) {
41
45
  return null;
42
46
  }
47
+ if (this.dng.graphics && this.dng.graphics.includes('Dedicated / Localized')) {
48
+ return false;
49
+ }
43
50
  return _lodash2.default.flattenDeep(Object.entries(this.dng)).includes("Dedicated / Localized");
44
51
  }
52
+ /**
53
+ * Determines in an order should be classified as 'subbed' based on its dng values
54
+ */
55
+
45
56
  }, {
46
57
  key: "isSub",
47
58
  value: function isSub() {
48
59
  if (!this.dng) {
49
60
  return null;
50
61
  }
62
+ if (this.dng === 'Graphics Only') return false;
51
63
  return _lodash2.default.flattenDeep(Object.entries(this.dng)).includes("Subtitled");
52
64
  }
53
65
  }]);
package/index.js CHANGED
@@ -2,5 +2,4 @@ export { default as Asset } from './src/Asset';
2
2
  export { default as Filename } from './src/Filename';
3
3
  export { default as Ingest } from './src/Ingest';
4
4
  export { default as IngestFile } from './src/IngestFile';
5
- export { default as IngestFileDrop } from './src/IngestFileDrop';
6
5
  export { default as Order } from './src/Order';
package/package.json CHANGED
@@ -1,28 +1,34 @@
1
1
  {
2
- "name": "@pixwel/pixwel-sdk",
3
- "description": "",
4
- "version": "1.1.7",
5
- "author": "Pixwel",
6
- "license": "UNLICENSED",
7
- "main": "./dist/index.js",
8
- "scripts": {
9
- "build": "babel -d dist index.js src/*.js",
10
- "test": "jest --coverage"
11
- },
12
- "jest": {
13
- "verbose": true,
14
- "coverageDirectory": "coverage",
15
- "collectCoverage": true,
16
- "collectCoverageFrom": [
17
- "src/*.js"
18
- ]
19
- },
20
- "dependencies": {
21
- "lodash": "^4.17.10"
22
- },
23
- "devDependencies": {
24
- "babel-cli": "^6.26.0",
25
- "babel-preset-env": "^1.7.0",
26
- "jest": "^22.4.4"
27
- }
2
+ "name": "@pixwel/pixwel-sdk",
3
+ "description": "",
4
+ "version": "1.1.9",
5
+ "author": "Pixwel",
6
+ "license": "UNLICENSED",
7
+ "main": "./dist/index.js",
8
+ "scripts": {
9
+ "build": "npx babel-cli -d dist index.js src/*.js",
10
+ "watch": "npx babel-cli -w -d dist index.js src/*.js",
11
+ "test": "npx jest --coverage"
12
+ },
13
+ "browserify": {
14
+ "transform": [
15
+ "babelify"
16
+ ]
17
+ },
18
+ "jest": {
19
+ "verbose": true,
20
+ "coverageDirectory": "coverage",
21
+ "collectCoverage": true,
22
+ "collectCoverageFrom": [
23
+ "src/*.js"
24
+ ]
25
+ },
26
+ "dependencies": {
27
+ "lodash": "^4.17.10"
28
+ },
29
+ "devDependencies": {
30
+ "babel-cli": "^6.26.0",
31
+ "babel-preset-env": "^1.7.0",
32
+ "jest": "^22.4.4"
33
+ }
28
34
  }