-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpptLyricsConverter.ts
115 lines (96 loc) · 3.42 KB
/
pptLyricsConverter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import fs from 'fs';
import path from 'path';
import fsExtra from 'fs-extra';
import recursive from 'recursive-readdir';
import chalk from 'chalk';
import dotenv from 'dotenv';
import { processPPTFileAndConvertToTxt } from './src/pptLyricsParser';
import { TXT_EXTENSION } from './src/constants';
import { logFileWithLinkInConsole } from './src/utils';
import process from 'process';
dotenv.config();
const cleanOutputDirAndProcessFrom = async (
sourceDir: string,
outputDir: string,
) => {
fsExtra.emptyDirSync(outputDir);
(await recursive(sourceDir, ['.DS_Store']))
.filter((filePath) => path.extname(filePath) === '.pptx')
.filter(
(filePath) =>
!path.basename(filePath).includes('Icon') &&
!path.basename(filePath).startsWith('$'),
)
.forEach((filePath: string) => {
const fileName = path.basename(filePath);
const data = fs.readFileSync(filePath);
console.log(chalk.cyan(`Processing "${path.basename(filePath)}".`));
logFileWithLinkInConsole(filePath);
const { exportFileName, basicTemplate } = processPPTFileAndConvertToTxt(
data,
fileName,
);
fs.writeFileSync(
`${outputDir}/${exportFileName}${TXT_EXTENSION}`,
basicTemplate!,
);
});
};
(async () => {
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Cor de copii Dynamis/PPT`,
'./out/cor_copii_ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Cantari Beni`,
'./out/cantari_beni_ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Cantari fanfara`,
'./out/cantari_fanfara_ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Grupul Betel`,
'./out/grupul_bethel__ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Grupul Ekklesia`,
'./out/grupul_ekklesia__ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Grupul Petras`,
'./out/grupul_petras__ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Cor Barbatesc`,
'./out/cor_barbatesc__ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Cantari Florin/(florin colinde)`,
'./out/fc_colinde__ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Cantari Florin/(florin rusalii)`,
'./out/fc_rusalii__ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Cantari Florin/(florin staruinta)`,
'./out/fc_staruinta__ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Cantari Florin/[florin toate cantarile]`,
'./out/fc_toate_cantarile__ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Cantari Florin/Cantari cu LOGO-ul bisericii`,
'./out/fc_cu_logo__ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Cantari Florin/Cantari cu LOGO-ul bisericii`,
'./out/fc_cu_logo__ppt',
);
await cleanOutputDirAndProcessFrom(
`${process.env.FOLDER_INPUT_BES_CLOUD_PPT_SONGS}/Cantari Florin/Cantari cu LOGO-ul bisericii`,
'./out/gramada__ppt',
);
})();