Commit f1fb41d77ca33531df41ad173b416bb7557489ea

Authored by Wesnydy Ribeiro
1 parent aa995730
Exists in master and in 1 other branch devel

Alteração do recodificador

extrator/src/extratorSRT.cpp
1 #include "extratorSRT.h" 1 #include "extratorSRT.h"
2 -#include <iostream>  
3 2
4 ExtratorSRT::ExtratorSRT(){ 3 ExtratorSRT::ExtratorSRT(){
5 listeners = new list<ListenerSub*>(); 4 listeners = new list<ListenerSub*>();
@@ -34,18 +33,16 @@ void ExtratorSRT::notifyEndExtraction(int size) { @@ -34,18 +33,16 @@ void ExtratorSRT::notifyEndExtraction(int size) {
34 } 33 }
35 34
36 void ExtratorSRT::encodingfiletoUTF8() { 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 void ExtratorSRT::setFilePath(char* path) { 48 void ExtratorSRT::setFilePath(char* path) {
@@ -62,7 +59,7 @@ void ExtratorSRT::initialize(){ @@ -62,7 +59,7 @@ void ExtratorSRT::initialize(){
62 }catch(Exception &ex){ 59 }catch(Exception &ex){
63 finish = true; 60 finish = true;
64 Logging::instance()->writeLog("extratorSRT.cpp <Error>: Arquivo de legenda não encontrado."); 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 this->Start(); 64 this->Start();
68 65
extrator/src/extratorTXT.cpp
@@ -44,18 +44,15 @@ void ExtratorTXT::notifyEndExtraction(int size) { @@ -44,18 +44,15 @@ void ExtratorTXT::notifyEndExtraction(int size) {
44 } 44 }
45 45
46 void ExtratorTXT::encodingfiletoUTF8() { 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 void ExtratorTXT::setFilePath(char* path){ 58 void ExtratorTXT::setFilePath(char* path){
extrator/src/extratorVTT.cpp
@@ -33,18 +33,15 @@ void ExtratorVTT::notifyEndExtraction(int size) { @@ -33,18 +33,15 @@ void ExtratorVTT::notifyEndExtraction(int size) {
33 } 33 }
34 34
35 void ExtratorVTT::encodingfiletoUTF8() { 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 void ExtratorVTT::setFilePath(char* path) { 47 void ExtratorVTT::setFilePath(char* path) {
extrator/src/include/extratorSRT.h
@@ -23,7 +23,6 @@ @@ -23,7 +23,6 @@
23 #define TARGET_TIME "-->" 23 #define TARGET_TIME "-->"
24 #define LESS_THAN "<" 24 #define LESS_THAN "<"
25 #define MORE_THAN ">" 25 #define MORE_THAN ">"
26 -#define TEMP_SRT "/tmp/tempsrt.srt"  
27 //#define MAX_LINE 1024 26 //#define MAX_LINE 1024
28 27
29 using namespace jthread; 28 using namespace jthread;
extrator/src/include/extratorTXT.h
@@ -14,8 +14,6 @@ @@ -14,8 +14,6 @@
14 #include "listenerTXT.h" 14 #include "listenerTXT.h"
15 #include "extratorException.h" 15 #include "extratorException.h"
16 16
17 -#define TEMP_TXT "/tmp/temptxt.txt"  
18 -  
19 using namespace jthread; 17 using namespace jthread;
20 using namespace std; 18 using namespace std;
21 19
extrator/src/include/extratorVTT.h
@@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
16 #define LESS_THAN "<" 16 #define LESS_THAN "<"
17 #define MORE_THAN ">" 17 #define MORE_THAN ">"
18 #define SIZE_SCAPE 1 18 #define SIZE_SCAPE 1
19 -#define TEMP_SRT "/tmp/tempsrt.srt"  
20 19
21 using namespace std; 20 using namespace std;
22 using namespace sndesc; 21 using namespace sndesc;
@@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
1 -  
2 -  
3 -