Search in sources :

Example 1 with TmdbTools2

use of com.battlelancer.seriesguide.tmdbapi.TmdbTools2 in project SeriesGuide by UweTrottmann.

the class SgPicassoRequestHandler method load.

@Override
public Result load(Request request, int networkPolicy) throws IOException {
    String scheme = request.uri.getScheme();
    String host = request.uri.getHost();
    if (host == null)
        return null;
    if (SCHEME_SHOW_TMDB.equals(scheme)) {
        int showTmdbId = Integer.parseInt(host);
        String language = request.uri.getQueryParameter(QUERY_LANGUAGE);
        if (language == null || language.length() == 0) {
            language = DisplaySettings.LANGUAGE_EN;
        }
        TvShow showDetails = new TmdbTools2().getShowDetails(showTmdbId, language, context);
        if (showDetails != null) {
            String url = ImageTools.tmdbOrTvdbPosterUrl(showDetails.poster_path, context, false);
            if (url != null) {
                return loadFromNetwork(Uri.parse(url), networkPolicy);
            }
        }
    }
    if (SCHEME_MOVIE_TMDB.equals(scheme)) {
        int movieTmdbId = Integer.valueOf(host);
        MovieTools movieTools = SgApp.getServicesComponent(context).movieTools();
        Movie movieSummary = movieTools.getMovieSummary(movieTmdbId);
        if (movieSummary != null && movieSummary.poster_path != null) {
            final String imageUrl = TmdbSettings.getImageBaseUrl(context) + TmdbSettings.POSTER_SIZE_SPEC_W342 + movieSummary.poster_path;
            return loadFromNetwork(Uri.parse(imageUrl), networkPolicy);
        }
    }
    return null;
}
Also used : Movie(com.uwetrottmann.tmdb2.entities.Movie) TvShow(com.uwetrottmann.tmdb2.entities.TvShow) MovieTools(com.battlelancer.seriesguide.ui.movies.MovieTools) TmdbTools2(com.battlelancer.seriesguide.tmdbapi.TmdbTools2)

Example 2 with TmdbTools2

use of com.battlelancer.seriesguide.tmdbapi.TmdbTools2 in project SeriesGuide by UweTrottmann.

the class HexagonShowSync method mapLegacyShows.

/**
 * Returns null on network error while looking up TMDB ID.
 */
@Nullable
private List<SgCloudShow> mapLegacyShows(List<Show> legacyShows) {
    List<SgCloudShow> shows = new ArrayList<>();
    for (Show legacyShow : legacyShows) {
        Integer showTvdbId = legacyShow.getTvdbId();
        if (showTvdbId == null || showTvdbId <= 0) {
            continue;
        }
        Integer showTmdbIdOrNull = new TmdbTools2().findShowTmdbId(context, showTvdbId);
        if (showTmdbIdOrNull == null) {
            // Network error, abort.
            return null;
        }
        // Only add if TMDB id found
        if (showTmdbIdOrNull != -1) {
            SgCloudShow show = new SgCloudShow();
            show.setTmdbId(showTmdbIdOrNull);
            show.setIsRemoved(legacyShow.getIsRemoved());
            show.setIsFavorite(legacyShow.getIsFavorite());
            show.setNotify(legacyShow.getNotify());
            show.setIsHidden(legacyShow.getIsHidden());
            show.setLanguage(legacyShow.getLanguage());
            shows.add(show);
        }
    }
    return shows;
}
Also used : SgCloudShow(com.uwetrottmann.seriesguide.backend.shows.model.SgCloudShow) TmdbTools2(com.battlelancer.seriesguide.tmdbapi.TmdbTools2) ArrayList(java.util.ArrayList) SgCloudShow(com.uwetrottmann.seriesguide.backend.shows.model.SgCloudShow) Show(com.uwetrottmann.seriesguide.backend.shows.model.Show) Nullable(androidx.annotation.Nullable)

Aggregations

TmdbTools2 (com.battlelancer.seriesguide.tmdbapi.TmdbTools2)2 Nullable (androidx.annotation.Nullable)1 MovieTools (com.battlelancer.seriesguide.ui.movies.MovieTools)1 SgCloudShow (com.uwetrottmann.seriesguide.backend.shows.model.SgCloudShow)1 Show (com.uwetrottmann.seriesguide.backend.shows.model.Show)1 Movie (com.uwetrottmann.tmdb2.entities.Movie)1 TvShow (com.uwetrottmann.tmdb2.entities.TvShow)1 ArrayList (java.util.ArrayList)1