_filesManager = filesManager;
_log = logManager;
}
public void downloadSubTitles() {
SubTitleManager subManager = new SubTitleManager(_config, _log);
_log.initiateDownloading();
try {
List<VideoFileVO> listVideo = _filesManager.getVideosWithoutSubTitles();
// Pega os Handlers
HashMap<IDownloadHandler, DownloadHandlerVO> downloadHandlers = _config.getDownloadHandlers();
// Vê se acha a bagaça nos Handlers
for (Map.Entry<IDownloadHandler, DownloadHandlerVO> handler : downloadHandlers.entrySet()) {
if (listVideo.isEmpty()) {
break;
}
// Pego as legendas para os filmes
try {
subManager.setListaVideo(listVideo);
subManager.downloadSubTitles(handler.getKey(), handler.getValue());
for (VideoFileVO videoVO : subManager.getListaVideoSaved())
_log.SavedSubTitle(videoVO.getFileName(), videoVO.getSubTitleVO().getFileName(), handler.getKey().getDescription());
} catch (Exception e) {
_log.ServerError(handler.getKey().getDescription(), e);
}
// Tira os que consegui pegar a legenda, os que sobraram vão para o próximo loop no próximo handler