Commit f1fb41d77ca33531df41ad173b416bb7557489ea
1 parent
aa995730
Exists in
master
and in
1 other branch
Alteração do recodificador
Showing
7 changed files
with
26 additions
and
42 deletions
Show diff stats
extrator/src/extratorSRT.cpp
1 | 1 | #include "extratorSRT.h" |
2 | -#include <iostream> | |
3 | 2 | |
4 | 3 | ExtratorSRT::ExtratorSRT(){ |
5 | 4 | listeners = new list<ListenerSub*>(); |
... | ... | @@ -34,18 +33,16 @@ void ExtratorSRT::notifyEndExtraction(int size) { |
34 | 33 | } |
35 | 34 | |
36 | 35 | void ExtratorSRT::encodingfiletoUTF8() { |
37 | - string iconvcmd = "iconv -f"; //Recodifica o arquivo para utf-8 | |
36 | + string recmd = "recode "; | |
37 | + recmd.append("$(file --mime-encoding -b ") | |
38 | + .append(this->filePath).append(")..utf-8 ") | |
39 | + .append(this->filePath); | |
40 | + system(recmd.c_str()); | |
38 | 41 | |
39 | - iconvcmd.append(" $(file --mime-encoding -b ") | |
40 | - .append(this->filePath).append(") -t utf-8 ") | |
41 | - .append(this->filePath).append(" > ").append(TEMP_SRT); | |
42 | - system(iconvcmd.c_str()); | |
42 | + string sedcmd = "sed -i 's/.$//' "; | |
43 | + sedcmd.append(this->filePath); | |
44 | + system(sedcmd.c_str()); | |
43 | 45 | |
44 | - string perlcmd = "perl -p -e 's/\r$//' < "; //Formata a quebra de linha | |
45 | - | |
46 | - perlcmd.append(TEMP_SRT).append(" > ").append(this->filePath) | |
47 | - .append(" && rm -f ").append(TEMP_SRT); | |
48 | - system(perlcmd.c_str()); | |
49 | 46 | } |
50 | 47 | |
51 | 48 | void ExtratorSRT::setFilePath(char* path) { |
... | ... | @@ -62,7 +59,7 @@ void ExtratorSRT::initialize(){ |
62 | 59 | }catch(Exception &ex){ |
63 | 60 | finish = true; |
64 | 61 | Logging::instance()->writeLog("extratorSRT.cpp <Error>: Arquivo de legenda não encontrado."); |
65 | - throw lavidlib::RuntimeException("Falha ao abrir o arquivo de legenda! Verifique se o mesmo existe.\n"); | |
62 | + throw ExtratorException("Falha ao abrir o arquivo de legenda! Verifique se o mesmo existe.\n"); | |
66 | 63 | } |
67 | 64 | this->Start(); |
68 | 65 | ... | ... |
extrator/src/extratorTXT.cpp
... | ... | @@ -44,18 +44,15 @@ void ExtratorTXT::notifyEndExtraction(int size) { |
44 | 44 | } |
45 | 45 | |
46 | 46 | void ExtratorTXT::encodingfiletoUTF8() { |
47 | - string iconvcmd = "iconv -f"; //Recodifica o arquivo para utf-8 | |
47 | + string recmd = "recode "; | |
48 | + recmd.append("$(file --mime-encoding -b ") | |
49 | + .append(this->filePath).append(")..utf-8 ") | |
50 | + .append(this->filePath); | |
51 | + system(recmd.c_str()); | |
48 | 52 | |
49 | - iconvcmd.append(" $(file --mime-encoding -b ") | |
50 | - .append(this->filePath).append(") -t utf-8 ") | |
51 | - .append(this->filePath).append(" > ").append(TEMP_TXT); | |
52 | - system(iconvcmd.c_str()); | |
53 | - | |
54 | - string perlcmd = "perl -p -e 's/\r$//' < "; //Formata a quebra de linha | |
55 | - | |
56 | - perlcmd.append(TEMP_TXT).append(" > ").append(this->filePath) | |
57 | - .append(" && rm -f ").append(TEMP_TXT); | |
58 | - system(perlcmd.c_str()); | |
53 | + string sedcmd = "sed -i 's/.$//' "; | |
54 | + sedcmd.append(this->filePath); | |
55 | + system(sedcmd.c_str()); | |
59 | 56 | } |
60 | 57 | |
61 | 58 | void ExtratorTXT::setFilePath(char* path){ | ... | ... |
extrator/src/extratorVTT.cpp
... | ... | @@ -33,18 +33,15 @@ void ExtratorVTT::notifyEndExtraction(int size) { |
33 | 33 | } |
34 | 34 | |
35 | 35 | void ExtratorVTT::encodingfiletoUTF8() { |
36 | - string iconvcmd = "iconv -f"; //Recodifica o arquivo para utf-8 | |
37 | - | |
38 | - iconvcmd.append(" $(file --mime-encoding -b ") | |
39 | - .append(this->filePath).append(") -t utf-8 ") | |
40 | - .append(this->filePath).append(" > ").append(TEMP_SRT); | |
41 | - system(iconvcmd.c_str()); | |
42 | - | |
43 | - string perlcmd = "perl -p -e 's/\r$//' < "; //Formata a quebra de linha | |
44 | - | |
45 | - perlcmd.append(TEMP_SRT).append(" > ").append(this->filePath) | |
46 | - .append(" && rm -f ").append(TEMP_SRT); | |
47 | - system(perlcmd.c_str()); | |
36 | + string recmd = "recode "; | |
37 | + recmd.append("$(file --mime-encoding -b ") | |
38 | + .append(this->filePath).append(")..utf-8 ") | |
39 | + .append(this->filePath); | |
40 | + system(recmd.c_str()); | |
41 | + | |
42 | + string sedcmd = "sed -i 's/.$//' "; | |
43 | + sedcmd.append(this->filePath); | |
44 | + system(sedcmd.c_str()); | |
48 | 45 | } |
49 | 46 | |
50 | 47 | void ExtratorVTT::setFilePath(char* path) { | ... | ... |
extrator/src/include/extratorSRT.h
extrator/src/include/extratorTXT.h
extrator/src/include/extratorVTT.h
log/log