kt-forpro-tools 1.0.11 → 1.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kt-forpro-tools",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "author": "Miguel de Mendoza",
6
6
  "main": "src/index.ts",
@@ -10,8 +10,13 @@ describe("KtForproTools Tests", () => {
10
10
 
11
11
  // KT_ForproTools.Cleanup();
12
12
  // KT_ForproTools.utils.cleanNamePrecomp();
13
- KT_ForproTools.utils.precompAndKeyOut("esp");
14
- KT_ForproTools.utils.precompAndKeyOut("cat");
13
+ // KT_ForproTools.utils.sendCleanupToMediaEncoder(["esp", "cat"]);
14
+ // KT_ForproTools.utils.sendLanguagesToMediaEncoder();
15
+ // KT_ForproTools.utils.sendCleanupToMediaEncoder();
16
+ KT_ForproTools.utils.autoPrecompAndKeyOut();
17
+ // const folder = Folder.selectDialog("Select a folder with language subfolders");
18
+ // $.writeln("Selected folder: " + folder?.fsName);
19
+ // KT_ForproTools.utils.precompAndKeyOut("cat");
15
20
  // KT_ForproTools.utils.createCleanupStructure();
16
21
 
17
22
  // const slides = new KT_Slides({
package/src/utils.ts CHANGED
@@ -2,6 +2,11 @@ import { KT_AeIs as is } from "kt-ae-is-checkers";
2
2
 
3
3
  import { KT_Project } from "kt-ae-tools-project";
4
4
  import { IO } from "kt-io";
5
+
6
+ type LanguageItems = {
7
+ [lang: string]: _ItemClasses[] | _ItemClasses;
8
+ };
9
+
5
10
  function generateProjectStructure(
6
11
  template: any = {},
7
12
  name?: string,
@@ -19,7 +24,7 @@ function generateProjectStructure(
19
24
  return newFolder;
20
25
  }
21
26
 
22
- export function createCleanupStructure(name: string): FolderItem {
27
+ export function createCleanupStructure(): FolderItem {
23
28
  return generateProjectStructure({
24
29
  src: {
25
30
  esp: {},
@@ -67,10 +72,21 @@ class __KT_FP_Utils {
67
72
  return createdComps;
68
73
  };
69
74
 
75
+ autoPrecompAndKeyOut = () => {
76
+ const root = KT_Project.find.folders("src");
77
+ const folders = KT_Project.find.folders({ root: root[0] as FolderItem });
78
+ for (const folder of folders) {
79
+ const lang = folder.name;
80
+ this.precompAndKeyOut(lang);
81
+ }
82
+ };
83
+
70
84
  precompAndKeyOut = (lang: string = "esp") => {
71
85
  const footagePaths = [KT_Project.path.join("//src", lang)];
86
+
72
87
  const footageItems = KT_Project.find.footage({ relativePath: footagePaths });
73
88
  if (footageItems.length === 0) {
89
+ alert("No footage items found in the selected language folder: " + lang);
74
90
  return;
75
91
  }
76
92
  const createdComps = this.cleanNamePrecomp(footageItems);
@@ -92,6 +108,55 @@ class __KT_FP_Utils {
92
108
  layer.selected = false;
93
109
  }
94
110
  };
111
+
112
+ sendCleanupToMediaEncoder = (langs: string[] = ["esp"]) => {
113
+ const items: FolderItem[] = KT_Project.find.folders("outputs");
114
+ this.sendLanguagesToMediaEncoder(items);
115
+ };
116
+
117
+ sendLanguagesToMediaEncoder = (selectedItems: _ItemClasses | _ItemClasses[] = app.project.selection) => {
118
+ if (!(selectedItems instanceof Array)) {
119
+ selectedItems = [selectedItems];
120
+ }
121
+ if (selectedItems.length === 0 || !is.folder(selectedItems[0])) {
122
+ return;
123
+ }
124
+ const langFolders = KT_Project.find.folders({ root: selectedItems[0] as FolderItem });
125
+ const langs = langFolders.map((folder) => folder.name);
126
+ const parentPath = KT_Project.path.get(selectedItems[0] as FolderItem);
127
+ const items: LanguageItems = {};
128
+ for (const lang of langs) {
129
+ const footagePaths = [KT_Project.path.join(parentPath, lang)];
130
+ const footageItems = KT_Project.find.comps({ relativePath: footagePaths });
131
+ if (footageItems.length > 0) {
132
+ if (!items[lang]) {
133
+ items[lang] = [];
134
+ }
135
+ items[lang] = footageItems;
136
+ }
137
+ }
138
+ this.sendFoldersToMediaEncoder(items);
139
+ };
140
+
141
+ sendFoldersToMediaEncoder = (items: LanguageItems) => {
142
+ const allRQItems: RenderQueueItem[] = [];
143
+ const outputPath = IO.fs.openFolderDialog(`Select output folder`);
144
+ if (!outputPath) {
145
+ return;
146
+ }
147
+ for (const lang in items) {
148
+ const langPath = IO.path.join(outputPath.fsName, lang);
149
+ const folderCreated = IO.fs.createDirectory(langPath);
150
+ const rqItems = KT_Project.render.sendToAME({
151
+ comps: items[lang],
152
+ path: langPath,
153
+ });
154
+ if (rqItems && rqItems.length > 0) {
155
+ allRQItems.push(...rqItems);
156
+ }
157
+ }
158
+ return allRQItems;
159
+ };
95
160
  }
96
161
 
97
162
  const KT_FP_Utils = new __KT_FP_Utils();