Search in sources :

Example 1 with TrailerTmdbDTO

use of com.furyviewer.service.dto.TheMovieDB.Trailer.TrailerTmdbDTO 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();
        }
    }
}
Also used : Social(com.furyviewer.domain.Social) TrailerTmdbDTO(com.furyviewer.service.dto.TheMovieDB.Trailer.TrailerTmdbDTO) IOException(java.io.IOException) Result(com.furyviewer.service.dto.TheMovieDB.Trailer.Result)

Example 2 with TrailerTmdbDTO

use of com.furyviewer.service.dto.TheMovieDB.Trailer.TrailerTmdbDTO 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();
        }
    }
}
Also used : Social(com.furyviewer.domain.Social) TrailerTmdbDTO(com.furyviewer.service.dto.TheMovieDB.Trailer.TrailerTmdbDTO) IOException(java.io.IOException) Result(com.furyviewer.service.dto.TheMovieDB.Trailer.Result)

Aggregations

Social (com.furyviewer.domain.Social)2 Result (com.furyviewer.service.dto.TheMovieDB.Trailer.Result)2 TrailerTmdbDTO (com.furyviewer.service.dto.TheMovieDB.Trailer.TrailerTmdbDTO)2 IOException (java.io.IOException)2