@pixwel/pixwel-sdk 2.1.4 → 2.1.6
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.
- package/.babelrc +2 -2
- package/coverage/clover.xml +4 -4
- package/coverage/coverage-final.json +2 -2
- package/coverage/lcov-report/Ass.js.html +1 -1
- package/coverage/lcov-report/Asset.js.html +1 -1
- package/coverage/lcov-report/AssetType.js.html +1 -1
- package/coverage/lcov-report/Encode.js.html +1 -1
- package/coverage/lcov-report/File.js.html +1 -1
- package/coverage/lcov-report/Filename.js.html +1 -1
- package/coverage/lcov-report/Ingest.js.html +2 -2
- package/coverage/lcov-report/IngestFile.js.html +1 -1
- package/coverage/lcov-report/Model.js.html +3 -3
- package/coverage/lcov-report/Order.js.html +1 -1
- package/coverage/lcov-report/Srt.js.html +1 -1
- package/coverage/lcov-report/Sub.js.html +1 -1
- package/coverage/lcov-report/Tag.js.html +1 -1
- package/coverage/lcov-report/TimeFormat.js.html +1 -1
- package/coverage/lcov-report/fileType.js.html +1 -1
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov.info +4 -4
- package/dist/Ass.js +206 -0
- package/dist/Asset.js +49 -0
- package/dist/AssetType.js +45 -0
- package/dist/Encode.js +45 -0
- package/dist/File.js +45 -0
- package/dist/Filename.js +23 -0
- package/dist/Ingest.js +734 -0
- package/dist/IngestFile.js +18 -0
- package/dist/Model.js +580 -0
- package/dist/Order.js +70 -0
- package/dist/Srt.js +97 -0
- package/dist/Sub.js +46 -0
- package/dist/Tag.js +45 -0
- package/dist/TimeFormat.js +53 -0
- package/dist/fileType.js +39 -0
- package/dist/index.js +77 -85
- package/dist/src/Ingest.js +1 -1
- package/package.json +7 -8
- package/src/Ingest.js +1 -1
- package/test/Ingest.spec.js +10 -7
package/dist/Ingest.js
ADDED
|
@@ -0,0 +1,734 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
+
|
|
16
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
|
+
|
|
18
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
+
|
|
20
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
21
|
+
|
|
22
|
+
var _File = _interopRequireDefault(require("./File"));
|
|
23
|
+
|
|
24
|
+
var _Model2 = _interopRequireDefault(require("./Model"));
|
|
25
|
+
|
|
26
|
+
var _fileType = require("./fileType");
|
|
27
|
+
|
|
28
|
+
var _ramda = require("ramda");
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* [media description]
|
|
32
|
+
* @type {[type]}
|
|
33
|
+
*/
|
|
34
|
+
var Ingest =
|
|
35
|
+
/*#__PURE__*/
|
|
36
|
+
function (_Model) {
|
|
37
|
+
(0, _inherits2["default"])(Ingest, _Model);
|
|
38
|
+
|
|
39
|
+
function Ingest(data) {
|
|
40
|
+
var _this;
|
|
41
|
+
|
|
42
|
+
(0, _classCallCheck2["default"])(this, Ingest);
|
|
43
|
+
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(Ingest).call(this, data));
|
|
44
|
+
_this._resource = "ingests";
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
(0, _createClass2["default"])(Ingest, [{
|
|
49
|
+
key: "renderPath",
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Returns path given an ingest record
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
value: function renderPath() {
|
|
56
|
+
var ingest = this.data();
|
|
57
|
+
|
|
58
|
+
if (!ingest.asset.project.studio.slug) {
|
|
59
|
+
throw new Error("missing studio slug");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!ingest.asset.project.slug) {
|
|
63
|
+
throw new Error("missing asset.project.slug");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!ingest.asset.project.slug) {
|
|
67
|
+
throw new Error("missing asset.project.slug");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return [ingest.asset.project.studio.slug, ingest.asset.project.slug, ingest.asset.type].join("/");
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create a File from an Ingest object with path and filename
|
|
74
|
+
*
|
|
75
|
+
* @param {object} params
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
}, {
|
|
79
|
+
key: "renderFilename",
|
|
80
|
+
value: function renderFilename() {
|
|
81
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : params = {},
|
|
82
|
+
allTags = _ref.allTags,
|
|
83
|
+
allTypes = _ref.allTypes,
|
|
84
|
+
order = _ref.order;
|
|
85
|
+
|
|
86
|
+
var asset = this.data().asset;
|
|
87
|
+
var options = this.data().selected.download;
|
|
88
|
+
var mediaType = this.data().asset.mediaType;
|
|
89
|
+
|
|
90
|
+
if (!asset.project) {
|
|
91
|
+
throw new Error("missing asset.project");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (asset.project && !asset.project.filePrefix) {
|
|
95
|
+
throw new Error("missing asset.project.filePrefix");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!asset.name) {
|
|
99
|
+
throw new Error("missing asset.name");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!asset.type) {
|
|
103
|
+
throw new Error("missing asset.type");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var defaults = {
|
|
107
|
+
language: null,
|
|
108
|
+
country: null,
|
|
109
|
+
version: null,
|
|
110
|
+
tags: {
|
|
111
|
+
Usage: null,
|
|
112
|
+
Aspect: null,
|
|
113
|
+
SubDub: {
|
|
114
|
+
sub: null,
|
|
115
|
+
dub: null
|
|
116
|
+
},
|
|
117
|
+
Resolution: null,
|
|
118
|
+
"Frame Mode": null,
|
|
119
|
+
Framerate: null,
|
|
120
|
+
Text: null,
|
|
121
|
+
Codec: null,
|
|
122
|
+
Extra: []
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
options = _lodash["default"].merge(defaults, options);
|
|
126
|
+
|
|
127
|
+
if (!options.language) {
|
|
128
|
+
throw new Error("missing options.language");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (mediaType && mediaType == "video" && !options.tags.Codec) {
|
|
132
|
+
throw new Error("missing options.tags.Codec");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (mediaType && mediaType == "video" && !options.tags.Resolution) {
|
|
136
|
+
throw new Error("missing options.tags.Resolution");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (mediaType && mediaType == "video" && !options.tags.Framerate) {
|
|
140
|
+
throw new Error("missing options.tags.Framerate");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (mediaType == "video" && !options.tags["Frame Mode"]) {
|
|
144
|
+
throw new Error("missing options.tags[Frame Mode]");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function assetType(asset, types) {
|
|
148
|
+
if (/trailer/.test(asset.type)) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var matchingType = _lodash["default"].find(types, {
|
|
153
|
+
name: asset.type
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (!matchingType) {
|
|
157
|
+
throw new Error("Asset type \"".concat(asset.type, "\" could not be found"));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return matchingType.file || matchingType.name.replace(".", "-").toUpperCase();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function assetTitle(asset) {
|
|
164
|
+
var prefix = "";
|
|
165
|
+
var name = asset.slug.toUpperCase().replace("INT-L", "INTL");
|
|
166
|
+
|
|
167
|
+
if (/trailer/.test(asset.type)) {
|
|
168
|
+
switch (asset.type) {
|
|
169
|
+
case "trailer.intl":
|
|
170
|
+
prefix = "ITR-";
|
|
171
|
+
name = name.replace(/INTL-TRAILER-/, "");
|
|
172
|
+
break;
|
|
173
|
+
|
|
174
|
+
case "trailer":
|
|
175
|
+
prefix = "TR-";
|
|
176
|
+
name = name.replace(/TRAILER-/, "");
|
|
177
|
+
break;
|
|
178
|
+
|
|
179
|
+
case "trailer.us":
|
|
180
|
+
prefix = "DTR-";
|
|
181
|
+
name = name.replace(/DOMESTIC-TRAILER-/, "");
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return prefix + name;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function runningTime(asset) {
|
|
190
|
+
var matches = asset.type.match(/^film-clip|^featurette/);
|
|
191
|
+
|
|
192
|
+
if (!matches) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
var minutes = Math.floor(asset.length / 60);
|
|
197
|
+
var seconds = asset.length % 60;
|
|
198
|
+
var result = "";
|
|
199
|
+
|
|
200
|
+
if (minutes > 0) {
|
|
201
|
+
result += minutes + "min";
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (seconds > 0) {
|
|
205
|
+
result += seconds + "sec";
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function locale(country, language) {
|
|
212
|
+
if (language.includes("-")) {
|
|
213
|
+
country = "";
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return [language, country].filter(function (str) {
|
|
217
|
+
return !!str && str !== "WW";
|
|
218
|
+
}).join("-");
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function textType(subDub, text) {
|
|
222
|
+
if (!subDub || !subDub.sub && !subDub.dub) {
|
|
223
|
+
return text;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
var result = [];
|
|
227
|
+
|
|
228
|
+
if (subDub.sub) {
|
|
229
|
+
result.push("sub");
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (subDub.dub) {
|
|
233
|
+
result.push("dub");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function matchSet(allTags, tags) {
|
|
240
|
+
var selectedTags = (0, _lodash["default"])(tags).values().flatten().value();
|
|
241
|
+
var setTag = (0, _lodash["default"])(allTags).filter("set").find(function (setTag) {
|
|
242
|
+
return _lodash["default"].difference(setTag.set, selectedTags).length === 0;
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
if (setTag) {
|
|
246
|
+
return setTag.name;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
var tags = options.tags,
|
|
251
|
+
parts = [asset.project.filePrefix, assetType(asset, allTypes), assetTitle(asset), runningTime(asset), locale(options.country, options.language), textType(tags.SubDub, tags.Text), tags.Extra.join("_"), options.version, tags.Codec];
|
|
252
|
+
parts = (0, _lodash["default"])(parts).flatten().filter().map(function (part) {
|
|
253
|
+
return part.toUpperCase();
|
|
254
|
+
});
|
|
255
|
+
var matchedSet = matchSet(allTags, options.tags);
|
|
256
|
+
var requiredInfo = tags.Resolution && tags["Frame Mode"] && tags.Framerate;
|
|
257
|
+
|
|
258
|
+
if (matchedSet) {
|
|
259
|
+
parts = parts.push(matchedSet);
|
|
260
|
+
} else if (mediaType == "video" && tags.Resolution && !requiredInfo) {
|
|
261
|
+
parts = parts.push(tags.Resolution.replace(/\d+x/, ""));
|
|
262
|
+
} else if (mediaType == "image" && tags.Resolution) {
|
|
263
|
+
parts = parts.push(tags.Resolution);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
var name = parts.join("_");
|
|
267
|
+
var hasResInfo = name.match(/\d+(i|p)/i);
|
|
268
|
+
var hasAllInfo = name.match(/\d+(i|p)\d+/i);
|
|
269
|
+
|
|
270
|
+
if (requiredInfo && !hasResInfo && !hasAllInfo) {
|
|
271
|
+
var res = tags.Resolution;
|
|
272
|
+
var encodeTag = [hasResInfo ? "" : res.indexOf("x") ? res.replace(/\d+x/, "") : res, res.match(/i|p/i) && !hasResInfo ? "" : tags["Frame Mode"].toLowerCase().slice(0, 1), tags.Framerate.replace(".", "").toUpperCase()].filter(function (val) {
|
|
273
|
+
return val;
|
|
274
|
+
}).join("");
|
|
275
|
+
var match = new RegExp(encodeTag, "i");
|
|
276
|
+
name = name.match(match) ? name.replace(match, encodeTag) : name + "_" + encodeTag;
|
|
277
|
+
} else if (hasResInfo && !hasAllInfo && tags.Framerate) {
|
|
278
|
+
name += tags.Framerate.replace(".", "").toUpperCase();
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return name;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Returns the mediaType of the ingest
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
}, {
|
|
288
|
+
key: "mediaType",
|
|
289
|
+
value: function mediaType() {
|
|
290
|
+
return this.src.mediaType;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Maps mediainfo metadata into ingest Tag format
|
|
294
|
+
*
|
|
295
|
+
*/
|
|
296
|
+
|
|
297
|
+
}, {
|
|
298
|
+
key: "mapFromMediainfo",
|
|
299
|
+
value: function mapFromMediainfo() {
|
|
300
|
+
var info = this.mediainfo;
|
|
301
|
+
var mediaType = this.source.mediaType;
|
|
302
|
+
var schema = {
|
|
303
|
+
Aspect: null,
|
|
304
|
+
Standard: null,
|
|
305
|
+
Resolution: null,
|
|
306
|
+
Codec: null,
|
|
307
|
+
"Frame Mode": null,
|
|
308
|
+
Text: null,
|
|
309
|
+
Usage: null,
|
|
310
|
+
Extra: [],
|
|
311
|
+
Framerate: null,
|
|
312
|
+
Duration: null
|
|
313
|
+
};
|
|
314
|
+
var tags = {};
|
|
315
|
+
|
|
316
|
+
if (!info.File) {
|
|
317
|
+
throw "missing info.File";
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (!info.File.track) {
|
|
321
|
+
throw "missing info.File.track";
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
var general;
|
|
325
|
+
|
|
326
|
+
if (!Array.isArray(info["File"]["track"])) {
|
|
327
|
+
general = info["File"]["track"];
|
|
328
|
+
} else {
|
|
329
|
+
general = _lodash["default"].find(info["File"]["track"], {
|
|
330
|
+
_type: "General"
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
switch (mediaType) {
|
|
335
|
+
case "video":
|
|
336
|
+
mediaType = "Video";
|
|
337
|
+
break;
|
|
338
|
+
|
|
339
|
+
case "image":
|
|
340
|
+
mediaType = "Image";
|
|
341
|
+
break;
|
|
342
|
+
|
|
343
|
+
default:
|
|
344
|
+
if (general.Format && general.Format == "MXF") {
|
|
345
|
+
tags.Usage = "broadcast";
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return tags;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
var mediainfoDefaults = {
|
|
352
|
+
DisplayAspectRatio: "",
|
|
353
|
+
Format: "",
|
|
354
|
+
Standard: "",
|
|
355
|
+
Height: "",
|
|
356
|
+
Width: "",
|
|
357
|
+
FrameRate: "",
|
|
358
|
+
ScanType: ""
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
var media = _lodash["default"].find(info["File"]["track"], {
|
|
362
|
+
_type: mediaType
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
media = _lodash["default"].merge({}, mediainfoDefaults, media);
|
|
366
|
+
var width = parseInt(media["Width"].replace(" ", "").match(/[0-9 ]+/));
|
|
367
|
+
var height = parseInt(media["Height"].replace(" ", "").match(/[0-9 ]+/));
|
|
368
|
+
var Resolution = width && height ? "".concat(width, "x").concat(height) : null;
|
|
369
|
+
|
|
370
|
+
if (Resolution) {
|
|
371
|
+
tags.Resolution = Resolution;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
var Standard = media["Standard"] ? media["Standard"].toLowerCase() : null;
|
|
375
|
+
|
|
376
|
+
if (Standard) {
|
|
377
|
+
tags.Standard = Standard;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
var framerate = media["FrameRate"];
|
|
381
|
+
|
|
382
|
+
switch (framerate) {
|
|
383
|
+
case "23.976":
|
|
384
|
+
framerate = "23.98";
|
|
385
|
+
break;
|
|
386
|
+
|
|
387
|
+
case "24.000":
|
|
388
|
+
framerate = "24";
|
|
389
|
+
break;
|
|
390
|
+
|
|
391
|
+
case "25.000":
|
|
392
|
+
framerate = "25";
|
|
393
|
+
break;
|
|
394
|
+
|
|
395
|
+
case "29.970":
|
|
396
|
+
framerate = "29.97";
|
|
397
|
+
break;
|
|
398
|
+
|
|
399
|
+
case "50.000":
|
|
400
|
+
framerate = "50";
|
|
401
|
+
break;
|
|
402
|
+
|
|
403
|
+
case "59.940":
|
|
404
|
+
framerate = "59.94";
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
framerate = parseFloat(framerate).toString();
|
|
409
|
+
framerate = framerate != "NaN" ? framerate : null;
|
|
410
|
+
|
|
411
|
+
if (framerate) {
|
|
412
|
+
tags.Framerate = framerate;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
if (!tags.Standard) {
|
|
416
|
+
switch (tags.Framerate) {
|
|
417
|
+
case "24":
|
|
418
|
+
case "23.98":
|
|
419
|
+
case "29.97":
|
|
420
|
+
case "59.94":
|
|
421
|
+
tags.Standard = "ntsc";
|
|
422
|
+
break;
|
|
423
|
+
|
|
424
|
+
case "25":
|
|
425
|
+
case "50":
|
|
426
|
+
tags.Standard = "pal";
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
var Codec;
|
|
432
|
+
|
|
433
|
+
switch (media["Format"]) {
|
|
434
|
+
case "AVC":
|
|
435
|
+
Codec = "h264";
|
|
436
|
+
break;
|
|
437
|
+
|
|
438
|
+
case "ProRes":
|
|
439
|
+
Codec = "prores";
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (Codec) {
|
|
444
|
+
tags.Codec = Codec;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (tags.Codec == "h264") {
|
|
448
|
+
tags.Usage = "online";
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (tags.Codec == "prores") {
|
|
452
|
+
tags.Usage = "broadcast";
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if (general && general["Format"] == "MXF") {
|
|
456
|
+
tags.Usage = "broadcast";
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
switch (media["DisplayAspectRatio"]) {
|
|
460
|
+
case "1.000":
|
|
461
|
+
tags.Aspect = "1:1";
|
|
462
|
+
break;
|
|
463
|
+
|
|
464
|
+
case "1.347":
|
|
465
|
+
tags.Aspect = "4:3";
|
|
466
|
+
break;
|
|
467
|
+
|
|
468
|
+
case "1.756":
|
|
469
|
+
tags.Aspect = "16:9";
|
|
470
|
+
break;
|
|
471
|
+
|
|
472
|
+
case "1.778":
|
|
473
|
+
tags.Aspect = "16:9";
|
|
474
|
+
break;
|
|
475
|
+
|
|
476
|
+
case "1.366":
|
|
477
|
+
tags.Aspect = "4:3";
|
|
478
|
+
break;
|
|
479
|
+
|
|
480
|
+
case "0.562":
|
|
481
|
+
tags.Aspect = "9:16";
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
var ScanType = media["ScanType"].toLowerCase() || null;
|
|
486
|
+
|
|
487
|
+
if (ScanType) {
|
|
488
|
+
tags["Frame Mode"] = ScanType;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
var ingest = {
|
|
492
|
+
selected: {
|
|
493
|
+
download: {
|
|
494
|
+
tags: tags
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
return ingest;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Maps parsed filename data to a partial ingest record for later merging
|
|
502
|
+
* @param {*} filename
|
|
503
|
+
* @param {*} allTags
|
|
504
|
+
*/
|
|
505
|
+
|
|
506
|
+
}, {
|
|
507
|
+
key: "mapFromFilename",
|
|
508
|
+
value: function mapFromFilename(params) {
|
|
509
|
+
var allTags = params.allTags;
|
|
510
|
+
var filename = this.filename;
|
|
511
|
+
var tags = {
|
|
512
|
+
SubDub: {
|
|
513
|
+
sub: null,
|
|
514
|
+
dub: null
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
filename.file.tags.forEach(function (tag) {
|
|
518
|
+
var foundTag = _lodash["default"].find(allTags, {
|
|
519
|
+
name: tag
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
if (foundTag) {
|
|
523
|
+
if (foundTag.type == "SubDub") {
|
|
524
|
+
if (foundTag.name == "sub") {
|
|
525
|
+
tags.SubDub.sub = true;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if (foundTag.name == "dub") {
|
|
529
|
+
tags.SubDub.dub = true;
|
|
530
|
+
}
|
|
531
|
+
} else {
|
|
532
|
+
tags[foundTag.type] = foundTag.name;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
tags.Extra = filename.extra;
|
|
537
|
+
var ingest = {
|
|
538
|
+
selected: {
|
|
539
|
+
download: {
|
|
540
|
+
tags: tags
|
|
541
|
+
},
|
|
542
|
+
preview: {}
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
if (filename.file.tags.includes("sub") && filename.file.tags.includes("dub")) {
|
|
547
|
+
ingest.selected.preview.type = "both";
|
|
548
|
+
} else if (filename.file.tags.includes("sub")) {
|
|
549
|
+
ingest.selected.preview.type = "sub";
|
|
550
|
+
} else if (filename.file.tags.includes("dub")) {
|
|
551
|
+
ingest.selected.preview.type = "dub";
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
if (filename.file.language) {
|
|
555
|
+
ingest.selected.preview.language = filename.file.language;
|
|
556
|
+
ingest.selected.download.language = filename.file.language;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
if (filename.file.country) {
|
|
560
|
+
ingest.selected.download.country = filename.file.country;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
return ingest;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Create a File from an Ingest object
|
|
567
|
+
*
|
|
568
|
+
* @param {object} params
|
|
569
|
+
*/
|
|
570
|
+
|
|
571
|
+
}, {
|
|
572
|
+
key: "createFile",
|
|
573
|
+
value: function createFile(params) {
|
|
574
|
+
var allTags = params.allTags,
|
|
575
|
+
allTypes = params.allTypes,
|
|
576
|
+
order = params.order;
|
|
577
|
+
var filename = this.mapFromFilename({
|
|
578
|
+
allTags: allTags
|
|
579
|
+
});
|
|
580
|
+
var mediainfo = this.mapFromMediainfo();
|
|
581
|
+
var ingest = this.assemble({
|
|
582
|
+
filename: filename,
|
|
583
|
+
mediainfo: mediainfo,
|
|
584
|
+
order: order
|
|
585
|
+
});
|
|
586
|
+
var file = new _File["default"]({
|
|
587
|
+
name: this.renderFilename({
|
|
588
|
+
allTags: allTags,
|
|
589
|
+
allTypes: allTypes
|
|
590
|
+
}),
|
|
591
|
+
path: this.renderPath(),
|
|
592
|
+
asset: ingest.asset._id,
|
|
593
|
+
generator: "ingest",
|
|
594
|
+
contextTag: ingest.context.tag,
|
|
595
|
+
language: ingest.selected.download.language,
|
|
596
|
+
country: ingest.selected.download.country,
|
|
597
|
+
tags: flatValues(ingest.selected.download.tags),
|
|
598
|
+
ingest: ingest._id,
|
|
599
|
+
workRequest: ingest.workRequest,
|
|
600
|
+
verified: true
|
|
601
|
+
});
|
|
602
|
+
return file;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Merges ingest metadata sources
|
|
606
|
+
*
|
|
607
|
+
* @param {object} params
|
|
608
|
+
*/
|
|
609
|
+
|
|
610
|
+
}, {
|
|
611
|
+
key: "assemble",
|
|
612
|
+
value: function assemble(params) {
|
|
613
|
+
var filename = params.filename,
|
|
614
|
+
mediainfo = params.mediainfo,
|
|
615
|
+
order = params.order,
|
|
616
|
+
_params$watermarks = params.watermarks,
|
|
617
|
+
watermarks = _params$watermarks === void 0 ? [] : _params$watermarks;
|
|
618
|
+
var original = this.data();
|
|
619
|
+
var defaults = {
|
|
620
|
+
workRequest: order._id,
|
|
621
|
+
selected: {
|
|
622
|
+
download: {
|
|
623
|
+
enabled: true,
|
|
624
|
+
tags: {
|
|
625
|
+
Extra: []
|
|
626
|
+
},
|
|
627
|
+
embargo: {
|
|
628
|
+
enabled: false
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
preview: {
|
|
632
|
+
enabled: false,
|
|
633
|
+
revision: "Final",
|
|
634
|
+
type: "none",
|
|
635
|
+
embargo: {
|
|
636
|
+
enabled: false
|
|
637
|
+
}
|
|
638
|
+
},
|
|
639
|
+
thumbnail: {
|
|
640
|
+
enabled: false,
|
|
641
|
+
position: 50
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
var ingest = _lodash["default"].merge(defaults, filename, original, mediainfo);
|
|
647
|
+
|
|
648
|
+
if (original.asset && original.asset.creative) {
|
|
649
|
+
ingest.selected.preview.revision = "Unfinished";
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (!original.context.asset && filename.asset && filename.asset._id) {
|
|
653
|
+
ingest.selected.asset = filename.asset._id;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
if (ingest.workRequest) {
|
|
657
|
+
ingest.selected.project = ingest.context.project;
|
|
658
|
+
ingest.selected.asset = ingest.context.asset;
|
|
659
|
+
ingest.selected.assetType = ingest.context.assetType;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (ingest.workRequest) {
|
|
663
|
+
ingest.selected.download.tags.Extra = [];
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if (original.context.tag) {
|
|
667
|
+
ingest.selected.download.tags.Extra = [original.context.tag];
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
if (order.territory) {
|
|
671
|
+
ingest.selected.download.country = order.territory;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if (order.language) {
|
|
675
|
+
ingest.selected.preview.language = order.language;
|
|
676
|
+
ingest.selected.download.language = order.language;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
if (order._id) {
|
|
680
|
+
ingest.selected.download.tags.Text = "txtd";
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
if (order.isSub() || order.isDub()) {
|
|
684
|
+
ingest.selected.download.tags.SubDub = {
|
|
685
|
+
sub: order.isSub(),
|
|
686
|
+
dub: order.isDub()
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
if (order.isSub()) {
|
|
691
|
+
ingest.selected.preview.type = "sub";
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
if (order.isDub()) {
|
|
695
|
+
ingest.selected.preview.type = "dub";
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (order.isSub() && order.isDub()) {
|
|
699
|
+
ingest.selected.preview.type = "both";
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
ingest.selected.preview.watermark = watermarks[0] ? watermarks[0]._id : "";
|
|
703
|
+
var tags = ingest.selected.download.tags;
|
|
704
|
+
ingest.selected.preview.enabled = !!(tags.Codec == "prores" && tags.Resolution.split("x")[1] == "1080" && (tags.Framerate == "23.98" || tags.Framerate == "25") && watermarks.length) || false;
|
|
705
|
+
return ingest;
|
|
706
|
+
}
|
|
707
|
+
}], [{
|
|
708
|
+
key: "_resource",
|
|
709
|
+
get: function get() {
|
|
710
|
+
return "ingests";
|
|
711
|
+
}
|
|
712
|
+
}]);
|
|
713
|
+
return Ingest;
|
|
714
|
+
}(_Model2["default"]);
|
|
715
|
+
/**
|
|
716
|
+
* Flattens ingest.selected.download.tags into a simple array
|
|
717
|
+
*
|
|
718
|
+
* @param {object} data
|
|
719
|
+
*/
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
exports["default"] = Ingest;
|
|
723
|
+
|
|
724
|
+
function flatValues(data) {
|
|
725
|
+
var copy = (0, _ramda.clone)(data);
|
|
726
|
+
|
|
727
|
+
if (copy.SubDub) {
|
|
728
|
+
copy.SubDub = (0, _ramda.keys)((0, _ramda.filter)(function (val) {
|
|
729
|
+
return !!val;
|
|
730
|
+
}, copy.SubDub));
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
return (0, _ramda.flatten)((0, _ramda.values)(copy));
|
|
734
|
+
}
|