@pixwel/pixwel-sdk 1.1.6 → 1.1.8

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', {
@@ -85,10 +85,6 @@ var Filename = function () {
85
85
  throw "missing options.language";
86
86
  }
87
87
 
88
- if (!options.tags.SubDub.sub && !options.tags.SubDub.dub && !options.tags.Text) {
89
- throw "missing options.tags.Text or options.tags.SubDub";
90
- }
91
-
92
88
  if (mediaType && mediaType == "video" && !options.tags.Codec) {
93
89
  throw "missing options.tags.Codec";
94
90
  }
@@ -105,12 +101,6 @@ var Filename = function () {
105
101
  throw "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;
@@ -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
  }
@@ -54,32 +55,35 @@ var Ingest = function () {
54
55
  throw "missing info.File.track";
55
56
  }
56
57
 
57
- var general = _lodash2.default.find(info["File"]["track"], {
58
- _type: 'General'
59
- });
58
+ var general = void 0;
59
+ if (!Array.isArray(info["File"]["track"])) {
60
+ general = info["File"]["track"];
61
+ } else {
62
+ general = _lodash2.default.find(info["File"]["track"], { _type: "General" });
63
+ }
60
64
 
61
65
  switch (mediaType) {
62
- case 'video':
63
- mediaType = 'Video';
66
+ case "video":
67
+ mediaType = "Video";
64
68
  break;
65
- case 'image':
66
- mediaType = 'Image';
69
+ case "image":
70
+ mediaType = "Image";
67
71
  break;
68
72
  default:
69
- if (general.Format == 'MXF') {
70
- tags.Usage = 'broadcast';
73
+ if (general.Format && general.Format == "MXF") {
74
+ tags.Usage = "broadcast";
71
75
  }
72
76
  return tags;
73
77
  }
74
78
 
75
79
  var mediainfoDefaults = {
76
- Display_aspect_ratio: "",
80
+ DisplayAspectRatio: "",
77
81
  Format: "",
78
82
  Standard: "",
79
83
  Height: "",
80
84
  Width: "",
81
- Frame_rate: "",
82
- Scan_type: ""
85
+ FrameRate: "",
86
+ ScanType: ""
83
87
  };
84
88
 
85
89
  var media = _lodash2.default.find(info["File"]["track"], {
@@ -89,21 +93,41 @@ var Ingest = function () {
89
93
 
90
94
  var width = parseInt(media["Width"].replace(" ", "").match(/[0-9 ]+/));
91
95
  var height = parseInt(media["Height"].replace(" ", "").match(/[0-9 ]+/));
92
- tags.Resolution = width && height ? width + "x" + height : "";
93
-
94
- tags.Standard = media["Standard"] ? media["Standard"].toLowerCase() : "";
96
+ var Resolution = width && height ? width + "x" + height : null;
97
+ if (Resolution) {
98
+ tags.Resolution = Resolution;
99
+ }
95
100
 
96
- var scan = /Progressive/.test(media["Scan_type"]) ? "p" : "i";
97
- var dimension = /3D/.test(name) ? "3D" : "2D";
101
+ var Standard = media["Standard"] ? media["Standard"].toLowerCase() : null;
102
+ if (Standard) {
103
+ tags.Standard = Standard;
104
+ }
98
105
 
99
- var framerate = media["Frame_rate"].split(" ");
100
- if (framerate.length) {
101
- var f = framerate[0];
102
- if (f == "23.976") {
103
- f = "23.98";
104
- }
105
- f = parseFloat(f).toString();
106
- 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;
107
131
  }
108
132
 
109
133
  if (!tags.Standard) {
@@ -121,16 +145,18 @@ var Ingest = function () {
121
145
  }
122
146
  }
123
147
 
124
- tags.Codec = function (codec) {
125
- switch (codec) {
126
- case "AVC":
127
- return "h264";
128
- case "ProRes":
129
- return "prores";
130
- default:
131
- return "";
132
- }
133
- }(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
+ }
134
160
 
135
161
  if (tags.Codec == "h264") {
136
162
  tags.Usage = "online";
@@ -140,68 +166,198 @@ var Ingest = function () {
140
166
  tags.Usage = "broadcast";
141
167
  }
142
168
 
143
- if (general && general['Format'] == 'MXF') {
144
- tags.Usage = 'broadcast';
169
+ if (general && general["Format"] == "MXF") {
170
+ tags.Usage = "broadcast";
145
171
  }
146
172
 
147
- tags.Aspect = media["Display_aspect_ratio"] || "";
148
- 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
+ }
149
193
 
150
- return tags;
151
- }
152
- }, {
153
- key: "mapFromKnownData",
154
- value: function mapFromKnownData(context, order, tags) {
155
- 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
+ }
156
198
 
199
+ var ingest = {
200
+ selected: {
201
+ download: {
202
+ tags: tags
203
+ }
204
+ }
205
+ };
157
206
 
158
- if (order.asset) {
159
- context = {
160
- asset: order.asset._id,
161
- project: order.project._id,
162
- assetType: order.assetType,
163
- purpose: "download"
164
- };
165
- }
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
+ */
166
214
 
167
- var previewType = function () {
168
- if (order.isSub() && order.isDub()) return "both";
169
- if (order.isDub()) return "dub";
170
- if (order.isSub()) return "sub";
171
- }();
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
+ */
172
271
 
173
- 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] : [];
174
276
 
175
- var watermark = watermarks[0] ? watermarks[0]._id : "";
176
277
 
177
- return {
278
+ var defaults = {
178
279
  workRequest: order._id,
179
280
  selected: {
180
281
  download: {
181
282
  enabled: true,
182
- country: order.country,
183
- language: order.language,
184
- tags: tags,
283
+ tags: {
284
+ Extra: []
285
+ },
185
286
  embargo: {
186
287
  enabled: false
187
288
  }
188
289
  },
189
290
  preview: {
190
- enabled: isPreviewEnabled,
191
- language: order.language,
192
- revision: "Final",
193
- type: previewType,
194
- watermark: watermark,
291
+ enabled: false,
292
+ revision: 'Final',
293
+ type: 'none',
195
294
  embargo: {
196
295
  enabled: false
197
296
  }
198
297
  },
199
298
  thumbnail: {
200
- enabled: false
299
+ enabled: false,
300
+ position: 50
201
301
  }
202
- },
203
- context: context
302
+ }
204
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;
205
361
  }
206
362
  }]);
