kt-forpro-tools 1.0.10 → 1.0.12

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.10",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "author": "Miguel de Mendoza",
6
6
  "main": "src/index.ts",
@@ -10,8 +10,12 @@ 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
+ // const folder = Folder.selectDialog("Select a folder with language subfolders");
17
+ // $.writeln("Selected folder: " + folder?.fsName);
18
+ // KT_ForproTools.utils.precompAndKeyOut("cat");
15
19
  // KT_ForproTools.utils.createCleanupStructure();
16
20
 
17
21
  // 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,20 +24,17 @@ function generateProjectStructure(
19
24
  return newFolder;
20
25
  }
21
26
 
22
- export function createCleanupStructure(name: string = "Project"): FolderItem {
23
- return generateProjectStructure(
24
- {
25
- src: {
26
- esp: {},
27
- cat: {},
28
- },
29
- outputs: {
30
- esp: {},
31
- cat: {},
32
- },
27
+ export function createCleanupStructure(): FolderItem {
28
+ return generateProjectStructure({
29
+ src: {
30
+ esp: {},
31
+ cat: {},
33
32
  },
34
- name + " Cleanup"
35
- );
33
+ outputs: {
34
+ esp: {},
35
+ cat: {},
36
+ },
37
+ });
36
38
  }
37
39
 
38
40
  class __KT_FP_Utils {
@@ -73,9 +75,13 @@ class __KT_FP_Utils {
73
75
  precompAndKeyOut = (lang: string = "esp") => {
74
76
  const footagePaths = [KT_Project.path.join("//src", lang)];
75
77
  const footageItems = KT_Project.find.footage({ relativePath: footagePaths });
76
- const parenFolderPath = KT_Project.path.join("//outputs", lang);
77
- const parentFolder = KT_Project.find.folders(parenFolderPath)[0] || app.project.rootFolder;
78
+ if (footageItems.length === 0) {
79
+ return;
80
+ }
78
81
  const createdComps = this.cleanNamePrecomp(footageItems);
82
+
83
+ const outputFolderPath = KT_Project.path.join("//outputs", lang);
84
+ const parentFolder = KT_Project.find.folders(outputFolderPath)[0] || app.project.rootFolder;
79
85
  KT_Project.move.move(createdComps, parentFolder);
80
86
  const presetsPath = IO.path.sanitize(
81
87
  "C:/Users/orson/Documents/Adobe/After Effects 2025/User Presets/IEF_Chroma.ffx"
@@ -91,6 +97,55 @@ class __KT_FP_Utils {
91
97
  layer.selected = false;
92
98
  }
93
99
  };
100
+
101
+ sendCleanupToMediaEncoder = (langs: string[] = ["esp"]) => {
102
+ const items: FolderItem[] = KT_Project.find.folders("outputs");
103
+ this.sendLanguagesToMediaEncoder(items);
104
+ };
105
+
106
+ sendLanguagesToMediaEncoder = (selectedItems: _ItemClasses | _ItemClasses[] = app.project.selection) => {
107
+ if (!(selectedItems instanceof Array)) {
108
+ selectedItems = [selectedItems];
109
+ }
110
+ if (selectedItems.length === 0 || !is.folder(selectedItems[0])) {
111
+ return;
112
+ }
113
+ const langFolders = KT_Project.find.folders({ root: selectedItems[0] as FolderItem });
114
+ const langs = langFolders.map((folder) => folder.name);
115
+ const parentPath = KT_Project.path.get(selectedItems[0] as FolderItem);
116
+ const items: LanguageItems = {};
117
+ for (const lang of langs) {
118
+ const footagePaths = [KT_Project.path.join(parentPath, lang)];
119
+ const footageItems = KT_Project.find.comps({ relativePath: footagePaths });
120
+ if (footageItems.length > 0) {
121
+ if (!items[lang]) {
122
+ items[lang] = [];
123
+ }
124
+ items[lang] = footageItems;
125
+ }
126
+ }
127
+ this.sendFoldersToMediaEncoder(items);
128
+ };
129
+
130
+ sendFoldersToMediaEncoder = (items: LanguageItems) => {
131
+ const allRQItems: RenderQueueItem[] = [];
132
+ const outputPath = IO.fs.openFolderDialog(`Select output folder`);
133
+ if (!outputPath) {
134
+ return;
135
+ }
136
+ for (const lang in items) {
137
+ const langPath = IO.path.join(outputPath.fsName, lang);
138
+ const folderCreated = IO.fs.createDirectory(langPath);
139
+ const rqItems = KT_Project.render.sendToAME({
140
+ comps: items[lang],
141
+ path: langPath,
142
+ });
143
+ if (rqItems && rqItems.length > 0) {
144
+ allRQItems.push(...rqItems);
145
+ }
146
+ }
147
+ return allRQItems;
148
+ };
94
149
  }
95
150
 
96
151
  const KT_FP_Utils = new __KT_FP_Utils();