Skip to content

Commit 63f8d0a

Browse files
committed
Split into missing and non missing footage arrays
1 parent 428e782 commit 63f8d0a

File tree

5 files changed

+43
-18
lines changed

5 files changed

+43
-18
lines changed

plainly-aescripts/src/collect.ts

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Font, Footage } from 'plainly-types';
1+
import type { Font, Footage, MissingFootage } from 'plainly-types';
22
import { getAllComps, getFolderPath, getTextLayersByComp } from './utils';
33

44
/**
@@ -20,14 +20,21 @@ function selectFolder(): Folder | string {
2020
* @returns {string|undefined} The name of the collected project folder, or undefined if no project is saved.
2121
*/
2222
function collectFiles(): string | undefined {
23-
const collectedData: { fonts: Font[]; footage: Footage[] } = {
23+
const collectedData: {
24+
fonts: Font[];
25+
footage: Footage[];
26+
missingFootage: MissingFootage[];
27+
} = {
2428
fonts: [],
2529
footage: [],
30+
missingFootage: [],
2631
};
2732

2833
// collect paths
2934
collectedData.fonts = collectFonts();
30-
collectedData.footage = collectFootage();
35+
const { footage, missingFootage } = collectFootage();
36+
collectedData.footage = footage;
37+
collectedData.missingFootage = missingFootage;
3138

3239
// return full path
3340
return JSON.stringify(collectedData);
@@ -61,8 +68,12 @@ function collectFonts(): Font[] {
6168
return Object.values(fonts);
6269
}
6370

64-
function collectFootage(): Footage[] {
71+
function collectFootage(): {
72+
footage: Footage[];
73+
missingFootage: MissingFootage[];
74+
} {
6575
const footage: Footage[] = [];
76+
const missingFootage: MissingFootage[] = [];
6677

6778
// Go through all items in the project
6879
for (let i = 1; i <= app.project.numItems; i++) {
@@ -74,16 +85,24 @@ function collectFootage(): Footage[] {
7485
// Determine the nested folder structure
7586
const relativePath = getFolderPath(item.parentFolder);
7687

77-
footage.push({
78-
itemId: item.id,
79-
itemName: item.file?.name || '',
80-
itemFsPath: item.file?.fsName || '',
81-
itemAeFolder: relativePath,
82-
isMissing: item.footageMissing || item.file === null,
83-
});
88+
if (item.footageMissing || item.file === null) {
89+
missingFootage.push({
90+
itemId: item.id,
91+
itemAeFolder: relativePath,
92+
isMissing: true,
93+
});
94+
} else {
95+
footage.push({
96+
itemId: item.id,
97+
itemName: item.file.name,
98+
itemFsPath: item.file.fsName,
99+
itemAeFolder: relativePath,
100+
isMissing: false,
101+
});
102+
}
84103
}
85104

86-
return footage;
105+
return { footage, missingFootage };
87106
}
88107

89108
export { collectFiles, selectFolder };

plainly-aescripts/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function getInstalledFontsByFamilyNameAndStyleName(
110110
});
111111
}
112112
return JSON.stringify(fontData);
113-
} catch (_error) {
113+
} catch {
114114
return undefined;
115115
}
116116
}

plainly-plugin/src/node/collectProject/collectProject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async function makeProjectZip(targetPath: string): Promise<string> {
8282
// 1. Collect project data
8383
const projectInfo = await AeScriptsApi.collectFiles();
8484

85-
validateFootage(projectInfo.footage);
85+
validateFootage(projectInfo.footage, projectInfo.missingFootage);
8686
await validateFonts(projectInfo.fonts);
8787

8888
const hasLongFootagePaths = projectInfo.footage.some((item) => {

plainly-plugin/src/node/collectProject/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Font, Footage } from 'plainly-types';
1+
import type { Font, Footage, MissingFootage } from 'plainly-types';
22
import { AeScriptsApi } from '../bridge';
33

44
async function validateFonts(fonts: Font[]) {
@@ -34,9 +34,8 @@ async function validateFonts(fonts: Font[]) {
3434
}
3535
}
3636

37-
function validateFootage(footage: Footage[]) {
37+
function validateFootage(_: Footage[], missingFootage: MissingFootage[]) {
3838
// Throw in case of missing footage
39-
const missingFootage = footage.filter((item) => item.isMissing);
4039
if (missingFootage.length > 0) {
4140
// TODO: Show a missing files
4241
throw new Error('Some footage files are missing from the project.');

plainly-types/src/collect.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
interface MissingFootage {
2+
itemId: number;
3+
itemAeFolder: string;
4+
isMissing: boolean;
5+
}
6+
17
interface Footage {
28
itemId: number;
39
itemName: string;
@@ -16,6 +22,7 @@ interface Font {
1622
interface ProjectInfo {
1723
fonts: Font[];
1824
footage: Footage[];
25+
missingFootage: MissingFootage[];
1926
}
2027

21-
export type { Footage, Font, ProjectInfo };
28+
export type { Footage, MissingFootage, Font, ProjectInfo };

0 commit comments

Comments
 (0)