use of com.uwetrottmann.trakt5.entities.Movie in project SeriesGuide by UweTrottmann.
the class MovieTools method loadSummaryFromTmdb.
@Nullable
private com.uwetrottmann.tmdb2.entities.Movie loadSummaryFromTmdb(@Nullable String languageCode, String regionCode, int movieTmdbId) {
// try to get local movie summary
Movie movie = getMovieSummary("get local movie summary", languageCode, movieTmdbId, true);
if (movie != null && !TextUtils.isEmpty(movie.overview)) {
movieTools2.updateReleaseDateForRegion(movie, movie.release_dates, regionCode);
return movie;
}
// fall back to default language if TMDb has no localized text
Movie movieFallback = getMovieSummary("get default movie summary", null, movieTmdbId, false);
if (movieFallback != null) {
// add note about non-translated or non-existing overview
String untranslatedOverview = movieFallback.overview;
movieFallback.overview = TextToolsK.textNoTranslationMovieLanguage(context, languageCode);
if (!TextUtils.isEmpty(untranslatedOverview)) {
movieFallback.overview += "\n\n" + untranslatedOverview;
}
if (movie != null) {
movieTools2.updateReleaseDateForRegion(movie, movie.release_dates, regionCode);
}
}
return movieFallback;
}
use of com.uwetrottmann.trakt5.entities.Movie in project SeriesGuide by UweTrottmann.
the class BaseRateItemTask method doBackgroundAction.
@Override
protected Integer doBackgroundAction(Void... params) {
if (isSendingToTrakt()) {
if (!TraktCredentials.get(getContext()).hasCredentials()) {
return ERROR_TRAKT_AUTH;
}
SyncItems ratedItems = buildTraktSyncItems();
if (ratedItems == null) {
return ERROR_TRAKT_API;
}
SyncErrors notFound;
try {
Sync traktSync = SgApp.getServicesComponent(getContext()).traktSync();
Response<SyncResponse> response = traktSync.addRatings(ratedItems).execute();
if (response.isSuccessful()) {
notFound = response.body().not_found;
} else {
if (SgTrakt.isUnauthorized(getContext(), response)) {
return ERROR_TRAKT_AUTH;
}
Errors.logAndReport(getTraktAction(), response);
return ERROR_TRAKT_API;
}
} catch (Exception e) {
Errors.logAndReport(getTraktAction(), e);
return ERROR_TRAKT_API;
}
if (notFound != null) {
if ((notFound.movies != null && notFound.movies.size() != 0) || (notFound.shows != null && notFound.shows.size() != 0) || (notFound.episodes != null && notFound.episodes.size() != 0)) {
// movie, show or episode not found on trakt
return ERROR_TRAKT_API_NOT_FOUND;
}
}
}
if (!doDatabaseUpdate()) {
return ERROR_DATABASE;
}
return SUCCESS;
}
Aggregations