use of com.uwetrottmann.trakt5.entities.Movie in project nzbhydra2 by theotherp.
the class TmdbHandler method fromImdb.
private TmdbSearchResult fromImdb(String imdbId) throws InfoProviderException {
Movie movie = getMovieByImdbId(imdbId);
TmdbSearchResult result = getSearchResultFromMovie(movie);
return result;
}
use of com.uwetrottmann.trakt5.entities.Movie in project SeriesGuide by UweTrottmann.
the class TmdbSyncTest method insertMovie.
private void insertMovie(int tmdbId, long releaseDateMs, Long lastUpdatedMs) {
Movie movie = new Movie();
movie.id = tmdbId;
movie.release_date = new Date(releaseDateMs);
MovieDetails details = new MovieDetails();
details.setInCollection(true);
details.setInWatchlist(true);
details.tmdbMovie(movie);
ContentValues values = details.toContentValuesInsert();
if (lastUpdatedMs == null) {
values.remove(Movies.LAST_UPDATED);
} else {
values.put(Movies.LAST_UPDATED, lastUpdatedMs);
}
resolver.insert(Movies.CONTENT_URI, values);
}
use of com.uwetrottmann.trakt5.entities.Movie in project SeriesGuide by UweTrottmann.
the class MigrationTest method getTestMovieDetails.
private static MovieDetails getTestMovieDetails(@Nullable Integer tmdbId) {
MovieDetails movieDetails = new MovieDetails();
Movie tmdbMovie = new Movie();
if (tmdbId != null) {
tmdbMovie.id = tmdbId;
} else {
tmdbMovie.id = 12;
}
movieDetails.tmdbMovie(tmdbMovie);
return movieDetails;
}
use of com.uwetrottmann.trakt5.entities.Movie in project SeriesGuide by UweTrottmann.
the class TraktTask method buildComment.
@Nullable
private Comment buildComment() {
Comment comment = new Comment();
comment.comment = args.getString(InitBundle.MESSAGE);
comment.spoiler = args.getBoolean(InitBundle.ISSPOILER);
// episode?
long episodeId = args.getLong(InitBundle.EPISODE_ID);
if (episodeId != 0) {
// Check in using episode TMDB ID
// Note: using show Trakt ID and episode numbers does not work (comments on show).
int episodeTmdbIdOrZero = SgRoomDatabase.getInstance(context).sgEpisode2Helper().getEpisodeTmdbId(episodeId);
if (episodeTmdbIdOrZero == 0) {
Timber.e("Failed to get episode %d", episodeId);
return null;
}
comment.episode = new Episode();
comment.episode.ids = EpisodeIds.tmdb(episodeTmdbIdOrZero);
return comment;
}
// show?
long showId = args.getLong(InitBundle.SHOW_ID);
if (showId != 0) {
Integer showTraktId = ShowTools.getShowTraktId(context, showId);
if (showTraktId == null) {
Timber.e("Failed to get show %d", showId);
return null;
}
comment.show = new Show();
comment.show.ids = ShowIds.trakt(showTraktId);
return comment;
}
// movie!
int movieTmdbId = args.getInt(InitBundle.MOVIE_TMDB_ID);
comment.movie = new Movie();
comment.movie.ids = MovieIds.tmdb(movieTmdbId);
return comment;
}
use of com.uwetrottmann.trakt5.entities.Movie in project SeriesGuide by UweTrottmann.
the class TraktSync method sync.
/**
* @param onlyRatings To not conflict with Hexagon sync, can turn on so only
* ratings are synced.
*/
public SgSyncAdapter.UpdateResult sync(long currentTime, boolean onlyRatings) {
// get last activity timestamps
progress.publish(SyncProgress.Step.TRAKT);
if (!AndroidUtils.isNetworkConnected(context)) {
progress.recordError();
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
LastActivities lastActivity = getLastActivity();
if (lastActivity == null || lastActivity.episodes == null || lastActivity.shows == null || lastActivity.movies == null) {
// trakt is offline or busy, or there are server errors, try later.
progress.recordError();
Timber.e("performTraktSync: last activity download failed");
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
TraktRatingsSync ratingsSync = new TraktRatingsSync(context, traktSync);
Map<Integer, Long> tmdbIdsToShowIds = SgApp.getServicesComponent(context).showTools().getTmdbIdsToShowIds();
if (tmdbIdsToShowIds.size() == 0) {
Timber.d("performTraktSync: no local shows, skip shows");
} else {
if (!onlyRatings) {
// EPISODES
// download and upload episode watched and collected flags
progress.publish(SyncProgress.Step.TRAKT_EPISODES);
if (!AndroidUtils.isNetworkConnected(context)) {
progress.recordError();
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
if (!syncEpisodes(tmdbIdsToShowIds, lastActivity.episodes, currentTime)) {
progress.recordError();
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
}
// download ratings
progress.publish(SyncProgress.Step.TRAKT_RATINGS);
if (!AndroidUtils.isNetworkConnected(context)) {
progress.recordError();
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
if (!ratingsSync.downloadForEpisodes(lastActivity.episodes.rated_at)) {
progress.recordError();
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
// download ratings
if (!AndroidUtils.isNetworkConnected(context)) {
progress.recordError();
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
if (!ratingsSync.downloadForShows(lastActivity.shows.rated_at)) {
progress.recordError();
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
}
// MOVIES
progress.publish(SyncProgress.Step.TRAKT_MOVIES);
TraktMovieSync movieSync = new TraktMovieSync(context, movieTools, traktSync);
// sync watchlist, collection and watched movies with trakt
if (!onlyRatings) {
if (!AndroidUtils.isNetworkConnected(context)) {
progress.recordError();
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
if (!movieSync.syncLists(lastActivity.movies)) {
progress.recordError();
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
// clean up any useless movies (not watched or not in any list)
MovieTools.deleteUnusedMovies(context);
}
// download movie ratings
progress.publish(SyncProgress.Step.TRAKT_RATINGS);
if (!AndroidUtils.isNetworkConnected(context)) {
progress.recordError();
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
if (!ratingsSync.downloadForMovies(lastActivity.movies.rated_at)) {
progress.recordError();
return SgSyncAdapter.UpdateResult.INCOMPLETE;
}
return SgSyncAdapter.UpdateResult.SUCCESS;
}
Aggregations