use of com.furyviewer.service.dto.TheMovieDB.Trailer.Result in project FuryViewer by TheDoctor-95.
the class TrailerTmdbDTOService method importMovieTrailer.
/**
* Se convierte el trailer de la movie del formato de la api TMDB al formato de FuryViewer.
* @param movie Movie | Movie de la que se quiere encontrar el trailer.
*/
public void importMovieTrailer(Movie movie) {
Social social = new Social();
int id = movieTmdbDTOService.getIdTmdbMovie(movie.getName());
if (id != -1) {
Call<TrailerTmdbDTO> callTrailer = apiTMDB.getMovieTrailer(id, apikey);
try {
Response<TrailerTmdbDTO> response = callTrailer.execute();
if (response.isSuccessful()) {
TrailerTmdbDTO trailerRes = response.body();
if (!trailerRes.getResults().isEmpty()) {
int size = trailerRes.getResults().get(0).getSize();
List<Result> resultTrailer = trailerRes.getResults();
// Buscamos el trailer con mejor resoluciĆ³n.
for (Result trailer : resultTrailer) {
if (size <= trailer.getSize()) {
social.setUrl(pathVideo + trailer.getKey());
social.setType("Trailer");
social.setMovie(movie);
size = trailer.getSize();
}
}
socialRepository.save(social);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of com.furyviewer.service.dto.TheMovieDB.Trailer.Result in project FuryViewer by TheDoctor-95.
the class TrailerTmdbDTOService method importSeriesTrailer.
/**
* Se convierte el trailer de la series del formato de la api TMDB al formato de FuryViewer.
* @param ss Series | Series de la que se quiere encontrar el trailer.
*/
public void importSeriesTrailer(Series ss) {
Social social = new Social();
int id = seriesTmdbDTOService.getIdTmdbSeries(ss.getName());
if (id != -1) {
Call<TrailerTmdbDTO> callTrailer = apiTMDB.getSeriesTrailer(id, apikey);
try {
Response<TrailerTmdbDTO> response = callTrailer.execute();
if (response.isSuccessful()) {
TrailerTmdbDTO trailerRes = response.body();
if (!trailerRes.getResults().isEmpty()) {
int size = trailerRes.getResults().get(0).getSize();
List<Result> resultTrailer = trailerRes.getResults();
// Buscamos el trailer con mejor resoluciĆ³n.
for (Result trailer : resultTrailer) {
if (size <= trailer.getSize()) {
social.setUrl(pathVideo + trailer.getKey());
social.setType("Trailer");
social.setSeries(ss);
size = trailer.getSize();
}
}
socialRepository.save(social);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Aggregations