From f1fb41d77ca33531df41ad173b416bb7557489ea Mon Sep 17 00:00:00 2001 From: Wesnydy Ribeiro Date: Wed, 23 Mar 2016 11:06:58 -0300 Subject: [PATCH] Alteração do recodificador --- extrator/src/extratorSRT.cpp | 21 +++++++++------------ extrator/src/extratorTXT.cpp | 19 ++++++++----------- extrator/src/extratorVTT.cpp | 21 +++++++++------------ extrator/src/include/extratorSRT.h | 1 - extrator/src/include/extratorTXT.h | 2 -- extrator/src/include/extratorVTT.h | 1 - log/log | 3 --- 7 files changed, 26 insertions(+), 42 deletions(-) diff --git a/extrator/src/extratorSRT.cpp b/extrator/src/extratorSRT.cpp index 5b68e3d..4ccc2c4 100644 --- a/extrator/src/extratorSRT.cpp +++ b/extrator/src/extratorSRT.cpp @@ -1,5 +1,4 @@ #include "extratorSRT.h" -#include ExtratorSRT::ExtratorSRT(){ listeners = new list(); @@ -34,18 +33,16 @@ void ExtratorSRT::notifyEndExtraction(int size) { } void ExtratorSRT::encodingfiletoUTF8() { - string iconvcmd = "iconv -f"; //Recodifica o arquivo para utf-8 + string recmd = "recode "; + recmd.append("$(file --mime-encoding -b ") + .append(this->filePath).append(")..utf-8 ") + .append(this->filePath); + system(recmd.c_str()); - iconvcmd.append(" $(file --mime-encoding -b ") - .append(this->filePath).append(") -t utf-8 ") - .append(this->filePath).append(" > ").append(TEMP_SRT); - system(iconvcmd.c_str()); + string sedcmd = "sed -i 's/.$//' "; + sedcmd.append(this->filePath); + system(sedcmd.c_str()); - string perlcmd = "perl -p -e 's/\r$//' < "; //Formata a quebra de linha - - perlcmd.append(TEMP_SRT).append(" > ").append(this->filePath) - .append(" && rm -f ").append(TEMP_SRT); - system(perlcmd.c_str()); } void ExtratorSRT::setFilePath(char* path) { @@ -62,7 +59,7 @@ void ExtratorSRT::initialize(){ }catch(Exception &ex){ finish = true; Logging::instance()->writeLog("extratorSRT.cpp : Arquivo de legenda não encontrado."); - throw lavidlib::RuntimeException("Falha ao abrir o arquivo de legenda! Verifique se o mesmo existe.\n"); + throw ExtratorException("Falha ao abrir o arquivo de legenda! Verifique se o mesmo existe.\n"); } this->Start(); diff --git a/extrator/src/extratorTXT.cpp b/extrator/src/extratorTXT.cpp index 81b4bc9..582bca0 100644 --- a/extrator/src/extratorTXT.cpp +++ b/extrator/src/extratorTXT.cpp @@ -44,18 +44,15 @@ void ExtratorTXT::notifyEndExtraction(int size) { } void ExtratorTXT::encodingfiletoUTF8() { - string iconvcmd = "iconv -f"; //Recodifica o arquivo para utf-8 + string recmd = "recode "; + recmd.append("$(file --mime-encoding -b ") + .append(this->filePath).append(")..utf-8 ") + .append(this->filePath); + system(recmd.c_str()); - iconvcmd.append(" $(file --mime-encoding -b ") - .append(this->filePath).append(") -t utf-8 ") - .append(this->filePath).append(" > ").append(TEMP_TXT); - system(iconvcmd.c_str()); - - string perlcmd = "perl -p -e 's/\r$//' < "; //Formata a quebra de linha - - perlcmd.append(TEMP_TXT).append(" > ").append(this->filePath) - .append(" && rm -f ").append(TEMP_TXT); - system(perlcmd.c_str()); + string sedcmd = "sed -i 's/.$//' "; + sedcmd.append(this->filePath); + system(sedcmd.c_str()); } void ExtratorTXT::setFilePath(char* path){ diff --git a/extrator/src/extratorVTT.cpp b/extrator/src/extratorVTT.cpp index 9f28b22..e6e6edf 100644 --- a/extrator/src/extratorVTT.cpp +++ b/extrator/src/extratorVTT.cpp @@ -33,18 +33,15 @@ void ExtratorVTT::notifyEndExtraction(int size) { } void ExtratorVTT::encodingfiletoUTF8() { - string iconvcmd = "iconv -f"; //Recodifica o arquivo para utf-8 - - iconvcmd.append(" $(file --mime-encoding -b ") - .append(this->filePath).append(") -t utf-8 ") - .append(this->filePath).append(" > ").append(TEMP_SRT); - system(iconvcmd.c_str()); - - string perlcmd = "perl -p -e 's/\r$//' < "; //Formata a quebra de linha - - perlcmd.append(TEMP_SRT).append(" > ").append(this->filePath) - .append(" && rm -f ").append(TEMP_SRT); - system(perlcmd.c_str()); + string recmd = "recode "; + recmd.append("$(file --mime-encoding -b ") + .append(this->filePath).append(")..utf-8 ") + .append(this->filePath); + system(recmd.c_str()); + + string sedcmd = "sed -i 's/.$//' "; + sedcmd.append(this->filePath); + system(sedcmd.c_str()); } void ExtratorVTT::setFilePath(char* path) { diff --git a/extrator/src/include/extratorSRT.h b/extrator/src/include/extratorSRT.h index 43b1c25..ecd8c65 100644 --- a/extrator/src/include/extratorSRT.h +++ b/extrator/src/include/extratorSRT.h @@ -23,7 +23,6 @@ #define TARGET_TIME "-->" #define LESS_THAN "<" #define MORE_THAN ">" -#define TEMP_SRT "/tmp/tempsrt.srt" //#define MAX_LINE 1024 using namespace jthread; diff --git a/extrator/src/include/extratorTXT.h b/extrator/src/include/extratorTXT.h index 7b449b0..4160e8a 100644 --- a/extrator/src/include/extratorTXT.h +++ b/extrator/src/include/extratorTXT.h @@ -14,8 +14,6 @@ #include "listenerTXT.h" #include "extratorException.h" -#define TEMP_TXT "/tmp/temptxt.txt" - using namespace jthread; using namespace std; diff --git a/extrator/src/include/extratorVTT.h b/extrator/src/include/extratorVTT.h index 28ee0bf..f9d1819 100644 --- a/extrator/src/include/extratorVTT.h +++ b/extrator/src/include/extratorVTT.h @@ -16,7 +16,6 @@ #define LESS_THAN "<" #define MORE_THAN ">" #define SIZE_SCAPE 1 -#define TEMP_SRT "/tmp/tempsrt.srt" using namespace std; using namespace sndesc; diff --git a/log/log b/log/log index b28b04f..e69de29 100644 --- a/log/log +++ b/log/log @@ -1,3 +0,0 @@ - - - -- libgit2 0.21.2