Commit b5cf8f1c96d5d7db4f0701253b8b07c758008496

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

Adicionado melhorias no componente extrator

extrator/src/extratorSRT.cpp
@@ -11,7 +11,7 @@ ExtratorSRT::ExtratorSRT(){ @@ -11,7 +11,7 @@ ExtratorSRT::ExtratorSRT(){
11 ExtratorSRT::~ExtratorSRT(){ 11 ExtratorSRT::~ExtratorSRT(){
12 listeners->clear(); 12 listeners->clear();
13 delete listeners; 13 delete listeners;
14 - if (bff_reader) delete bff_reader; 14 + //if (bff_reader) delete bff_reader;
15 if (file_io) delete file_io; 15 if (file_io) delete file_io;
16 DDDPRINTF("ExtratorSTR finalized!\n"); 16 DDDPRINTF("ExtratorSTR finalized!\n");
17 } 17 }
@@ -79,13 +79,16 @@ void ExtratorSRT::Run(){ @@ -79,13 +79,16 @@ void ExtratorSRT::Run(){
79 string sub_text = ""; 79 string sub_text = "";
80 80
81 while(hasNextSubtitle()){ 81 while(hasNextSubtitle()){
82 - subtitle = next(); 82 + try{
  83 + subtitle = next();
  84 + }catch(ExtratorException ex){ break; }
83 sub_text = subtitle->getSubtitleText(); 85 sub_text = subtitle->getSubtitleText();
84 notifyListeners((unsigned char*)sub_text.c_str(), calcula_pts((double) subtitle->getTimeIn())); 86 notifyListeners((unsigned char*)sub_text.c_str(), calcula_pts((double) subtitle->getTimeIn()));
85 - //cout << " . ";  
86 sub_index++; 87 sub_index++;
87 free(subtitle); 88 free(subtitle);
88 } 89 }
  90 + if(sub_index == 0)
  91 + notifyListeners((unsigned char*)"ARQUIVO_VAZIO", 0);
89 printf("\n"); 92 printf("\n");
90 finish = true; 93 finish = true;
91 notifyEndExtraction(sub_index); 94 notifyEndExtraction(sub_index);
@@ -142,10 +145,8 @@ Subtitle* ExtratorSRT::next() { @@ -142,10 +145,8 @@ Subtitle* ExtratorSRT::next() {
142 sub->setSubtitleText(text_sub); 145 sub->setSubtitleText(text_sub);
143 delete(bff_reader); 146 delete(bff_reader);
144 return sub; 147 return sub;
145 -  
146 } 148 }
147 -  
148 - 149 +
149 int64_t ExtratorSRT::str_to_time(string str_time) { 150 int64_t ExtratorSRT::str_to_time(string str_time) {
150 151
151 int64_t ttime = 0; 152 int64_t ttime = 0;
extrator/src/extratorTXT.cpp
@@ -91,6 +91,8 @@ void ExtratorTXT::Run(){ @@ -91,6 +91,8 @@ void ExtratorTXT::Run(){
91 line_index++; 91 line_index++;
92 } 92 }
93 }catch (EOFException &ex){ 93 }catch (EOFException &ex){
  94 + if(line_index == 0)
  95 + notifyListeners((unsigned char*)"ARQUIVO_VAZIO");
94 hasNext = false; 96 hasNext = false;
95 }catch (...){ 97 }catch (...){
96 Util::Logger::Instance()->writeLog((char*) "[ERRO: extratorTXT.cpp] Erro durante a leitura do arquivo de texto."); 98 Util::Logger::Instance()->writeLog((char*) "[ERRO: extratorTXT.cpp] Erro durante a leitura do arquivo de texto.");