-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetlistBuilder.cpp
More file actions
86 lines (66 loc) · 2.16 KB
/
SetlistBuilder.cpp
File metadata and controls
86 lines (66 loc) · 2.16 KB
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
#include "SongFile.h"
#include "ASSFile.h"
#include <iostream>
#include <string>
#define STYLED_PATH "test\\Colored\\"
#define EN_PATH "test\\EN\\"
#define K_PATH "test\\Karaoke\\"
std::string convertWhitespaceToUnderscore(std::string input);
std::string removeExtension(std::string input);
int main(int argc, char* argv[])
{
if (argc < 3)
{
std::cout << "Please include input file and styles..." << std::endl;
return 1;
}
std::string setlistFileName = argv[1];
std::string stylesFileName = argv[2];
try
{
std::cout << "Loading setlist..." << std::endl;
ASSFileWithSwitch setlist(setlistFileName);
ASSFileWithSwitch output;
output.readPreprocessLines(stylesFileName);
for (ASSLine currSong : setlist.getLines())
{
if (!currSong.isComment())
{
std::string songTitle = currSong.getText();
std::string parsedSongTitle = convertWhitespaceToUnderscore(songTitle);
std::cout << "Processing " << songTitle << "..." << std::endl;
SongFile currSongFile(STYLED_PATH + parsedSongTitle + ".ass",
K_PATH + parsedSongTitle + ".ass",
EN_PATH + parsedSongTitle + ".txt",
stylesFileName);
ASSTime offset = currSong.getStart() - currSongFile.getStart();
currSongFile.offsetFile(offset);
output.appendFile(currSongFile.getFile());
}
}
std::string outputFileName = removeExtension(setlistFileName) + "_OUT.ass";
output.printASSFile(outputFileName);
}
catch (const char* exception)
{
std::cerr << exception << std::endl;
}
return 0;
}
std::string convertWhitespaceToUnderscore(std::string input)
{
std::string output = "";
for (char c : input)
{
if (c == ' ') output += '_';
else output += c;
}
return output;
}
std::string removeExtension(std::string input)
{
std::string output = input;
for (int i = 0; i < 4; i++)
output.pop_back();
return output;
}