207
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.6",
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.8",
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
  }
package/src/Filename.js CHANGED
@@ -64,14 +64,6 @@ export default class Filename {
64
64
  throw "missing options.language";
65
65
  }
66
66
 
67
- if (
68
- !options.tags.SubDub.sub &&
69
- !options.tags.SubDub.dub &&
70
- !options.tags.Text
71
- ) {
72
- throw "missing options.tags.Text or options.tags.SubDub";
73
- }
74
-
75
67
  if (mediaType && mediaType == "video" && !options.tags.Codec) {
76
68
  throw "missing options.tags.Codec";
77
69
  }
@@ -88,12 +80,6 @@ export default class Filename {
88
80
  throw "missing options.tags[Frame Mode]";
89
81
  }
90
82
 
91
- // currently, slurpee's filename.ts will render this, but we can add this back in later when
92
- // filename.ts starts to rely on Filename.render
93
- // if ((options.tags.SubDub.dub || options.tags.SubDub.sub) && options.tags.Text) {
94
- // throw 'conflicting options supplied: SubDub and Text';
95
- // }
96
-
97
83
  function assetType(asset, types) {
98
84
  if (/trailer/.test(asset.type)) {
99
85
  return false;
@@ -154,6 +140,9 @@ export default class Filename {
154
140
  }
155
141
 
156
142
  function locale(country, language) {
143
+ if (language.includes('-')) {
144
+ country = '';
145
+ }
157
146
  return [language, country]
158
147
  .filter(str => {
159
148
  return !!str && str !== "WW";