Repository: holgerbrandl/themoviedbapi Branch: master Commit: eab76bc7182d Files: 452 Total size: 4.2 MB Directory structure: gitextract_z5gux3ao/ ├── .gitattributes ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ └── bug_report.md │ ├── dependabot.yml │ └── workflows/ │ └── gradle.yml ├── .gitignore ├── LICENCE.txt ├── README.md ├── build.gradle.kts ├── config/ │ └── checkstyle/ │ ├── checkstyle.xml │ └── suppressions.xml ├── devel_notes.md ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── lombok.config ├── settings.gradle.kts └── src/ ├── main/ │ └── java/ │ ├── info/ │ │ └── movito/ │ │ └── themoviedbapi/ │ │ ├── AbstractTmdbApi.java │ │ ├── TmdbAccount.java │ │ ├── TmdbApi.java │ │ ├── TmdbAuthentication.java │ │ ├── TmdbCertifications.java │ │ ├── TmdbChanges.java │ │ ├── TmdbCollections.java │ │ ├── TmdbCompanies.java │ │ ├── TmdbConfiguration.java │ │ ├── TmdbDiscover.java │ │ ├── TmdbFind.java │ │ ├── TmdbGenre.java │ │ ├── TmdbGuestSessions.java │ │ ├── TmdbKeywords.java │ │ ├── TmdbLists.java │ │ ├── TmdbMovieLists.java │ │ ├── TmdbMovies.java │ │ ├── TmdbNetworks.java │ │ ├── TmdbPeople.java │ │ ├── TmdbPeopleLists.java │ │ ├── TmdbReviews.java │ │ ├── TmdbSearch.java │ │ ├── TmdbTrending.java │ │ ├── TmdbTvEpisodeGroups.java │ │ ├── TmdbTvEpisodes.java │ │ ├── TmdbTvSeasons.java │ │ ├── TmdbTvSeries.java │ │ ├── TmdbTvSeriesLists.java │ │ ├── TmdbWatchProviders.java │ │ ├── model/ │ │ │ ├── account/ │ │ │ │ ├── Account.java │ │ │ │ └── Avatar.java │ │ │ ├── authentication/ │ │ │ │ ├── GuestSession.java │ │ │ │ ├── RequestToken.java │ │ │ │ └── Session.java │ │ │ ├── certifications/ │ │ │ │ ├── Certification.java │ │ │ │ └── CertificationResults.java │ │ │ ├── changes/ │ │ │ │ ├── Change.java │ │ │ │ └── ChangesResultsPage.java │ │ │ ├── collections/ │ │ │ │ ├── CollectionInfo.java │ │ │ │ ├── Data.java │ │ │ │ ├── Images.java │ │ │ │ ├── Part.java │ │ │ │ ├── Translation.java │ │ │ │ └── Translations.java │ │ │ ├── companies/ │ │ │ │ ├── AlternativeNamesResultsPage.java │ │ │ │ └── Company.java │ │ │ ├── configuration/ │ │ │ │ ├── Configuration.java │ │ │ │ ├── Country.java │ │ │ │ ├── ImageConfig.java │ │ │ │ ├── Job.java │ │ │ │ └── Timezone.java │ │ │ ├── core/ │ │ │ │ ├── AbstractJsonMapping.java │ │ │ │ ├── AccountStates.java │ │ │ │ ├── AlternativeName.java │ │ │ │ ├── AlternativeTitle.java │ │ │ │ ├── Genre.java │ │ │ │ ├── Genres.java │ │ │ │ ├── IdElement.java │ │ │ │ ├── Language.java │ │ │ │ ├── Movie.java │ │ │ │ ├── MovieDbResultsPage.java │ │ │ │ ├── MovieResultsPage.java │ │ │ │ ├── NamedElement.java │ │ │ │ ├── NamedIdElement.java │ │ │ │ ├── NamedStringIdElement.java │ │ │ │ ├── ProductionCompany.java │ │ │ │ ├── ProductionCountry.java │ │ │ │ ├── Results.java │ │ │ │ ├── ResultsPage.java │ │ │ │ ├── Review.java │ │ │ │ ├── ReviewResultsPage.java │ │ │ │ ├── StringIdElement.java │ │ │ │ ├── TvKeywords.java │ │ │ │ ├── TvSeries.java │ │ │ │ ├── TvSeriesResultsPage.java │ │ │ │ ├── image/ │ │ │ │ │ ├── Artwork.java │ │ │ │ │ ├── Image.java │ │ │ │ │ └── ImageResults.java │ │ │ │ ├── multi/ │ │ │ │ │ ├── Multi.java │ │ │ │ │ ├── MultiMovie.java │ │ │ │ │ ├── MultiPerson.java │ │ │ │ │ ├── MultiResultsPage.java │ │ │ │ │ └── MultiTvSeries.java │ │ │ │ ├── popularperson/ │ │ │ │ │ ├── KnownFor.java │ │ │ │ │ ├── PopularPerson.java │ │ │ │ │ └── PopularPersonResultsPage.java │ │ │ │ ├── responses/ │ │ │ │ │ ├── ResponseStatus.java │ │ │ │ │ ├── ResponseStatusAuthentication.java │ │ │ │ │ ├── ResponseStatusDelete.java │ │ │ │ │ └── TmdbResponseException.java │ │ │ │ ├── video/ │ │ │ │ │ ├── Video.java │ │ │ │ │ └── VideoResults.java │ │ │ │ └── watchproviders/ │ │ │ │ ├── Provider.java │ │ │ │ ├── ProviderResults.java │ │ │ │ └── WatchProviders.java │ │ │ ├── find/ │ │ │ │ ├── FindMovie.java │ │ │ │ ├── FindPerson.java │ │ │ │ ├── FindResults.java │ │ │ │ ├── FindTvEpisode.java │ │ │ │ ├── FindTvSeason.java │ │ │ │ └── FindTvSeries.java │ │ │ ├── keywords/ │ │ │ │ └── Keyword.java │ │ │ ├── lists/ │ │ │ │ ├── ListDetails.java │ │ │ │ ├── ListItemStatus.java │ │ │ │ └── MovieListCreationStatus.java │ │ │ ├── movielists/ │ │ │ │ ├── Dates.java │ │ │ │ └── MovieResultsPageWithDates.java │ │ │ ├── movies/ │ │ │ │ ├── AlternativeTitles.java │ │ │ │ ├── BelongsToCollection.java │ │ │ │ ├── Cast.java │ │ │ │ ├── Credits.java │ │ │ │ ├── Crew.java │ │ │ │ ├── Data.java │ │ │ │ ├── ExternalIds.java │ │ │ │ ├── Images.java │ │ │ │ ├── KeywordResults.java │ │ │ │ ├── MovieDb.java │ │ │ │ ├── MovieList.java │ │ │ │ ├── MovieListResultsPage.java │ │ │ │ ├── ReleaseDate.java │ │ │ │ ├── ReleaseDateResults.java │ │ │ │ ├── ReleaseInfo.java │ │ │ │ ├── ReleaseType.java │ │ │ │ ├── Translation.java │ │ │ │ ├── Translations.java │ │ │ │ └── changes/ │ │ │ │ ├── Change.java │ │ │ │ ├── ChangeItem.java │ │ │ │ └── ChangeResults.java │ │ │ ├── networks/ │ │ │ │ ├── AlternativeNamesResults.java │ │ │ │ └── Network.java │ │ │ ├── people/ │ │ │ │ ├── Data.java │ │ │ │ ├── ExternalIds.java │ │ │ │ ├── Gender.java │ │ │ │ ├── PersonDb.java │ │ │ │ ├── PersonImages.java │ │ │ │ ├── Translation.java │ │ │ │ ├── Translations.java │ │ │ │ └── credits/ │ │ │ │ ├── Cast.java │ │ │ │ ├── CombinedPersonCredits.java │ │ │ │ ├── Crew.java │ │ │ │ ├── MediaType.java │ │ │ │ ├── MovieCast.java │ │ │ │ ├── MovieCredits.java │ │ │ │ ├── MovieCrew.java │ │ │ │ ├── TvCast.java │ │ │ │ ├── TvCredits.java │ │ │ │ └── TvCrew.java │ │ │ ├── rated/ │ │ │ │ ├── RatedMovie.java │ │ │ │ ├── RatedMovieResultsPage.java │ │ │ │ ├── RatedTvEpisode.java │ │ │ │ ├── RatedTvEpisodeResultsPage.java │ │ │ │ ├── RatedTvSeries.java │ │ │ │ └── RatedTvSeriesResultsPage.java │ │ │ ├── reviews/ │ │ │ │ ├── AuthorDetails.java │ │ │ │ └── Review.java │ │ │ ├── search/ │ │ │ │ ├── Collection.java │ │ │ │ ├── CollectionResultsPage.java │ │ │ │ ├── Company.java │ │ │ │ ├── CompanyResultsPage.java │ │ │ │ └── KeywordResultsPage.java │ │ │ ├── tv/ │ │ │ │ ├── core/ │ │ │ │ │ ├── Change.java │ │ │ │ │ ├── ChangeItem.java │ │ │ │ │ ├── ChangeResults.java │ │ │ │ │ ├── Data.java │ │ │ │ │ ├── Network.java │ │ │ │ │ ├── Translation.java │ │ │ │ │ ├── Translations.java │ │ │ │ │ ├── TvEpisode.java │ │ │ │ │ ├── TvSeason.java │ │ │ │ │ └── credits/ │ │ │ │ │ ├── AggregateCast.java │ │ │ │ │ ├── AggregateCredits.java │ │ │ │ │ ├── AggregateCrew.java │ │ │ │ │ ├── Cast.java │ │ │ │ │ ├── Credits.java │ │ │ │ │ └── Crew.java │ │ │ │ ├── episode/ │ │ │ │ │ ├── EpisodeCredits.java │ │ │ │ │ ├── ExternalIds.java │ │ │ │ │ ├── GuestStar.java │ │ │ │ │ ├── Images.java │ │ │ │ │ └── TvEpisodeDb.java │ │ │ │ ├── episodegroups/ │ │ │ │ │ ├── EpisodeGroupType.java │ │ │ │ │ ├── OrderedTvEpisode.java │ │ │ │ │ ├── TvEpisodeGroup.java │ │ │ │ │ └── TvEpisodeGroups.java │ │ │ │ ├── season/ │ │ │ │ │ ├── AccountState.java │ │ │ │ │ ├── AccountStateResults.java │ │ │ │ │ ├── Change.java │ │ │ │ │ ├── ChangeItem.java │ │ │ │ │ ├── ChangeResults.java │ │ │ │ │ ├── ExternalIds.java │ │ │ │ │ ├── Images.java │ │ │ │ │ ├── TvSeasonDb.java │ │ │ │ │ └── TvSeasonEpisode.java │ │ │ │ └── series/ │ │ │ │ ├── AlternativeTitleResults.java │ │ │ │ ├── ContentRating.java │ │ │ │ ├── ContentRatingResults.java │ │ │ │ ├── CreatedBy.java │ │ │ │ ├── Data.java │ │ │ │ ├── EpisodeGroup.java │ │ │ │ ├── EpisodeGroupResults.java │ │ │ │ ├── ExternalIds.java │ │ │ │ ├── Images.java │ │ │ │ ├── Job.java │ │ │ │ ├── Role.java │ │ │ │ ├── ScreenedTheatrically.java │ │ │ │ ├── ScreenedTheatricallyResults.java │ │ │ │ ├── Translation.java │ │ │ │ ├── Translations.java │ │ │ │ ├── TvSeriesDb.java │ │ │ │ ├── TvSeriesList.java │ │ │ │ └── TvSeriesListResultsPage.java │ │ │ └── watchproviders/ │ │ │ ├── AvailableRegion.java │ │ │ ├── AvailableRegionResults.java │ │ │ ├── Provider.java │ │ │ └── ProviderResults.java │ │ ├── tools/ │ │ │ ├── ApiUrl.java │ │ │ ├── RequestType.java │ │ │ ├── TmdbException.java │ │ │ ├── TmdbHttpClient.java │ │ │ ├── TmdbResponseCode.java │ │ │ ├── TmdbUrlReader.java │ │ │ ├── appendtoresponse/ │ │ │ │ ├── AppendToResponse.java │ │ │ │ ├── MovieAppendToResponse.java │ │ │ │ ├── PersonAppendToResponse.java │ │ │ │ ├── TvEpisodesAppendToResponse.java │ │ │ │ ├── TvSeasonsAppendToResponse.java │ │ │ │ └── TvSeriesAppendToResponse.java │ │ │ ├── builders/ │ │ │ │ ├── ParamBuilder.java │ │ │ │ └── discover/ │ │ │ │ ├── DiscoverMovieParamBuilder.java │ │ │ │ ├── DiscoverParamBuilder.java │ │ │ │ └── DiscoverTvParamBuilder.java │ │ │ ├── model/ │ │ │ │ └── time/ │ │ │ │ ├── ExternalSource.java │ │ │ │ └── TimeWindow.java │ │ │ └── sortby/ │ │ │ ├── AccountSortBy.java │ │ │ ├── DiscoverMovieSortBy.java │ │ │ ├── DiscoverTvSortBy.java │ │ │ └── SortBy.java │ │ └── util/ │ │ ├── JsonUtil.java │ │ └── ModelUtil.java │ └── module-info.java └── test/ ├── java/ │ └── info/ │ └── movito/ │ └── themoviedbapi/ │ ├── AbstractTmdbApiTest.java │ ├── TmdbAccountTest.java │ ├── TmdbAuthenticationTest.java │ ├── TmdbCertificationsTest.java │ ├── TmdbChangesTest.java │ ├── TmdbCollectionsTest.java │ ├── TmdbCompaniesTest.java │ ├── TmdbConfigurationTest.java │ ├── TmdbDiscoverTest.java │ ├── TmdbFindTest.java │ ├── TmdbGenresTest.java │ ├── TmdbGuestSessionsTest.java │ ├── TmdbKeywordsTest.java │ ├── TmdbListsTest.java │ ├── TmdbMovieListsTest.java │ ├── TmdbMoviesTest.java │ ├── TmdbNetworksTest.java │ ├── TmdbPeopleListsTest.java │ ├── TmdbPeopleTest.java │ ├── TmdbReviewsTest.java │ ├── TmdbTrendingTest.java │ ├── TmdbTvEpisodeGroupsTest.java │ ├── TmdbTvEpisodesTest.java │ ├── TmdbTvSearchTest.java │ ├── TmdbTvSeasonsTest.java │ ├── TmdbTvSeriesListsTest.java │ ├── TmdbTvSeriesTest.java │ ├── TmdbWatchProvidersTest.java │ ├── testutil/ │ │ ├── AbstractJsonMappingValidator.java │ │ ├── TestUtils.java │ │ └── ValidatorConfig.java │ └── util/ │ ├── JsonUtilTest.java │ └── ModelUtilTest.java └── resources/ └── api_responses/ ├── account/ │ ├── add_favourite.json │ ├── add_to_watchlist.json │ ├── details.json │ ├── favourite_movies.json │ ├── favourite_tv.json │ ├── lists.json │ ├── rated_movies.json │ ├── rated_tv.json │ ├── rated_tv_episodes.json │ ├── watchlist_movies.json │ └── watchlist_tv.json ├── authentication/ │ ├── create_guest_session.json │ ├── create_request_token.json │ ├── create_request_token_unsuccessful.json │ ├── create_session.json │ ├── create_session_with_login.json │ ├── create_session_with_login_unsuccessful.json │ ├── delete_session.json │ ├── validate_key.json │ └── validate_key_unsuccessful.json ├── certifications/ │ ├── movie.json │ └── tv.json ├── changes/ │ ├── movie_list.json │ ├── people_list.json │ └── tv_list.json ├── collections/ │ ├── details.json │ ├── images.json │ └── translations.json ├── companies/ │ ├── alternative_names.json │ ├── details.json │ └── images.json ├── configuration/ │ ├── countries.json │ ├── details.json │ ├── jobs.json │ ├── languages.json │ ├── primary_translations.json │ └── timezones.json ├── discover/ │ ├── movies.json │ └── tv.json ├── find/ │ ├── movie_results.json │ ├── person_results.json │ ├── tv_episode_results.json │ ├── tv_results.json │ └── tv_season_results.json ├── genres/ │ ├── movie_list.json │ └── tv_list.json ├── guest_sessions/ │ ├── rated_movies.json │ ├── rated_tv.json │ └── rated_tv_episodes.json ├── keywords/ │ └── details.json ├── lists/ │ ├── add_movie.json │ ├── check_item_status.json │ ├── clear.json │ ├── create.json │ ├── delete.json │ ├── details.json │ └── remove_movie.json ├── movie_lists/ │ ├── now_playing.json │ ├── popular.json │ ├── top_rated.json │ └── upcoming.json ├── movies/ │ ├── account_states.json │ ├── add_rating.json │ ├── alternative_titles.json │ ├── changes.json │ ├── credits.json │ ├── delete_rating.json │ ├── details.json │ ├── details_with_append_to_response.json │ ├── external_ids.json │ ├── images.json │ ├── keywords.json │ ├── latest.json │ ├── lists.json │ ├── recommendations.json │ ├── release_dates.json │ ├── reviews.json │ ├── similar.json │ ├── translations.json │ ├── videos.json │ └── watch_providers.json ├── networks/ │ ├── alternative_names.json │ ├── details.json │ └── images.json ├── people/ │ ├── changes.json │ ├── combined_credits.json │ ├── details.json │ ├── details_with_append_to_response.json │ ├── external_ids.json │ ├── images.json │ ├── latest.json │ ├── movie_credits.json │ ├── translations.json │ └── tv_credits.json ├── people_lists/ │ └── popular.json ├── reviews/ │ └── details.json ├── search/ │ ├── collection.json │ ├── company.json │ ├── keyword.json │ ├── movie.json │ ├── multi.json │ ├── person.json │ └── tv.json ├── trending/ │ ├── all.json │ ├── movies.json │ ├── people.json │ └── tv.json ├── tv_episode_groups/ │ └── details.json ├── tv_episodes/ │ ├── account_states.json │ ├── add_rating.json │ ├── changes.json │ ├── credits.json │ ├── delete_rating.json │ ├── details.json │ ├── details_with_append_to_response.json │ ├── external_ids.json │ ├── images.json │ ├── translations.json │ └── videos.json ├── tv_seasons/ │ ├── account_states.json │ ├── aggregate_credits.json │ ├── changes.json │ ├── credits.json │ ├── details.json │ ├── details_with_append_to_response.json │ ├── external_ids.json │ ├── images.json │ ├── translations.json │ ├── videos.json │ └── watch_providers.json ├── tv_series/ │ ├── account_states.json │ ├── add_rating.json │ ├── aggregate_credits.json │ ├── alternative_titles.json │ ├── changes.json │ ├── content_ratings.json │ ├── credits.json │ ├── delete_rating.json │ ├── details.json │ ├── details_with_append_to_response.json │ ├── episode_groups.json │ ├── external_ids.json │ ├── images.json │ ├── keywords.json │ ├── latest.json │ ├── lists.json │ ├── recommendations.json │ ├── reviews.json │ ├── screened_theatrically.json │ ├── similar.json │ ├── translations.json │ ├── videos.json │ └── watch_providers.json ├── tv_series_lists/ │ ├── airing_today.json │ ├── on_the_air.json │ ├── popular.json │ └── top_rated.json └── watch_providers/ ├── available_regions.json ├── empty_watch_providers.json ├── movie_providers.json └── tv_providers.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ # Auto detect text files and perform LF normalization * text=auto # Custom for Visual Studio *.cs diff=csharp *.sln merge=union *.csproj merge=union *.vbproj merge=union *.fsproj merge=union *.dbproj merge=union # Standard to msysgit *.doc diff=astextplain *.DOC diff=astextplain *.docx diff=astextplain *.DOCX diff=astextplain *.dot diff=astextplain *.DOT diff=astextplain *.pdf diff=astextplain *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.md ================================================ --- name: Bug report about: Create a report to help us fix an issue title: "[BUG]" labels: bug assignees: '' --- **Describe the bug** A clear and concise description of what the bug is. **State what version of themoviedbapi you are using** e.g. 2.3.1. **Provide a code snippet to replicate the bug** code goes here **Additional context** Add any other context about the problem here. ================================================ FILE: .github/dependabot.yml ================================================ # To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file version: 2 updates: - package-ecosystem: "gradle" directory: "/" # Location of package manifests schedule: interval: "monthly" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "monthly" ================================================ FILE: .github/workflows/gradle.yml ================================================ name: build on: push: branches: [ master ] pull_request: branches: [ master ] permissions: contents: read jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v6 - name: Setup Java uses: actions/setup-java@v5 with: java-version: 17 distribution: corretto - name: Setup Gradle uses: gradle/actions/setup-gradle@v5 - name: Execute Gradle Build run: ./gradlew clean build --scan ================================================ FILE: .gitignore ================================================ *.class # Package Files # *.jar *.war *.ear /target/ /nbactions.xml .classpath .project .idea/ .settings/ *.iml /bin/ # sonatype credentials local.properties *.gpg build .gradle !/gradle/wrapper/gradle-wrapper.jar ================================================ FILE: LICENCE.txt ================================================ Copyright (c) 2026, Holger Brandl, Conor Egan All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. ================================================ FILE: README.md ================================================ # TheMovieDB API [![Download](https://img.shields.io/github/v/release/c-eg/themoviedbapi)](https://github.com/c-eg/themoviedbapi/releases) [![BSD 2 License](http://img.shields.io/badge/license-BSD_2_Clause-green.svg)](https://opensource.org/licenses/BSD-2-Clause) This library provides a Java-wrapper around the [JSON API](https://developer.themoviedb.org/docs/getting-started) provided by [TMdB](https://www.themoviedb.org/), which is an open database for movie and tv content. The wrapper implements most, if not all, of the JSON API. However, because the API is subject to constantly change, new functionality may not be implemented, or current functionality may break. Please point this out by submitting an issue, or even better, just send us a pull request! It's available via [Maven Central](https://central.sonatype.com/artifact/uk.co.conoregan/themoviedbapi). Just add it as dependency to your project.
Maven ```xml uk.co.conoregan themoviedbapi {version} ```
Gradle (Kotlin) ```kotlin dependencies { implementation("uk.co.conoregan:themoviedbapi:{version}") } ```
## Usage To register for a TMdB API key, click the [API link](https://www.themoviedb.org/settings/api) from within your account settings page. There are two types of API keys currently provided by TMdB, please ensure you are using the `API Read Access Token` key. With this you can instantiate `info.movito.themoviedbapi.TmdbApi`, which has getters for all subcategories of the API, e.g. ```java TmdbApi tmdbApi = new TmdbApi(""); ``` ### Examples #### Get movie details ```java TmdbMovies tmdbMovies = tmdbApi.getMovies(); MovieDb movie = tmdbMovies.getDetails(5353, "en-US"); ``` #### Append to response Some of the API methods support appending additional requests to the response. This concept is part of the underlying [TMdB API - Append To Response](https://developer.themoviedb.org/docs/append-to-response), our wrapper just mimics the scheme. If you try to call the getter for a model that has fields for appendable responses, without providing the append to response parameter to the function, it will return `null`. ```java TmdbMovies tmdbMovies = tmdbApi.getMovies(); MovieDb movie = tmdbMovies.getDetails(5353, "en-US"); Images images = movie.getImages(); // this will be null MovieDb movie = tmdbMovies.getDetails(5353, "en-US", MovieAppendToResponse.IMAGES); Images images = movie.getImages(); // this will NOT be null ``` You can also append multiple responses to the same request by providing multiple append to response values. ```java TmdbMovies tmdbMovies = tmdbApi.getMovies(); MovieDb movie = tmdbMovies.getDetails(5353, "en-US", MovieAppendToResponse.IMAGES, MovieAppendToResponse.VIDEOS); MovieDb movie = tmdbMovies.getDetails(5353, "en-US", MovieAppendToResponse.values()); ``` To find all methods that use append to response, see the `info.movito.themoviedbapi.tools.appendtoresponse.AppendToResponse` interface implementations. ### Exception Handling Every API method can throw a `info.movito.themoviedbapi.tools.TmdbException` if the request fails for any reason. You should catch this exception and handle it appropriately. Some exceptions are caused because the response status provided by the TMdB API is not successful. To see more details, see the `info.movito.themoviedbapi.tools.TmdbResponseCode` and [TMdB Errors](https://developer.themoviedb.org/docs/errors). In the example below, the response was successful, but response code returned by TMdB API was not successful due to an authentication failure. ```java TmdbMovies tmdbMovies = tmdbApi.getMovies(); try { AccountStates accountStates = tmdbMovies.getAccountStates(-1, "accountId", null); } catch (TmdbResponseException exception) { TmdbResponseCode responseCode = exception.getResponseCode(); // handle unsuccessful TMdB response code } catch (TmdbException exception) { // handle unknown-cause exception } ``` We chose to throw exceptions rather than returning `null`, so you have more control over what you do with each failure case. E.g. with the example above, you may want to display an error message to the user about failing authentication. ## Project Logging This project uses [SLF4J](http://www.slf4j.org) to abstract the logging in the project. To use the logging in your own project you should add one of the provided [adapter bindings](http://www.slf4j.org/manual.html). ## Prooguard / R8 rules Model classes are placed under `info.movito.themoviedbapi.model` package. Add this to `proguard-rules.pro` so that, these classes can survive minification. ``` -keep class info.movito.themoviedbapi.model.** { *; } ``` ## Notes & Acknowledgements The library was developed for [Movito](http://www.movito.info) to interact with TMdB services. This library has been inspired by [api-themoviedb](https://github.com/Omertron/api-themoviedb) but has been rewritten to provide a more open license, a more clean API, and to expose more features of the TMdB JSON API. ================================================ FILE: build.gradle.kts ================================================ plugins { `java-library` checkstyle `maven-publish` signing id("io.github.gradle-nexus.publish-plugin") version "2.0.0" id("org.jreleaser") version "1.23.0" } group = "uk.co.conoregan" version = "2.6.0" repositories { mavenCentral() } dependencies { // logging implementation(platform("org.slf4j:slf4j-bom:2.0.17")) implementation("org.slf4j:slf4j-api") // testing testImplementation(platform("org.junit:junit-bom:6.0.3")) testImplementation("org.junit.jupiter:junit-jupiter") testRuntimeOnly("org.junit.platform:junit-platform-launcher") // gradle bundled version is incompatible with 5.12 testImplementation(platform("org.mockito:mockito-bom:5.22.0")) testImplementation("org.mockito:mockito-core") // util compileOnly("org.projectlombok:lombok:1.18.42") annotationProcessor("org.projectlombok:lombok:1.18.42") testCompileOnly("org.projectlombok:lombok:1.18.42") testAnnotationProcessor("org.projectlombok:lombok:1.18.42") implementation(platform("com.fasterxml.jackson:jackson-bom:2.21.1")) implementation("com.fasterxml.jackson.core:jackson-annotations") implementation("com.fasterxml.jackson.core:jackson-core") implementation("com.fasterxml.jackson.core:jackson-databind") implementation("org.apache.commons:commons-lang3:3.20.0") testImplementation("commons-io:commons-io:2.21.0") } java { withJavadocJar() withSourcesJar() } tasks.test { useJUnitPlatform() } checkstyle { toolVersion = "10.17.0" configFile = file("config/checkstyle/checkstyle.xml") } tasks.checkstyleMain { source = fileTree("src/main/java") } tasks.checkstyleTest { source = fileTree("src/test/java") } tasks.withType().configureEach { reports { html.required = true } } publishing { publications { create("mavenJava") { from(components["java"]) pom { name = "themoviedbapi" description = "A Java-wrapper around the JSON API provided by TMdB, which is an open database for movie and tv content." url = "https://github.com/c-eg/themoviedbapi" licenses { license { name = "BSD" url = "https://github.com/c-eg/themoviedbapi/blob/master/LICENCE.txt" } } scm { connection = "scm:git:github.com/c-eg/themoviedbapi.git" url = "https://github.com/c-eg/themoviedbapi.git" } developers { developer { id = "holgerbrandl" name = "Holger Brandl" email = "holgerbrandl@gmail.com" } developer { id = "c-eg" name = "Conor Egan" email = "17conoregan@gmail.com" } } } } } repositories { maven { url = uri(layout.buildDirectory.dir("staging-deploy")) } } } jreleaser { signing { pgp { active = org.jreleaser.model.Active.ALWAYS armored = true mode = org.jreleaser.model.Signing.Mode.FILE publicKey = "C:/gpg/public.pgp" secretKey = "C:/gpg/private.pgp" } } deploy { maven { mavenCentral { create("sonatype") { active = org.jreleaser.model.Active.ALWAYS url.set("https://central.sonatype.com/api/v1/publisher") stagingRepository("build/staging-deploy") } } } } } if (project.hasProperty("signing.keyId") && project.hasProperty("signing.password") && project.hasProperty("signing.secretKeyRingFile")) signing { sign(publishing.publications["mavenJava"]) } tasks.javadoc { if (JavaVersion.current().isJava9Compatible) { (options as StandardJavadocDocletOptions).addBooleanOption("html5", true) } } tasks { javadoc { options { (this as CoreJavadocOptions).addBooleanOption("Xdoclint:none", true) } } } ================================================ FILE: config/checkstyle/checkstyle.xml ================================================ ================================================ FILE: config/checkstyle/suppressions.xml ================================================ ================================================ FILE: devel_notes.md ================================================ # Developer Notes ## How to do a release? 1. Make sure to increase version number in [build.gradle.kts](build.gradle.kts), commit and push the version to the `master` branch 2. Do the release on GitHub 3. Make sure the prerequisites are met that are listed below 4. Clean, publish and deploy ```bash ./gradlew clean && ./gradlew publish && ./gradlew jreleaserDeploy ``` 5. Go to [Maven Central Repository](https://central.sonatype.com/publishing/deployments) and verify the deployment was successful ## Prerequisites ### GPG & PGP Keys Make sure you have the following keys exist: - `C:/gpg/private.pgp` - `C:/gpg/public.pgp` - `C:/gpg/secring.gpg` ### Gradle Properties Make sure you have the following in your global gradle.properties file `C:\Users\\.gradle\gradle.properties`: ```properties signing.keyId = signing.password = signing.secretKeyRingFile = C:/gpg/secring.gpg ``` ### JReleaser Properties Make sure you have the following in your jreleaser.properties file `C:\Users\\.jreleaser\config.properties`: ```properties JRELEASER_GPG_PUBLIC_KEY = C:/gpg/public.pgp JRELEASER_GPG_SECRET_KEY = C:/gpg/private.pgp JRELEASER_GPG_PASSPHRASE = JRELEASER_GITHUB_TOKEN = JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME = JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD = ``` Note: `JRELEASER_GITHUB_TOKEN` does not need a valid value, it just needs a non-empty value set. If you are setting this up for the first time, you can verify your config is configured correctly with: ```bash ./gradlew jreleaserConfig ``` ================================================ FILE: gradle/wrapper/gradle-wrapper.properties ================================================ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists ================================================ FILE: gradle.properties ================================================ org.gradle.caching = true org.gradle.vfs.watch = true ================================================ FILE: gradlew ================================================ #!/bin/sh # # Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # SPDX-License-Identifier: Apache-2.0 # ############################################################################## # # Gradle start up script for POSIX generated by Gradle. # # Important for running: # # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is # noncompliant, but you have some other compliant shell such as ksh or # bash, then to run this script, type that shell name before the whole # command line, like: # # ksh Gradle # # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», # «${var#prefix}», «${var%suffix}», and «$( cmd )»; # * compound commands having a testable exit status, especially «case»; # * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # # (2) This script targets any POSIX shell, so it avoids extensions provided # by Bash, Ksh, etc; in particular arrays are avoided. # # The "traditional" practice of packing multiple parameters into a # space-separated string is a well documented source of bugs and security # problems, so this is (mostly) avoided, by progressively accumulating # options in "$@", and eventually passing that to Java. # # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; # see the in-line comments for details. # # There are tweaks for specific operating systems such as AIX, CygWin, # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. # ############################################################################## # Attempt to set APP_HOME # Resolve links: $0 may be a link app_path=$0 # Need this for daisy-chained symlinks. while APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path [ -h "$app_path" ] do ls=$( ls -ld "$app_path" ) link=${ls#*' -> '} case $link in #( /*) app_path=$link ;; #( *) app_path=$APP_HOME$link ;; esac done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum warn () { echo "$*" } >&2 die () { echo echo "$*" echo exit 1 } >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "$( uname )" in #( CYGWIN* ) cygwin=true ;; #( Darwin* ) darwin=true ;; #( MSYS* | MINGW* ) msys=true ;; #( NONSTOP* ) nonstop=true ;; esac CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD=$JAVA_HOME/jre/sh/java else JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD=java if ! command -v java >/dev/null 2>&1 then die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi # Collect all arguments for the java command, stacking in reverse order: # * args from the command line # * the main class name # * -classpath # * -D...appname settings # * --module-path (only if needed) # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) # Now convert the arguments - kludge to limit ourselves to /bin/sh for arg do if case $arg in #( -*) false ;; # don't mess with options #( /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath [ -e "$t" ] ;; #( *) false ;; esac then arg=$( cygpath --path --ignore --mixed "$arg" ) fi # Roll the args list around exactly as many times as the number of # args, so each arg winds up back in the position where it started, but # possibly modified. # # NB: a `for` loop captures its iteration list before it begins, so # changing the positional parameters here affects neither the number of # iterations, nor the values presented in `arg`. shift # remove old arg set -- "$@" "$arg" # push replacement arg done fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. if ! command -v xargs >/dev/null 2>&1 then die "xargs is not available" fi # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. # # In Bash we could simply go: # # readarray ARGS < <( xargs -n1 <<<"$var" ) && # set -- "${ARGS[@]}" "$@" # # but POSIX shell has neither arrays nor command substitution, so instead we # post-process each arg (as a line of input to sed) to backslash-escape any # character that might be a shell metacharacter, then use eval to reverse # that process (while maintaining the separation between arguments), and wrap # the whole thing up as a single "set" statement. # # This will of course break if any of these variables contains a newline or # an unmatched quote. # eval "set -- $( printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | xargs -n1 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | tr '\n' ' ' )" '"$@"' exec "$JAVACMD" "$@" ================================================ FILE: gradlew.bat ================================================ @rem @rem Copyright 2015 the original author or authors. @rem @rem Licensed under the Apache License, Version 2.0 (the "License"); @rem you may not use this file except in compliance with the License. @rem You may obtain a copy of the License at @rem @rem https://www.apache.org/licenses/LICENSE-2.0 @rem @rem Unless required by applicable law or agreed to in writing, software @rem distributed under the License is distributed on an "AS IS" BASIS, @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem @rem SPDX-License-Identifier: Apache-2.0 @rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Resolve any "." and ".." in APP_HOME to make it shorter. for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute echo. 1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute echo. 1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line set CLASSPATH= @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! set EXIT_CODE=%ERRORLEVEL% if %EXIT_CODE% equ 0 set EXIT_CODE=1 if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: lombok.config ================================================ config.stopBubbling = true lombok.addLombokGeneratedAnnotation = true ================================================ FILE: settings.gradle.kts ================================================ rootProject.name = "themoviedbapi" ================================================ FILE: src/main/java/info/movito/themoviedbapi/AbstractTmdbApi.java ================================================ package info.movito.themoviedbapi; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectReader; import info.movito.themoviedbapi.model.core.responses.ResponseStatus; import info.movito.themoviedbapi.model.core.responses.TmdbResponseException; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.TmdbResponseCode; import info.movito.themoviedbapi.util.JsonUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static info.movito.themoviedbapi.tools.TmdbResponseCode.REQUEST_LIMIT_EXCEEDED; /** * Class to be inherited by a TmdbApi class. */ public abstract class AbstractTmdbApi { public static final String PARAM_YEAR = "year"; public static final String PARAM_PAGE = "page"; public static final String PARAM_LANGUAGE = "language"; public static final String PARAM_ADULT = "include_adult"; public static final String PARAM_SORT_BY = "sort_by"; private static final ObjectReader RESPONSE_STATUS_READER = JsonUtil.OBJECT_MAPPER.readerFor(ResponseStatus.class); private static final Logger LOGGER = LoggerFactory.getLogger(AbstractTmdbApi.class); private final TmdbApi tmdbApi; AbstractTmdbApi(TmdbApi tmdbApi) { this.tmdbApi = tmdbApi; } /** * Maps a json result to a class. * * @param apiUrl the api url to map * @param clazz the class to map to * @param the type of class to map to * @return the mapped class */ protected T mapJsonResult(ApiUrl apiUrl, Class clazz) throws TmdbException { return mapJsonResult(apiUrl, null, clazz); } /** * Maps a json result to a class. * * @param apiUrl the api url to map * @param resultClass the class to map to * @param the type of class to map to * @return the mapped class */ protected T mapJsonResult(ApiUrl apiUrl, TypeReference resultClass) throws TmdbException { return mapJsonResult(apiUrl, null, resultClass); } /** * Maps a json result to a class. * * @param apiUrl the api url to map * @param jsonBody the json body * @param clazz the class to map to * @param the type of class to map to * @return the mapped class. */ protected T mapJsonResult(ApiUrl apiUrl, String jsonBody, Class clazz) throws TmdbException { return mapJsonResult(apiUrl, jsonBody, RequestType.GET, clazz); } /** * Maps a json result to a class. * * @param apiUrl the api url to map * @param jsonBody the json body * @param resultClass the class to map to * @param the type of class to map to * @return the mapped class */ protected T mapJsonResult(ApiUrl apiUrl, String jsonBody, TypeReference resultClass) throws TmdbException { return mapJsonResult(apiUrl, jsonBody, RequestType.GET, resultClass); } /** * Maps a json result to a class. * * @param apiUrl the api url to map * @param jsonBody the json body * @param requestType the type of request * @param clazz the class to map to * @param the type of class to map to * @return the mapped class. */ protected T mapJsonResult(ApiUrl apiUrl, String jsonBody, RequestType requestType, Class clazz) throws TmdbException { return mapJsonResult(apiUrl, jsonBody, requestType, JsonUtil.OBJECT_MAPPER.readerFor(clazz)); } /** * Maps a json result to a class. * * @param apiUrl the api url to map * @param jsonBody the json body * @param requestType the type of request * @param resultClass the class to map to * @param the type of class to map to * @return the mapped class. */ protected T mapJsonResult(ApiUrl apiUrl, String jsonBody, RequestType requestType, TypeReference resultClass) throws TmdbException { return mapJsonResult(apiUrl, jsonBody, requestType, JsonUtil.OBJECT_MAPPER.readerFor(resultClass)); } /** * Maps a json result to a class. * * @param apiUrl the api url to map * @param jsonBody the json body * @param requestType the type of request * @param objectReader the object reader * @param the type of class to map to * @return the mapped class. */ private T mapJsonResult(ApiUrl apiUrl, String jsonBody, RequestType requestType, ObjectReader objectReader) throws TmdbException { String jsonResponse = tmdbApi.getTmdbUrlReader().readUrl(apiUrl.buildUrl(), jsonBody, requestType); try { // check if the response was successful. tmdb have their own codes for successful and unsuccessful responses. // some 2xx codes are not successful. See: https://developer.themoviedb.org/docs/errors for more info. ResponseStatus responseStatus = RESPONSE_STATUS_READER.readValue(jsonResponse); TmdbResponseCode tmdbResponseCode = responseStatus.getStatusCode(); if (tmdbResponseCode != null) { if (REQUEST_LIMIT_EXCEEDED == tmdbResponseCode) { LOGGER.info("TMDB API: Request limit exceeded. Waiting 1 second before retrying."); Thread.sleep(1000); return mapJsonResult(apiUrl, jsonBody, requestType, objectReader); } else if (!tmdbResponseCode.isSuccess()) { throw new TmdbResponseException(tmdbResponseCode); } } } catch (JsonProcessingException exception) { // ignore, not an error - caused by RESPONSE_STATUS_READER.readValue(jsonResponse); // this is necessary because if some requests fail (including 2xx responses), the response is a json object } catch (InterruptedException exception) { throw new TmdbException(exception); } try { return objectReader.readValue(jsonResponse); } catch (JsonProcessingException exception) { throw new TmdbException(exception); } } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbAccount.java ================================================ package info.movito.themoviedbapi; import java.util.HashMap; import info.movito.themoviedbapi.model.account.Account; import info.movito.themoviedbapi.model.core.MovieResultsPage; import info.movito.themoviedbapi.model.core.TvSeriesResultsPage; import info.movito.themoviedbapi.model.core.responses.ResponseStatus; import info.movito.themoviedbapi.model.movies.MovieListResultsPage; import info.movito.themoviedbapi.model.rated.RatedMovieResultsPage; import info.movito.themoviedbapi.model.rated.RatedTvEpisodeResultsPage; import info.movito.themoviedbapi.model.rated.RatedTvSeriesResultsPage; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.sortby.AccountSortBy; import info.movito.themoviedbapi.util.JsonUtil; /** * The movie database api for accounts. See the * documentation for more info. */ public class TmdbAccount extends AbstractTmdbApi { public static final String PARAM_SESSION = "session_id"; protected static final String TMDB_METHOD_ACCOUNT = "account"; /** * Create a new TmdbAccount instance to call the account related TMDb API methods. */ TmdbAccount(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the basic information for an account. You will need to have a valid session id.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @return The account details. * @throws TmdbException If there was an error making the request or mapping the response. */ public Account getDetails(Integer accountId, String sessionId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId) .addQueryParam(PARAM_SESSION, sessionId); return mapJsonResult(apiUrl, Account.class); } /** *

Add media to an account's favorites list.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param mediaId the id of the media to add to the favorites list. * @param mediaType the type of media to add to the favorites list. * @return The status of the request. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus addFavorite(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType) throws TmdbException { return changeFavoriteStatus(accountId, sessionId, mediaId, mediaType, true); } /** *

Remove media to an account's favorites list.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param mediaId the id of the media to remove from the favorites list. * @param mediaType the type of media to remove from the favorites list. * @return The status of the request. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus removeFavorite(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType) throws TmdbException { return changeFavoriteStatus(accountId, sessionId, mediaId, mediaType, false); } private ResponseStatus changeFavoriteStatus(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType, boolean isFavorite) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "favorite") .addQueryParam(PARAM_SESSION, sessionId); HashMap body = new HashMap<>(); body.put("media_type", mediaType.toString()); body.put("media_id", mediaId); body.put("favorite", isFavorite); String jsonBody = JsonUtil.toJson(body); return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class); } /** *

Add media to an account's watch list.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param mediaId the id of the media to add to the watch list. * @param mediaType the type of media to add to the watch list. * @return The status of the request. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus addToWatchList(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType) throws TmdbException { return changeWatchListStatus(accountId, sessionId, mediaId, mediaType, true); } /** *

Remove media to an account's watch list.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param mediaId the id of the media to remove from the watch list. * @param mediaType the type of media to remove from the watch list. * @return The status of the request. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus removeFromWatchList(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType) throws TmdbException { return changeWatchListStatus(accountId, sessionId, mediaId, mediaType, false); } private ResponseStatus changeWatchListStatus(Integer accountId, String sessionId, Integer mediaId, MediaType mediaType, boolean isWatchList) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "watchlist") .addQueryParam(PARAM_SESSION, sessionId); HashMap body = new HashMap<>(); body.put("media_type", mediaType.toString()); body.put("media_id", mediaId); body.put("watchlist", isWatchList); String jsonBody = JsonUtil.toJson(body); return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class); } /** *

Get the favorite movies from the account.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param sortBy nullable - The sort order of the results. * @return The favorite movies of the user. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPage getFavoriteMovies(Integer accountId, String sessionId, String language, Integer page, AccountSortBy sortBy) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "favorite/movies") .addQueryParam(PARAM_SESSION, sessionId) .addLanguage(language) .addPage(page) .addSortBy(sortBy); return mapJsonResult(apiUrl, MovieResultsPage.class); } /** *

Get the favorite tv shows from the account.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param sortBy nullable - The sort order of the results. * @return The favorite tv series of the user. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage getFavoriteTv(Integer accountId, String sessionId, String language, Integer page, AccountSortBy sortBy) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "favorite/tv") .addQueryParam(PARAM_SESSION, sessionId) .addLanguage(language) .addPage(page) .addSortBy(sortBy); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } /** *

Get the lists that as user has created.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param page nullable - The page of results to return. Default: 1. * @return The lists of the user. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieListResultsPage getLists(Integer accountId, String sessionId, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "lists") .addQueryParam(PARAM_SESSION, sessionId) .addPage(page); return mapJsonResult(apiUrl, MovieListResultsPage.class); } /** *

Get the rated movies from the account.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param sortBy nullable - The sort order of the results. * @return The rated movies of the user. * @throws TmdbException If there was an error making the request or mapping the response. */ public RatedMovieResultsPage getRatedMovies(int accountId, String sessionId, String language, Integer page, AccountSortBy sortBy) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "rated/movies") .addQueryParam(PARAM_SESSION, sessionId) .addLanguage(language) .addPage(page) .addSortBy(sortBy); return mapJsonResult(apiUrl, RatedMovieResultsPage.class); } /** *

Get the rated tv shows from the account.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param sortBy nullable - The sort order of the results. * @return The rated tv series of the user. * @throws TmdbException If there was an error making the request or mapping the response. */ public RatedTvSeriesResultsPage getRatedTvSeries(int accountId, String sessionId, String language, Integer page, AccountSortBy sortBy) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "rated/tv") .addQueryParam(PARAM_SESSION, sessionId) .addLanguage(language) .addPage(page) .addSortBy(sortBy); return mapJsonResult(apiUrl, RatedTvSeriesResultsPage.class); } /** *

Get the rated tv episodes from the account.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param sortBy nullable - The sort order of the results. * @return The rated tv episodes of the user. * @throws TmdbException If there was an error making the request or mapping the response. */ public RatedTvEpisodeResultsPage getRatedTvEpisodes(int accountId, String sessionId, String language, Integer page, AccountSortBy sortBy) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "rated/tv/episodes") .addQueryParam(PARAM_SESSION, sessionId) .addLanguage(language) .addPage(page) .addSortBy(sortBy); return mapJsonResult(apiUrl, RatedTvEpisodeResultsPage.class); } /** *

Get the list of movies on an accounts watchlist.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param sortBy nullable - The sort order of the results. * @return The movies in the account's watchlist * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPage getWatchListMovies(Integer accountId, String sessionId, String language, Integer page, AccountSortBy sortBy) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "watchlist/movies") .addQueryParam(PARAM_SESSION, sessionId) .addLanguage(language) .addPage(page) .addSortBy(sortBy); return mapJsonResult(apiUrl, MovieResultsPage.class); } /** *

Get the list of tv series on an accounts watchlist.

*

See the documentation for more info.

* * @param accountId The account id of the user. * @param sessionId nullable - The session id of the user. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param sortBy nullable - The sort order of the results. * @return The tv series in the account's watchlist * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage getWatchListTvSeries(Integer accountId, String sessionId, String language, Integer page, AccountSortBy sortBy) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_ACCOUNT, accountId, "watchlist/tv") .addQueryParam(PARAM_SESSION, sessionId) .addLanguage(language) .addPage(page) .addSortBy(sortBy); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } /** * Needed to tell TMDB API about what type of id is provided. * e.g. see the documentation */ public enum MediaType { MOVIE, TV; @Override public String toString() { return super.toString().toLowerCase(); } } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbApi.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.tools.TmdbHttpClient; import info.movito.themoviedbapi.tools.TmdbUrlReader; import lombok.AccessLevel; import lombok.Getter; /** * The movie db api for getting started. See the * documentation for more info. * * @author Holger Brandl. */ public class TmdbApi { /** * Http client to make requests to the movie database api. */ @Getter(AccessLevel.PROTECTED) private final TmdbUrlReader tmdbUrlReader; /** * Constructor. * * @param apiKey your TMDB api key */ public TmdbApi(String apiKey) { this(new TmdbHttpClient(apiKey)); } /** * Constructor. * * @param tmdbUrlReader the url reader to use */ public TmdbApi(TmdbUrlReader tmdbUrlReader) { this.tmdbUrlReader = tmdbUrlReader; } public TmdbAccount getAccount() { return new TmdbAccount(this); } public TmdbAuthentication getAuthentication() { return new TmdbAuthentication(this); } public TmdbCertifications getCertifications() { return new TmdbCertifications(this); } public TmdbChanges getChanges() { return new TmdbChanges(this); } public TmdbCollections getCollections() { return new TmdbCollections(this); } public TmdbCompanies getCompanies() { return new TmdbCompanies(this); } public TmdbConfiguration getConfiguration() { return new TmdbConfiguration(this); } public TmdbDiscover getDiscover() { return new TmdbDiscover(this); } public TmdbFind getFind() { return new TmdbFind(this); } public TmdbGenre getGenre() { return new TmdbGenre(this); } public TmdbGuestSessions getGuestSessions() { return new TmdbGuestSessions(this); } public TmdbKeywords getKeywords() { return new TmdbKeywords(this); } public TmdbLists getLists() { return new TmdbLists(this); } public TmdbMovieLists getMovieLists() { return new TmdbMovieLists(this); } public TmdbMovies getMovies() { return new TmdbMovies(this); } public TmdbNetworks getNetworks() { return new TmdbNetworks(this); } public TmdbPeopleLists getPeopleLists() { return new TmdbPeopleLists(this); } public TmdbPeople getPeople() { return new TmdbPeople(this); } public TmdbReviews getReviews() { return new TmdbReviews(this); } public TmdbSearch getSearch() { return new TmdbSearch(this); } public TmdbTrending getTrending() { return new TmdbTrending(this); } public TmdbTvEpisodes getTvEpisodes() { return new TmdbTvEpisodes(this); } public TmdbTvEpisodeGroups getTvEpisodeGroups() { return new TmdbTvEpisodeGroups(this); } public TmdbTvSeasons getTvSeasons() { return new TmdbTvSeasons(this); } public TmdbTvSeries getTvSeries() { return new TmdbTvSeries(this); } public TmdbTvSeriesLists getTvSeriesLists() { return new TmdbTvSeriesLists(this); } public TmdbWatchProviders getWatchProviders() { return new TmdbWatchProviders(this); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbAuthentication.java ================================================ package info.movito.themoviedbapi; import java.util.HashMap; import info.movito.themoviedbapi.model.authentication.GuestSession; import info.movito.themoviedbapi.model.authentication.RequestToken; import info.movito.themoviedbapi.model.authentication.Session; import info.movito.themoviedbapi.model.core.responses.ResponseStatusAuthentication; import info.movito.themoviedbapi.model.core.responses.ResponseStatusDelete; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.util.JsonUtil; /** * The movie database api for authentication. See the * documentation for more info. */ public class TmdbAuthentication extends AbstractTmdbApi { protected static final String TMDB_METHOD_AUTH = "authentication"; private static final String PARAM_REQUEST_TOKEN = "request_token"; /** * Create a new TmdbAuthentication instance to call the authentication related TMDb API methods. */ TmdbAuthentication(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Creates a guest session.

*

See the documentation * for more info.

* * @return The guest session. * @throws TmdbException If there was an error making the request or mapping the response. */ public GuestSession createGuestSession() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH, "guest_session/new"); return mapJsonResult(apiUrl, GuestSession.class); } /** *

Creates an unauthenticated request token. This will need to be authenticated by the user using * {@link #getTmdbAuthenticationUrlForRequestToken(RequestToken, String)}. If you cannot redirect the user to a browser, * use {@link #createAuthenticatedRequestToken(RequestToken, String, String)} instead.

*

See the documentation * for more info.

* * @return The unauthenticated request token. * @throws TmdbException If there was an error making the request or mapping the response. */ public RequestToken createRequestToken() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH, "token/new"); return mapJsonResult(apiUrl, RequestToken.class); } /** *

Creates the url to redirect the user to in order to authenticate their request token.

*

See the documentation * for more info.

* * @param token The request token. * @param redirectUrl nullable - The url to redirect the user to after authentication. * @return The url to redirect the user to. * @throws TmdbException If the request token is null or not successful. */ public static String getTmdbAuthenticationUrlForRequestToken(RequestToken token, String redirectUrl) throws TmdbException { if (token == null || !token.getSuccess()) { throw new TmdbException("Invalid request token! The request token must not be null and must be successful!"); } StringBuilder sb = new StringBuilder("https://www.themoviedb.org/authenticate/"); sb.append(token.getRequestToken()); if (redirectUrl != null && !redirectUrl.trim().isEmpty()) { sb.append("?redirect_to=").append(redirectUrl); } return sb.toString(); } /** *

Creates an authenticated request token, with the non-authenticated request token, username and password.

*

Use this function if you have no way of directing the user to a browser for authentication.

*

See the documentation * for more info.

* * @param token The unauthenticated request token. * @param username The TMDB account username. * @param password The TMDB account password. * @return The authenticated request token. * @throws TmdbException If the request token is null or not successful. Or, if there was an error making the request or mapping the * response. */ public RequestToken createAuthenticatedRequestToken(RequestToken token, String username, String password) throws TmdbException { if (token == null || !token.getSuccess()) { throw new TmdbException("Invalid request token! The request token must not be null and must be successful!"); } ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH, "token/validate_with_login"); HashMap body = new HashMap<>(); body.put("username", username); body.put("password", password); body.put(PARAM_REQUEST_TOKEN, token.getRequestToken()); String jsonBody = JsonUtil.toJson(body); return mapJsonResult(apiUrl, jsonBody, RequestType.POST, RequestToken.class); } /** *

Creates a session with an authenticated request token.

*

See the documentation * for more info.

* * @param token The authenticated request token. * @return The session. * @throws TmdbException If the request token is null or not successful. */ public Session createSession(RequestToken token) throws TmdbException { if (token == null || !token.getSuccess()) { throw new TmdbException("Invalid request token! The request token must not be null and must be successful!"); } ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH, "session/new"); HashMap body = new HashMap<>(); body.put(PARAM_REQUEST_TOKEN, token.getRequestToken()); String jsonBody = JsonUtil.toJson(body); return mapJsonResult(apiUrl, jsonBody, RequestType.POST, Session.class); } /** *

Deletes a session.

*

See the documentation * for more info.

* * @param sessionId The session id. * @return The response status. * @throws TmdbException If the session id is null or empty. Or, if there was an error making the request or mapping the response. */ public ResponseStatusDelete deleteSession(String sessionId) throws TmdbException { if (sessionId == null || sessionId.trim().isEmpty()) { throw new TmdbException("Invalid session id! The session id must not be null or empty!"); } ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH, "session"); HashMap body = new HashMap<>(); body.put("session_id", sessionId); String jsonBody = JsonUtil.toJson(body); return mapJsonResult(apiUrl, jsonBody, RequestType.DELETE, ResponseStatusDelete.class); } /** *

Test your API Key to see if it's valid.

*

See the documentation * for more info.

* * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatusAuthentication validateKey() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_AUTH); return mapJsonResult(apiUrl, ResponseStatusAuthentication.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbCertifications.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.certifications.CertificationResults; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for certifications. See the * documentation for more info. */ public class TmdbCertifications extends AbstractTmdbApi { protected static final String TMDB_METHOD_CERTIFICATIONS = "certification"; protected static final String TMDB_METHOD_MOVIE_CERTIFICATIONS = "movie/list"; protected static final String TMDB_METHOD_TV_CERTIFICATIONS = "tv/list"; TmdbCertifications(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get an up to date list of the officially supported movie certifications on TMDB.

*

See the documentation for more info.

* * @return The movie certifications. * @throws TmdbException If there was an error making the request or mapping the response. */ public CertificationResults getMovieCertifications() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CERTIFICATIONS, TMDB_METHOD_MOVIE_CERTIFICATIONS); return mapJsonResult(apiUrl, CertificationResults.class); } /** *

Get an up to date list of the officially supported tv certifications on TMDB.

*

See the documentation for more info.

* * @return The tv certifications. * @throws TmdbException If there was an error making the request or mapping the response. */ public CertificationResults getTvCertifications() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CERTIFICATIONS, TMDB_METHOD_TV_CERTIFICATIONS); return mapJsonResult(apiUrl, CertificationResults.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbChanges.java ================================================ package info.movito.themoviedbapi; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import info.movito.themoviedbapi.model.changes.ChangesResultsPage; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for changes. See the * documentation for more info. */ public class TmdbChanges extends AbstractTmdbApi { protected static final String TMDB_METHOD_CHANGES = "changes"; protected static final String TMDB_METHOD_MOVIE = "movie"; protected static final String TMDB_METHOD_PERSON = "person"; protected static final String TMDB_METHOD_TV = "tv"; /** * Create a new TmdbChanges instance to call the changes related TMDb API methods. */ TmdbChanges(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get a list of all the movie ids that have been changed in the past 24 hours.

*

See the documentation for more info.

* * @param startDate nullable - The start date, in format: YYYY-MM-DD. * @param endDate nullable - The end date, in format: YYYY-MM-DD. * @param page nullable - The page of results to return. Default: 1. * @return The changes results page. * @throws TmdbException If there was an error making the request or mapping the response. */ public ChangesResultsPage getMovieChangesList(String startDate, String endDate, Integer page) throws TmdbException { if (calculateDaysDifference(startDate, endDate) > 14) { throw new IllegalArgumentException("The date range must be less than or equal to 14 days."); } ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, TMDB_METHOD_CHANGES) .addQueryParam("start_date", startDate) .addQueryParam("end_date", endDate) .addPage(page); return mapJsonResult(apiUrl, ChangesResultsPage.class); } /** *

Get a list of all the people ids that have been changed in the past 24 hours.

*

See the documentation for more info.

* * @param startDate nullable - The start date, in format: YYYY-MM-DD. * @param endDate nullable - The end date, in format: YYYY-MM-DD. * @param page nullable - The page of results to return. Default: 1. * @return The changes results page. * @throws TmdbException If there was an error making the request or mapping the response. */ public ChangesResultsPage getPeopleChangesList(String startDate, String endDate, Integer page) throws TmdbException { if (calculateDaysDifference(startDate, endDate) > 14) { throw new IllegalArgumentException("The date range must be less than or equal to 14 days."); } ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, TMDB_METHOD_CHANGES) .addQueryParam("start_date", startDate) .addQueryParam("end_date", endDate) .addPage(page); return mapJsonResult(apiUrl, ChangesResultsPage.class); } /** *

Get a list of all the tv ids that have been changed in the past 24 hours.

*

See the documentation for more info.

* * @param startDate nullable - The start date, in format: YYYY-MM-DD. * @param endDate nullable - The end date, in format: YYYY-MM-DD. * @param page nullable - The page of results to return. Default: 1. * @return nullable - The changes results page. * @throws TmdbException If there was an error making the request or mapping the response. */ public ChangesResultsPage getTvChangesList(String startDate, String endDate, Integer page) throws TmdbException { if (calculateDaysDifference(startDate, endDate) > 14) { throw new IllegalArgumentException("The date range must be less than or equal to 14 days."); } ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, TMDB_METHOD_CHANGES) .addQueryParam("start_date", startDate) .addQueryParam("end_date", endDate) .addPage(page); return mapJsonResult(apiUrl, ChangesResultsPage.class); } /** * Calculate the difference in days between two date strings. * * @param startDateString the start date string, in format: YYYY-MM-DD. * @param endDateString the end date string, in format: YYYY-MM-DD. * @return the difference in days. */ private static long calculateDaysDifference(String startDateString, String endDateString) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate startDate = LocalDate.parse(startDateString, formatter); LocalDate endDate = LocalDate.parse(endDateString, formatter); return ChronoUnit.DAYS.between(startDate, endDate); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbCollections.java ================================================ package info.movito.themoviedbapi; import java.util.List; import info.movito.themoviedbapi.model.collections.CollectionInfo; import info.movito.themoviedbapi.model.collections.Images; import info.movito.themoviedbapi.model.collections.Translation; import info.movito.themoviedbapi.model.collections.Translations; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for collections. See the * documentation for more info. */ public class TmdbCollections extends AbstractTmdbApi { protected static final String TMDB_METHOD_COLLECTION = "collection"; /** * Create a new TmdbCollections instance to call the collections related TMDb API methods. */ TmdbCollections(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get collection details by ID.

*

See the documentation for more info.

* * @param collectionId The collection id. * @param language nullable - The language to query the results in. Default: en-US. * @return The collection info. * @throws TmdbException If there was an error making the request or mapping the response. */ public CollectionInfo getDetails(Integer collectionId, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COLLECTION, collectionId) .addLanguage(language); return mapJsonResult(apiUrl, CollectionInfo.class); } /** *

Get the images that belong to a collection.

*

See the documentation for more info.

* * @param collectionId The collection id. * @param language nullable - The language to query the results in. Default: en-US. * @param includeImageLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it * @return The images. * @throws TmdbException If there was an error making the request or mapping the response. */ public Images getImages(Integer collectionId, String language, String... includeImageLanguage) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COLLECTION, collectionId, "images") .addLanguage(language) .addQueryParamCommandSeparated("include_image_language", includeImageLanguage); return mapJsonResult(apiUrl, Images.class); } /** *

Get all translations for a collection.

*

See the documentation for more info.

* * @param collectionId The collection id. * @return The translations. * @throws TmdbException If there was an error making the request or mapping the response. */ public List getTranslations(Integer collectionId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COLLECTION, collectionId, "translations"); return mapJsonResult(apiUrl, Translations.class).getTranslations(); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbCompanies.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.companies.AlternativeNamesResultsPage; import info.movito.themoviedbapi.model.companies.Company; import info.movito.themoviedbapi.model.core.image.ImageResults; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for companies. See the * documentation for more info. */ public class TmdbCompanies extends AbstractTmdbApi { protected static final String TMDB_METHOD_COMPANY = "company"; /** * Create a new TmdbCompany instance to call the company related TMDb API methods. */ TmdbCompanies(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the company details by ID.

*

See the documentation for more info.

* * @param companyId The company ID * @return The company details * @throws TmdbException If there was an error making the request or mapping the response. */ public Company getDetails(Integer companyId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COMPANY, companyId); return mapJsonResult(apiUrl, Company.class); } /** *

Gets the alternative company names by ID.

*

See the documentation for more info.

* * @param companyId The company ID * @return The alternative company names * @throws TmdbException If there was an error making the request or mapping the response. */ public AlternativeNamesResultsPage getAlternativeNames(Integer companyId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COMPANY, companyId, "alternative_names"); return mapJsonResult(apiUrl, AlternativeNamesResultsPage.class); } /** *

Get the company logos by ID.

*

See the documentation for more info.

* * @param companyId The company ID * @return The company logos * @throws TmdbException If there was an error making the request or mapping the response. */ public ImageResults getImages(Integer companyId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_COMPANY, companyId, "images"); return mapJsonResult(apiUrl, ImageResults.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbConfiguration.java ================================================ package info.movito.themoviedbapi; import java.util.List; import com.fasterxml.jackson.core.type.TypeReference; import info.movito.themoviedbapi.model.configuration.Configuration; import info.movito.themoviedbapi.model.configuration.Country; import info.movito.themoviedbapi.model.configuration.Job; import info.movito.themoviedbapi.model.configuration.Timezone; import info.movito.themoviedbapi.model.core.Language; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for configuration. See the * documentation for more info. */ public class TmdbConfiguration extends AbstractTmdbApi { protected static final String TMDB_METHOD_CONFIGURATION = "configuration"; /** * Create a new TmdbConfig instance to call the config related TMDb API methods. */ TmdbConfiguration(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Query the API configuration details.

*

See the documentation for more info.

* * @return The configuration details * @throws TmdbException If there was an error making the request or mapping the response. */ public Configuration getDetails() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION); return mapJsonResult(apiUrl, Configuration.class); } /** *

Get the list of countries (ISO 3166-1 tags) used throughout TMDB.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @return The configuration details * @throws TmdbException If there was an error making the request or mapping the response. */ public List getCountries(String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION, "countries") .addLanguage(language); return mapJsonResult(apiUrl, new TypeReference<>() { }); } /** *

Get the list of jobs and departments we use on TMDb.

*

See the documentation for more info.

* * @return The list of jobs and departments * @throws TmdbException If there was an error making the request or mapping the response. */ public List getJobs() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION, "jobs"); return mapJsonResult(apiUrl, new TypeReference<>() { }); } /** *

Get the list of languages (ISO 639-1 tags) used throughout TMDB.

*

See the documentation for more info.

* * @return The list of languages * @throws TmdbException If there was an error making the request or mapping the response. */ public List getLanguages() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION, "languages"); return mapJsonResult(apiUrl, new TypeReference<>() { }); } /** *

Get the list of languages (ISO 639-1 tags) used throughout TMDB.

*

See the documentation * for more info.

* * @return The list of languages * @throws TmdbException If there was an error making the request or mapping the response. */ public List getPrimaryTranslations() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION, "primary_translations"); return mapJsonResult(apiUrl, new TypeReference<>() { }); } /** *

Get the list of timezones used throughout TMDB.

*

See the documentation for more info.

* * @return The list of timezones * @throws TmdbException If there was an error making the request or mapping the response. */ public List getTimezones() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION, "timezones"); return mapJsonResult(apiUrl, new TypeReference<>() { }); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbDiscover.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.core.MovieResultsPage; import info.movito.themoviedbapi.model.core.TvSeriesResultsPage; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.builders.discover.DiscoverMovieParamBuilder; import info.movito.themoviedbapi.tools.builders.discover.DiscoverTvParamBuilder; /** * The movie database api for discover. See the * documentation for more info. */ public class TmdbDiscover extends AbstractTmdbApi { protected static final String TMDB_METHOD_DISCOVER = "discover"; protected static final String TMDB_METHOD_MOVIE = "movie"; protected static final String TMDB_METHOD_TV = "tv"; /** * Create a new TmdbDiscover instance to call the discover related TMDb API methods. */ TmdbDiscover(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Find movies using over 30 filters and sort options.

*

See the documentation for more info.

* * @param builder A discover object containing the search criteria wanted * @return the movie results page. */ public MovieResultsPage getMovie(DiscoverMovieParamBuilder builder) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_DISCOVER, TMDB_METHOD_MOVIE) .addPathParams(builder); return mapJsonResult(apiUrl, MovieResultsPage.class); } /** *

Find TV shows using over 30 filters and sort options.

*

See the documentation for more info.

* * @param builder A discover object containing the search criteria wanted * @return the tv series results page. */ public TvSeriesResultsPage getTv(DiscoverTvParamBuilder builder) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_DISCOVER, TMDB_METHOD_TV) .addPathParams(builder); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbFind.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.find.FindResults; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.model.time.ExternalSource; /** * The movie database api for find. See the * documentation for more info. */ public class TmdbFind extends AbstractTmdbApi { protected static final String TMDB_METHOD_FIND = "find"; /** * Create a new TmdbFind instance to call the find related TMDb API methods. */ TmdbFind(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Find data by external ID's.

*

See the documentation for more info.

* * @param externalId The external id of the movie, TV show or people. * @param externalSource The external source of the id. * @param language nullable - The language to query the results in. Default: en-US. * @return The find results */ public FindResults findById(String externalId, ExternalSource externalSource, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_FIND, externalId) .addPathParam("external_source", externalSource.getValue()) .addLanguage(language); return mapJsonResult(apiUrl, FindResults.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbGenre.java ================================================ package info.movito.themoviedbapi; import java.util.List; import info.movito.themoviedbapi.model.core.Genre; import info.movito.themoviedbapi.model.core.Genres; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for genre. See the * documentation for more info. */ public class TmdbGenre extends AbstractTmdbApi { protected static final String TMDB_METHOD_GENRE = "genre"; /** * Create a new TmdbGenre instance to call the genre related TMDb API methods. */ public TmdbGenre(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the list of official genres for movies.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @return The list of official genres for movies. * @throws TmdbException If there was an error making the request or mapping the response. */ public List getMovieList(String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GENRE, "movie/list") .addLanguage(language); return mapJsonResult(apiUrl, Genres.class).getGenres(); } /** *

Get the list of official genres for TV shows.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @return The list of official genres for movies. * @throws TmdbException If there was an error making the request or mapping the response. */ public List getTvList(String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GENRE, "tv/list") .addLanguage(language); return mapJsonResult(apiUrl, Genres.class).getGenres(); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbGuestSessions.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.rated.RatedMovieResultsPage; import info.movito.themoviedbapi.model.rated.RatedTvEpisodeResultsPage; import info.movito.themoviedbapi.model.rated.RatedTvSeriesResultsPage; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.sortby.AccountSortBy; /** * The movie database api for guest sessions. See the * documentation for more info. */ public class TmdbGuestSessions extends AbstractTmdbApi { protected static final String TMDB_METHOD_GUEST_SESSIONS = "guest_session"; /** * Create a new TmdbGuestSessions instance to call the guest sessions related TMDb API methods. */ public TmdbGuestSessions(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the rated movies for a guest session.

*

See the documentation for more info.

* * @param guestSessionId The guest session id of the user. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param sortBy nullable - The sort order of the results. * @return The rated movies of the user. * @throws TmdbException If there was an error making the request or mapping the response. */ public RatedMovieResultsPage getRatedMovies(int guestSessionId, String language, Integer page, AccountSortBy sortBy) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GUEST_SESSIONS, guestSessionId, "rated/movies") .addLanguage(language) .addPage(page) .addSortBy(sortBy); return mapJsonResult(apiUrl, RatedMovieResultsPage.class); } /** *

Get the rated tv shows for a guest session.

*

See the documentation for more info.

* * @param guestSessionId The guest session id of the user. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param sortBy nullable - The sort order of the results. * @return The rated tv series of the user. * @throws TmdbException If there was an error making the request or mapping the response. */ public RatedTvSeriesResultsPage getRatedTvSeries(int guestSessionId, String language, Integer page, AccountSortBy sortBy) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GUEST_SESSIONS, guestSessionId, "rated/tv") .addLanguage(language) .addPage(page) .addSortBy(sortBy); return mapJsonResult(apiUrl, RatedTvSeriesResultsPage.class); } /** *

Get the rated tv episodes for a guest session.

*

See the documentation for more info.

* * @param guestSessionId The guest session id of the user. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param sortBy nullable - The sort order of the results. * @return The rated tv episodes of the user. * @throws TmdbException If there was an error making the request or mapping the response. */ public RatedTvEpisodeResultsPage getRatedTvEpisodes(int guestSessionId, String language, Integer page, AccountSortBy sortBy) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GUEST_SESSIONS, guestSessionId, "rated/tv/episodes") .addLanguage(language) .addPage(page) .addSortBy(sortBy); return mapJsonResult(apiUrl, RatedTvEpisodeResultsPage.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbKeywords.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.core.MovieDbResultsPage; import info.movito.themoviedbapi.model.keywords.Keyword; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.builders.discover.DiscoverMovieParamBuilder; /** * The movie database api for keywords. See the * documentation for more info. */ public class TmdbKeywords extends AbstractTmdbApi { protected static final String TMDB_METHOD_KEYWORD = "keyword"; /** * Create a new TmdbKeywords instance to call the keywords TMDb API methods. */ TmdbKeywords(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the details for a specific keyword.

*

See the documentation for more info.

* * @param keywordId The keyword id. * @return The keyword details. */ public Keyword getDetails(int keywordId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_KEYWORD, keywordId); return mapJsonResult(apiUrl, Keyword.class); } /** * Get the list of movies for a particular keyword by id. * * @return List of movies with the keyword * @deprecated use {@link TmdbDiscover#getMovie(DiscoverMovieParamBuilder)} instead. */ @Deprecated public MovieDbResultsPage getKeywordMovies(String keywordId, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_KEYWORD, keywordId, "movies") .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, MovieDbResultsPage.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbLists.java ================================================ package info.movito.themoviedbapi; import java.util.HashMap; import info.movito.themoviedbapi.model.core.responses.ResponseStatus; import info.movito.themoviedbapi.model.lists.ListDetails; import info.movito.themoviedbapi.model.lists.ListItemStatus; import info.movito.themoviedbapi.model.lists.MovieListCreationStatus; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.util.JsonUtil; /** * The movie database api for lists. See the * documentation for more info. */ public class TmdbLists extends AbstractTmdbApi { protected static final String TMDB_METHOD_LIST = "list"; /** * Create a new TmdbLists instance to call the lists TMDb API methods. */ public TmdbLists(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Add a movie to a list.

*

See the documentation for more info.

* * @param listId The list id. * @param sessionId The session id. * @param movieId The movie id. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus addMovie(Integer listId, String sessionId, Integer movieId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId, "add_item") .addPathParam("session_id", sessionId); HashMap body = new HashMap<>(); body.put("media_id", movieId); String jsonBody = JsonUtil.toJson(body); return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class); } /** *

Use this method to check if an item has already been added to the list.

*

See the documentation for more info.

* * @param listId The list id. * @param language nullable - The language to query the results in. Default: en-US. * @param movieId nullable - The movie id. * @return The list item status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ListItemStatus checkItemStatus(Integer listId, String language, Integer movieId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId, "item_status") .addLanguage(language) .addQueryParam("movie_id", movieId); return mapJsonResult(apiUrl, ListItemStatus.class); } /** *

Clear all items from a list.

*

See the documentation for more info.

* * @param listId The list id. * @param sessionId The session id. * @param confirm Confirm the clear. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus clear(Integer listId, String sessionId, Boolean confirm) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId, "clear") .addPathParam("session_id", sessionId) .addPathParam("confirm", confirm); return mapJsonResult(apiUrl, null, RequestType.POST, ResponseStatus.class); } /** *

Create a new list.

*

See the documentation for more info.

* * @param sessionId The session id. * @param name The name of the list. * @param description The description of the list. * @param language nullable - The language to query the results in. Default: en-US. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieListCreationStatus create(String sessionId, String name, String description, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST) .addPathParam("session_id", sessionId); HashMap body = new HashMap<>(); body.put("name", name); body.put("description", description); body.put("language", language); String jsonBody = JsonUtil.toJson(body); return mapJsonResult(apiUrl, jsonBody, RequestType.POST, MovieListCreationStatus.class); } /** *

Delete a list.

*

See the documentation for more info.

* * @param listId The list id. * @param sessionId The session id. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus delete(Integer listId, String sessionId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId) .addPathParam("session_id", sessionId); return mapJsonResult(apiUrl, null, RequestType.DELETE, ResponseStatus.class); } /** *

Get the details of a list.

*

See the documentation for more info.

* * @param listId The list id. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The movie list. * @throws TmdbException If there was an error making the request or mapping the response. */ public ListDetails getDetails(Integer listId, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId) .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, ListDetails.class); } /** *

Remove a movie from a list.

*

See the documentation for more info.

* * @param listId The list id. * @param sessionId The session id. * @param movieId The movie id. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus removeMovie(Integer listId, String sessionId, Integer movieId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId, "remove_item") .addPathParam("session_id", sessionId); HashMap body = new HashMap<>(); body.put("media_id", movieId); String jsonBody = JsonUtil.toJson(body); return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbMovieLists.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.core.MovieResultsPage; import info.movito.themoviedbapi.model.movielists.MovieResultsPageWithDates; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for movie lists. See the * documentation for more info. */ public class TmdbMovieLists extends AbstractTmdbApi { protected static final String TMDB_METHOD_MOVIE_LISTS = "movie"; /** * Create a new TmdbMovieLists instance to call the movie lists related TMDb API methods. */ TmdbMovieLists(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get a list of movies that are currently in theatres.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US". * @return The now playing movies. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPageWithDates getNowPlaying(String language, Integer page, String region) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE_LISTS, "now_playing") .addLanguage(language) .addPage(page) .addQueryParam("region", region); return mapJsonResult(apiUrl, MovieResultsPageWithDates.class); } /** *

Get a list of movies ordered by popularity.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US". * @return The popular movies. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPage getPopular(String language, Integer page, String region) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE_LISTS, "popular") .addLanguage(language) .addPage(page) .addQueryParam("region", region); return mapJsonResult(apiUrl, MovieResultsPage.class); } /** *

Get a list of movies ordered by rating.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US". * @return The top-rated movies. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPage getTopRated(String language, Integer page, String region) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE_LISTS, "top_rated") .addLanguage(language) .addPage(page) .addQueryParam("region", region); return mapJsonResult(apiUrl, MovieResultsPage.class); } /** *

Get a list of movies that are being released soon.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US". * @return The upcoming movies. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPageWithDates getUpcoming(String language, Integer page, String region) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE_LISTS, "upcoming") .addLanguage(language) .addPage(page) .addQueryParam("region", region); return mapJsonResult(apiUrl, MovieResultsPageWithDates.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbMovies.java ================================================ package info.movito.themoviedbapi; import java.util.HashMap; import info.movito.themoviedbapi.model.core.AccountStates; import info.movito.themoviedbapi.model.core.MovieResultsPage; import info.movito.themoviedbapi.model.core.ReviewResultsPage; import info.movito.themoviedbapi.model.core.responses.ResponseStatus; import info.movito.themoviedbapi.model.core.video.VideoResults; import info.movito.themoviedbapi.model.core.watchproviders.ProviderResults; import info.movito.themoviedbapi.model.movies.AlternativeTitles; import info.movito.themoviedbapi.model.movies.Credits; import info.movito.themoviedbapi.model.movies.ExternalIds; import info.movito.themoviedbapi.model.movies.Images; import info.movito.themoviedbapi.model.movies.KeywordResults; import info.movito.themoviedbapi.model.movies.MovieDb; import info.movito.themoviedbapi.model.movies.MovieListResultsPage; import info.movito.themoviedbapi.model.movies.ReleaseDateResults; import info.movito.themoviedbapi.model.movies.Translations; import info.movito.themoviedbapi.model.movies.changes.ChangeResults; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.appendtoresponse.MovieAppendToResponse; import info.movito.themoviedbapi.util.JsonUtil; /** * The movie database api for movies. See the * documentation for more info. */ public class TmdbMovies extends AbstractTmdbApi { protected static final String TMDB_METHOD_MOVIE = "movie"; /** * Create a new TmdbMovies instance to call the movie related TMDb API methods. */ public TmdbMovies(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the top level details of a movie by ID.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param language nullable - The language to query the results in. Default: en-US. * @param appendToResponse nullable - additional namespaces to append to the result (20 max). * @return The movie details. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieDb getDetails(int movieId, String language, MovieAppendToResponse... appendToResponse) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId) .addLanguage(language) .addAppendToResponses(appendToResponse); return mapJsonResult(apiUrl, MovieDb.class); } /** *

Get the rating, watchlist and favourite status of an account.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param sessionId nullable - The session id of the user. * @param guestSessionId nullable - The guest session id of the user. * @return The account states of the movie. * @throws TmdbException If there was an error making the request or mapping the response. */ public AccountStates getAccountStates(int movieId, String sessionId, String guestSessionId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "account_states") .addQueryParam("session_id", sessionId) .addQueryParam("guest_session_id", guestSessionId); return mapJsonResult(apiUrl, AccountStates.class); } /** *

Get the alternative titles for a movie.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param country nullable - The country to query the results in (ISO-3166-1), e.g. "US". * @return The alternative titles of the movie. * @throws TmdbException If there was an error making the request or mapping the response. */ public AlternativeTitles getAlternativeTitles(int movieId, String country) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "alternative_titles") .addQueryParam("country", country); return mapJsonResult(apiUrl, AlternativeTitles.class); } /** *

Get the recent changes for a movie.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param startDate nullable - The start date, in format: YYYY-MM-DD. * @param endDate nullable - The end date, in format: YYYY-MM-DD. * @param page nullable - The page of results to return. Default: 1. * @return The movie changes. * @throws TmdbException If there was an error making the request or mapping the response. */ public ChangeResults getChanges(int movieId, String startDate, String endDate, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "changes") .addQueryParam("start_date", startDate) .addQueryParam("end_date", endDate) .addPage(page); return mapJsonResult(apiUrl, ChangeResults.class); } /** *

Get the credits for a movie.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param language nullable - The language to query the results in. Default: en-US. * @return The movie credits. * @throws TmdbException If there was an error making the request or mapping the response. */ public Credits getCredits(int movieId, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "credits") .addLanguage(language); return mapJsonResult(apiUrl, Credits.class); } /** *

Get the external ID's for a movie.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @return The external IDs. * @throws TmdbException If there was an error making the request or mapping the response. */ public ExternalIds getExternalIds(int movieId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "external_ids"); return mapJsonResult(apiUrl, ExternalIds.class); } /** *

Get the images that belong to a movie.

*

See the documentation for more info.

* * @param movieId The movie id. * @param language nullable - The language to query the results in. Default: en-US. * @param includeImageLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it * @return The images. * @throws TmdbException If there was an error making the request or mapping the response. */ public Images getImages(int movieId, String language, String... includeImageLanguage) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "images") .addLanguage(language) .addQueryParamCommandSeparated("include_image_language", includeImageLanguage); return mapJsonResult(apiUrl, Images.class); } /** *

Get the keywords that belong to a movie.

*

See the documentation for more info.

* * @param movieId The movie id. * @return The keywords. * @throws TmdbException If there was an error making the request or mapping the response. */ public KeywordResults getKeywords(int movieId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "keywords"); return mapJsonResult(apiUrl, KeywordResults.class); } /** *

Get the newest movie ID.

*

See the documentation for more info.

* * @return The latest movie. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieDb getLatest() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, "latest"); return mapJsonResult(apiUrl, MovieDb.class); } /** *

Get the lists that a movie has been added to.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The movie lists. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieListResultsPage getLists(int movieId, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "lists") .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, MovieListResultsPage.class); } /** *

Get the recommendations for a movie.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The recommended movies. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPage getRecommendations(int movieId, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "recommendations") .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, MovieResultsPage.class); } /** *

Get the release dates and certifications for a movie.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @return The release dates and certifications. * @throws TmdbException If there was an error making the request or mapping the response. */ public ReleaseDateResults getReleaseDates(int movieId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "release_dates"); return mapJsonResult(apiUrl, ReleaseDateResults.class); } /** *

Get the user reviews for a movie.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The movie reviews. * @throws TmdbException If there was an error making the request or mapping the response. */ public ReviewResultsPage getReviews(int movieId, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "reviews") .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, ReviewResultsPage.class); } /** *

Get the similar movies based on genres and keywords.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The similar movies. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPage getSimilar(int movieId, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "similar") .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, MovieResultsPage.class); } /** *

Get the translations for a movie.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @return The translations. * @throws TmdbException If there was an error making the request or mapping the response. */ public Translations getTranslations(int movieId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "translations"); return mapJsonResult(apiUrl, Translations.class); } /** *

Get the videos that have been added to a movie.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param language nullable - The language to query the results in. Default: en-US. * @return The videos. * @throws TmdbException If there was an error making the request or mapping the response. */ public VideoResults getVideos(int movieId, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "videos") .addLanguage(language); return mapJsonResult(apiUrl, VideoResults.class); } /** *

Get the list of streaming providers we have for a movie.

*

In order to use this data you must attribute the source of the data as JustWatch. If TMDb find any usage not complying with these * terms TMDb will revoke access to the API.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @return The watch providers. * @throws TmdbException If there was an error making the request or mapping the response. */ public ProviderResults getWatchProviders(int movieId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "watch/providers"); return mapJsonResult(apiUrl, ProviderResults.class); } /** *

Rate a movie and save it to your rated list.

*

Note: if no guestSessionId or sessionId are provided, the method will add the rating to the API key * holder's account.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param guestSessionId nullable - The guest session id of the user. * @param sessionId nullable - The session id of the user. * @param rating The rating of the movie. Must be: 0 < rating ≤ 10. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus addRating(int movieId, String guestSessionId, String sessionId, double rating) throws TmdbException { if (rating < 0 || rating > 10) { throw new IllegalArgumentException("Rating must be: 0 < rating <= 10"); } ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "rating") .addQueryParam("session_id", sessionId) .addQueryParam("guest_session_id", guestSessionId); HashMap body = new HashMap<>(); body.put("value", rating); String jsonBody = JsonUtil.toJson(body); return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class); } /** *

Delete a user rating.

*

Note: if no guestSessionId or sessionId are provided, the method will delete the rating for the API key * holder's account.

*

See the documentation for more info.

* * @param movieId The TMDb id of the movie. * @param guestSessionId nullable - The guest session id of the user. * @param sessionId nullable - The session id of the user. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus deleteRating(int movieId, String guestSessionId, String sessionId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE, movieId, "rating") .addQueryParam("session_id", sessionId) .addQueryParam("guest_session_id", guestSessionId); return mapJsonResult(apiUrl, null, RequestType.DELETE, ResponseStatus.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbNetworks.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.core.image.ImageResults; import info.movito.themoviedbapi.model.networks.AlternativeNamesResults; import info.movito.themoviedbapi.model.networks.Network; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for networks. See the * documentation for more info. */ public class TmdbNetworks extends AbstractTmdbApi { protected static final String TMDB_METHOD_NETWORK = "network"; /** * Create a new TmdbNetworks instance to call the network related TMDb API methods. */ public TmdbNetworks(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the details of a network.

*

See the documentation for more info.

* * @param networkId The network id. * @return The network details. * @throws TmdbException If there was an error making the request or mapping the response. */ public Network getDetails(int networkId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_NETWORK, networkId); return mapJsonResult(apiUrl, Network.class); } /** *

Get the alternative names of a network.

*

See the documentation for more info.

* * @param networkId The network id. * @return The alternative names of the network. * @throws TmdbException If there was an error making the request or mapping the response. */ public AlternativeNamesResults getAlternativeNames(int networkId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_NETWORK, networkId, "alternative_names"); return mapJsonResult(apiUrl, AlternativeNamesResults.class); } /** *

Get the images of a network.

*

See the documentation for more info.

* * @param networkId The network id. * @return The images of the network. * @throws TmdbException If there was an error making the request or mapping the response. */ public ImageResults getImages(int networkId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_NETWORK, networkId, "images"); return mapJsonResult(apiUrl, ImageResults.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbPeople.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.movies.changes.ChangeResults; import info.movito.themoviedbapi.model.people.ExternalIds; import info.movito.themoviedbapi.model.people.PersonDb; import info.movito.themoviedbapi.model.people.PersonImages; import info.movito.themoviedbapi.model.people.Translations; import info.movito.themoviedbapi.model.people.credits.CombinedPersonCredits; import info.movito.themoviedbapi.model.people.credits.MovieCredits; import info.movito.themoviedbapi.model.people.credits.TvCredits; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.appendtoresponse.PersonAppendToResponse; /** * The movie database api for people. See the * documentation for more info. */ public class TmdbPeople extends AbstractTmdbApi { protected static final String TMDB_METHOD_PERSON = "person"; /** * Create a new TmdbPeople instance to call the people related TMDb API methods. */ TmdbPeople(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Query the top level details of a person.

*

See the documentation for more info.

* * @param personId The TMDb id of the person. * @param language nullable - The language to query the results in. Default: en-US. * @param appendToResponse nullable - additional namespaces to append to the result (20 max). * @return The person details. * @throws TmdbException If there was an error making the request or mapping the response. */ public PersonDb getDetails(int personId, String language, PersonAppendToResponse... appendToResponse) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId) .addLanguage(language) .addAppendToResponses(appendToResponse); return mapJsonResult(apiUrl, PersonDb.class); } /** *

Get the recent changes for a person.

*

See the documentation for more info.

* * @param personId The TMDb id of the person. * @param startDate nullable - The start date, in format: YYYY-MM-DD. * @param endDate nullable - The end date, in format: YYYY-MM-DD. * @param page nullable - The page of results to return. Default: 1. * @return The person changes. * @throws TmdbException If there was an error making the request or mapping the response. */ public ChangeResults getChanges(int personId, String startDate, String endDate, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "changes") .addQueryParam("start_date", startDate) .addQueryParam("end_date", endDate) .addPage(page); return mapJsonResult(apiUrl, ChangeResults.class); } /** *

Get the combined movie and TV credits that belong to a person.

*

See the documentation for more info.

* * @param personId The TMDb id of the person. * @param language nullable - The language to query the results in. Default: en-US. * @return The combined person credits. * @throws TmdbException If there was an error making the request or mapping the response. */ public CombinedPersonCredits getCombinedCredits(int personId, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "combined_credits") .addLanguage(language); return mapJsonResult(apiUrl, CombinedPersonCredits.class); } /** *

Get the external ID's that belong to a person.

*

See the documentation for more info.

* * @param personId The TMDb id of the person. * @return The external IDs. * @throws TmdbException If there was an error making the request or mapping the response. */ public ExternalIds getExternalIds(int personId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "external_ids"); return mapJsonResult(apiUrl, ExternalIds.class); } /** *

Get the profile images that belong to a person.

*

See the documentation for more info.

* * @param personId The TMDb id of the person. * @return The profile images. * @throws TmdbException If there was an error making the request or mapping the response. */ public PersonImages getImages(int personId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "images"); return mapJsonResult(apiUrl, PersonImages.class); } /** *

Get the newest created person. This is a live response and will continuously change.

*

See the documentation for more info.

* * @return The latest person. * @throws TmdbException If there was an error making the request or mapping the response. */ public PersonDb getLatest() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, "latest"); return mapJsonResult(apiUrl, PersonDb.class); } /** *

Get the movie credits for a person.

*

See the documentation for more info.

* * @param personId The TMDb id of the person. * @param language nullable - The language to query the results in. Default: en-US. * @return The movie credits. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieCredits getMovieCredits(int personId, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "movie_credits") .addLanguage(language); return mapJsonResult(apiUrl, MovieCredits.class); } /** *

Get the TV credits that belong to a person..

*

See the documentation for more info.

* * @param personId The TMDb id of the person. * @param language nullable - The language to query the results in. Default: en-US. * @return The TV credits. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvCredits getTvCredits(int personId, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "tv_credits") .addLanguage(language); return mapJsonResult(apiUrl, TvCredits.class); } /** *

Get the translations that belong to a person.

*

See the documentation for more info.

* * @param personId The TMDb id of the person. * @return The translations. * @throws TmdbException If there was an error making the request or mapping the response. */ public Translations getTranslations(int personId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PERSON, personId, "translations"); return mapJsonResult(apiUrl, Translations.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbPeopleLists.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.core.popularperson.PopularPersonResultsPage; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for people lists. See the * documentation for more info. */ public class TmdbPeopleLists extends AbstractTmdbApi { protected static final String TMDB_METHOD_PEOPLE_LISTS = "person/popular"; TmdbPeopleLists(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get a list of people ordered by popularity.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The popular people. * @throws TmdbException If there was an error making the request or mapping the response. */ public PopularPersonResultsPage getPopular(String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_PEOPLE_LISTS) .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, PopularPersonResultsPage.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbReviews.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.reviews.Review; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for reviews. See the * documentation for more info. */ public class TmdbReviews extends AbstractTmdbApi { protected static final String TMDB_METHOD_MOVIE_REVIEW = "reviews"; /** * Create a new TmdbReviews instance to call the reviews related TMDb API methods. */ TmdbReviews(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the details for a review.

*

See the documentation for more info.

* * @param reviewId The review id. * @return the reviews */ public Review getDetails(int reviewId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_MOVIE_REVIEW, reviewId); return mapJsonResult(apiUrl, Review.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbSearch.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.core.MovieResultsPage; import info.movito.themoviedbapi.model.core.TvSeriesResultsPage; import info.movito.themoviedbapi.model.core.multi.MultiResultsPage; import info.movito.themoviedbapi.model.core.popularperson.PopularPersonResultsPage; import info.movito.themoviedbapi.model.search.CollectionResultsPage; import info.movito.themoviedbapi.model.search.CompanyResultsPage; import info.movito.themoviedbapi.model.search.KeywordResultsPage; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; import static info.movito.themoviedbapi.TmdbCollections.TMDB_METHOD_COLLECTION; import static info.movito.themoviedbapi.TmdbMovies.TMDB_METHOD_MOVIE; import static info.movito.themoviedbapi.TmdbPeople.TMDB_METHOD_PERSON; import static info.movito.themoviedbapi.TmdbTvSeries.TMDB_METHOD_TV; /** * The movie database api for searching. See the * documentation for more info. */ public class TmdbSearch extends AbstractTmdbApi { protected static final String TMDB_METHOD_SEARCH = "search"; protected static final String TMDB_METHOD_MULTI = "multi"; private static final String PARAM_QUERY = "query"; /** * Create a new TmdbSearch instance to call the search TMDb API methods. */ public TmdbSearch(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Search for collections by their original, translated and alternative names.

*

See the documentation for more info.

* * @param query The query to search for. * @param language nullable - The language to query the results in. Default: en-US. * @param includeAdult nullable - Whether to include adult results in the search. * @param page nullable - The page of results to return. Default: 1. * @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US". * @return The collection results. * @throws TmdbException If there was an error making the request or mapping the response. */ public CollectionResultsPage searchCollection(String query, String language, Boolean includeAdult, Integer page, String region) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, TMDB_METHOD_COLLECTION) .addPathParam(PARAM_QUERY, query) .addQueryParam("include_adult", includeAdult) .addQueryParam("region", region) .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, CollectionResultsPage.class); } /** *

Search for companies by their original and alternative names.

*

See the documentation for more info.

* * @param query The query to search for. * @param page nullable - The page of results to return. Default: 1. * @return The company results. * @throws TmdbException If there was an error making the request or mapping the response. */ public CompanyResultsPage searchCompany(String query, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, "company") .addPathParam(PARAM_QUERY, query) .addPage(page); return mapJsonResult(apiUrl, CompanyResultsPage.class); } /** *

Search for keywords by their name.

*

See the documentation for more info.

* * @param query The query to search for. * @param page nullable - The page of results to return. Default: 1. * @return The keyword results. * @throws TmdbException If there was an error making the request or mapping the response. */ public KeywordResultsPage searchKeyword(String query, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, "keyword") .addPathParam(PARAM_QUERY, query) .addPage(page); return mapJsonResult(apiUrl, KeywordResultsPage.class); } /** *

Search for movies by their original, translated and alternative titles.

*

See the documentation for more info.

* * @param query The query to search for. * @param includeAdult nullable - Whether to include adult results in the search. * @param language nullable - The language to query the results in. Default: en-US. * @param primaryReleaseYear nullable - Filter the results so that only the primary release year matches this value. * @param page nullable - The page of results to return. Default: 1. * @param region nullable - The region (ISO-3166-1 code) to display the results for. e.g. "US". * @param year nullable - Filter the results so that only the release year matches this value. * @return The movie results. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPage searchMovie(String query, Boolean includeAdult, String language, String primaryReleaseYear, Integer page, String region, String year) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, TMDB_METHOD_MOVIE) .addPathParam(PARAM_QUERY, query) .addQueryParam("include_adult", includeAdult) .addQueryParam("primary_release_year", primaryReleaseYear) .addQueryParam("region", region) .addQueryParam("year", year) .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, MovieResultsPage.class); } /** *

Use multi search when you want to search for movies, TV shows and people in a single request.

*

See the documentation for more info.

* * @param query The query to search for. * @param includeAdult nullable - Whether to include adult results in the search. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The multi results. * @throws TmdbException If there was an error making the request or mapping the response. */ public MultiResultsPage searchMulti(String query, Boolean includeAdult, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, TMDB_METHOD_MULTI) .addPathParam(PARAM_QUERY, query) .addQueryParam("include_adult", includeAdult) .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, MultiResultsPage.class); } /** *

Search for people by their name and also known as names.

*

See the documentation for more info.

* * @param query The query to search for. * @param includeAdult nullable - Whether to include adult results in the search. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The person results. * @throws TmdbException If there was an error making the request or mapping the response. */ public PopularPersonResultsPage searchPerson(String query, Boolean includeAdult, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, TMDB_METHOD_PERSON) .addPathParam(PARAM_QUERY, query) .addQueryParam("include_adult", includeAdult) .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, PopularPersonResultsPage.class); } /** *

Search for TV shows by their original, translated and also known as names.

*

See the documentation for more info.

* * @param query The query to search for. * @param firstAirDateYear nullable - Filter the results so that only the first air date year matches this value. * @param includeAdult nullable - Whether to include adult results in the search. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param year nullable - Filter the results so that only the release year matches this value. * @return The TV series results. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage searchTv(String query, Integer firstAirDateYear, Boolean includeAdult, String language, Integer page, Integer year) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_SEARCH, TMDB_METHOD_TV) .addPathParam(PARAM_QUERY, query) .addQueryParam("first_air_date_year", firstAirDateYear) .addQueryParam("include_adult", includeAdult) .addQueryParam("year", year) .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbTrending.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.core.MovieResultsPage; import info.movito.themoviedbapi.model.core.TvSeriesResultsPage; import info.movito.themoviedbapi.model.core.multi.MultiResultsPage; import info.movito.themoviedbapi.model.core.popularperson.PopularPersonResultsPage; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.model.time.TimeWindow; /** * The movie database api for trending media. See the * documentation for more info. */ public class TmdbTrending extends AbstractTmdbApi { protected static final String TMDB_METHOD_TRENDING = "trending"; /** * Create a new TmdbTrending instance to call the rending TMDb API methods. */ TmdbTrending(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the trending movies, TV shows and people.

*

See the documentation for more info.

* * @param timeWindow The time window for the trending media. * @param language nullable - The language to query the results in. Default: en-US. * @return The trending media. * @throws TmdbException If there was an error making the request or mapping the response. */ public MultiResultsPage getAll(TimeWindow timeWindow, String language) throws TmdbException { return getAll(timeWindow, language, 1); } /** *

Get the trending movies, TV shows and people.

*

See the documentation for more info.

* * @param timeWindow The time window for the trending media. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The trending media. * @throws TmdbException If there was an error making the request or mapping the response. */ public MultiResultsPage getAll(TimeWindow timeWindow, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "all", timeWindow.getValue()) .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, MultiResultsPage.class); } /** *

Get the trending movies on TMDB.

*

See the documentation for more info.

* * @param timeWindow The time window for the trending movie. * @param language nullable - The language to query the results in. Default: en-US. * @return The trending movies. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPage getMovies(TimeWindow timeWindow, String language) throws TmdbException { return getMovies(timeWindow, language, 1); } /** *

Get the trending movies on TMDB.

*

See the documentation for more info.

* * @param timeWindow The time window for the trending movie. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The trending movies. * @throws TmdbException If there was an error making the request or mapping the response. */ public MovieResultsPage getMovies(TimeWindow timeWindow, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "movie", timeWindow.getValue()) .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, MovieResultsPage.class); } /** *

Get the trending people on TMDB.

*

See the documentation for more info.

* * @param timeWindow The time window for the trending people. * @param language nullable - The language to query the results in. Default: en-US. * @return The trending people. * @throws TmdbException If there was an error making the request or mapping the response. */ public PopularPersonResultsPage getPeople(TimeWindow timeWindow, String language) throws TmdbException { return getPeople(timeWindow, language, 1); } /** *

Get the trending people on TMDB.

*

See the documentation for more info.

* * @param timeWindow The time window for the trending people. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The trending people. * @throws TmdbException If there was an error making the request or mapping the response. */ public PopularPersonResultsPage getPeople(TimeWindow timeWindow, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "person", timeWindow.getValue()) .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, PopularPersonResultsPage.class); } /** *

Get the trending TV shows on TMDB.

*

See the documentation for more info.

* * @param timeWindow The time window for the trending tv. * @param language nullable - The language to query the results in. Default: en-US. * @return The trending tv. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage getTv(TimeWindow timeWindow, String language) throws TmdbException { return getTv(timeWindow, language, 1); } /** *

Get the trending TV shows on TMDB.

*

See the documentation for more info.

* * @param timeWindow The time window for the trending tv. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The trending tv. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage getTv(TimeWindow timeWindow, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TRENDING, "tv", timeWindow.getValue()) .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbTvEpisodeGroups.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.tv.episodegroups.TvEpisodeGroups; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for tv episode groups. See the * documentation for more info. */ public class TmdbTvEpisodeGroups extends AbstractTmdbApi { protected static final String TMDB_METHOD_TV_EPISODE_GROUPS = "tv/episode_group"; /** * Create a new TmdbTvEpisodeGroups instance to call the tv episode groups TMDb API methods. */ TmdbTvEpisodeGroups(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the details of a TV episode group.

*

See the documentation for more info.

* * @param tvEpisodeGroupId The id of the tv episode group. * @return The tv episode group details. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvEpisodeGroups getDetails(String tvEpisodeGroupId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV_EPISODE_GROUPS, tvEpisodeGroupId); return mapJsonResult(apiUrl, TvEpisodeGroups.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbTvEpisodes.java ================================================ package info.movito.themoviedbapi; import java.util.HashMap; import info.movito.themoviedbapi.model.core.AccountStates; import info.movito.themoviedbapi.model.core.responses.ResponseStatus; import info.movito.themoviedbapi.model.core.video.VideoResults; import info.movito.themoviedbapi.model.tv.core.ChangeResults; import info.movito.themoviedbapi.model.tv.core.Translations; import info.movito.themoviedbapi.model.tv.episode.EpisodeCredits; import info.movito.themoviedbapi.model.tv.episode.ExternalIds; import info.movito.themoviedbapi.model.tv.episode.Images; import info.movito.themoviedbapi.model.tv.episode.TvEpisodeDb; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.appendtoresponse.TvEpisodesAppendToResponse; import info.movito.themoviedbapi.util.JsonUtil; import static info.movito.themoviedbapi.TmdbTvSeasons.TMDB_METHOD_TV_SEASON; import static info.movito.themoviedbapi.TmdbTvSeries.TMDB_METHOD_TV; /** * The movie database api for tv episodes. See the * documentation for more info. */ public class TmdbTvEpisodes extends AbstractTmdbApi { public static final String TMDB_METHOD_TV_EPISODE = "episode"; /** * Create a new TmdbTvEpisodes instance to call the tv episodes TMDb API methods. */ TmdbTvEpisodes(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Query the details of a TV episode.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param seasonNumber The season number of the tv series. * @param episodeNumber The episode number of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @param appendToResponse nullable - additional namespaces to append to the result (20 max). * @return The tv episode details. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvEpisodeDb getDetails(int seriesId, int seasonNumber, int episodeNumber, String language, TvEpisodesAppendToResponse... appendToResponse) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber) .addLanguage(language) .addAppendToResponses(appendToResponse); return mapJsonResult(apiUrl, TvEpisodeDb.class); } /** *

Get the rating, watchlist and favourite status.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param seasonNumber The season number of the tv series. * @param episodeNumber The episode number of the tv series. * @param sessionId nullable - The session id of the user. * @param guestSessionId nullable - The guest session id of the user. * @return The account states. * @throws TmdbException If there was an error making the request or mapping the response. */ public AccountStates getAccountStates(int seriesId, int seasonNumber, int episodeNumber, String sessionId, String guestSessionId) throws TmdbException { ApiUrl apiUrl = new ApiUrl( TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "account_states") .addQueryParam("session_id", sessionId) .addQueryParam("guest_session_id", guestSessionId); return mapJsonResult(apiUrl, AccountStates.class); } /** *

Get the recent changes for a TV episode.

*

See the documentation for more info.

* * @param episodeId The TMDb id of the tv episode. * @return The change results. * @throws TmdbException If there was an error making the request or mapping the response. */ public ChangeResults getChanges(int episodeId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, TMDB_METHOD_TV_EPISODE, episodeId, "changes"); return mapJsonResult(apiUrl, ChangeResults.class); } /** *

Get the credits for a TV episode.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param seasonNumber The season number of the tv series. * @param episodeNumber The episode number of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @return The credits. * @throws TmdbException If there was an error making the request or mapping the response. */ public EpisodeCredits getCredits(int seriesId, int seasonNumber, int episodeNumber, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl( TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "credits") .addLanguage(language); return mapJsonResult(apiUrl, EpisodeCredits.class); } /** *

Get a list of external IDs that have been added to a TV episode.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param seasonNumber The season number of the tv series. * @param episodeNumber The episode number of the tv series. * @return The external IDs. * @throws TmdbException If there was an error making the request or mapping the response. */ public ExternalIds getExternalIds(int seriesId, int seasonNumber, int episodeNumber) throws TmdbException { ApiUrl apiUrl = new ApiUrl( TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "external_ids"); return mapJsonResult(apiUrl, ExternalIds.class); } /** *

Get the images that belong to a TV episode.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param seasonNumber The season number of the tv series. * @param episodeNumber The episode number of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @param includeImageLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it * @return The images. * @throws TmdbException If there was an error making the request or mapping the response. */ public Images getImages(int seriesId, int seasonNumber, int episodeNumber, String language, String... includeImageLanguage) throws TmdbException { ApiUrl apiUrl = new ApiUrl( TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "images") .addLanguage(language) .addQueryParamCommandSeparated("include_image_language", includeImageLanguage); return mapJsonResult(apiUrl, Images.class); } /** *

Get the translations that have been added to a TV episode.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param seasonNumber The season number of the tv series. * @param episodeNumber The episode number of the tv series. * @return The translations. * @throws TmdbException If there was an error making the request or mapping the response. */ public Translations getTranslations(int seriesId, int seasonNumber, int episodeNumber) throws TmdbException { ApiUrl apiUrl = new ApiUrl( TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "translations"); return mapJsonResult(apiUrl, Translations.class); } /** *

Get the videos that belong to a TV episode.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param seasonNumber The season number of the tv series. * @param episodeNumber The episode number of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @param includeVideoLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it * @return The videos. * @throws TmdbException If there was an error making the request or mapping the response. */ public VideoResults getVideos(int seriesId, int seasonNumber, int episodeNumber, String language, String... includeVideoLanguage) throws TmdbException { ApiUrl apiUrl = new ApiUrl( TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "videos") .addLanguage(language) .addQueryParamCommandSeparated("include_video_language", includeVideoLanguage); return mapJsonResult(apiUrl, VideoResults.class); } /** *

Rate a TV episode and save it to your rated list.

*

Note: if no guestSessionId or sessionId are provided, the method will add the rating to the API key * holder's account.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param seasonNumber The season number of the tv series. * @param episodeNumber The episode number of the tv series. * @param guestSessionId nullable - The guest session id of the user. * @param sessionId nullable - The session id of the user. * @param rating The rating of the tv episode. Must be: 0 < rating ≤ 10. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus addRating(int seriesId, int seasonNumber, int episodeNumber, String guestSessionId, String sessionId, double rating) throws TmdbException { if (rating < 0 || rating > 10) { throw new IllegalArgumentException("Rating must be: 0 < rating <= 10"); } ApiUrl apiUrl = new ApiUrl( TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "rating") .addQueryParam("session_id", sessionId) .addQueryParam("guest_session_id", guestSessionId); HashMap body = new HashMap<>(); body.put("value", rating); String jsonBody = JsonUtil.toJson(body); return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class); } /** *

Delete your rating on a TV episode.

*

Note: if no guestSessionId or sessionId are provided, the method will delete the rating for the API key * holder's account.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param seasonNumber The season number of the tv series. * @param episodeNumber The episode number of the tv series. * @param guestSessionId nullable - The guest session id of the user. * @param sessionId nullable - The session id of the user. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus deleteRating(int seriesId, int seasonNumber, int episodeNumber, String guestSessionId, String sessionId) throws TmdbException { ApiUrl apiUrl = new ApiUrl( TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, TMDB_METHOD_TV_EPISODE, episodeNumber, "rating") .addQueryParam("session_id", sessionId) .addQueryParam("guest_session_id", guestSessionId); return mapJsonResult(apiUrl, null, RequestType.DELETE, ResponseStatus.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbTvSeasons.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.core.video.VideoResults; import info.movito.themoviedbapi.model.core.watchproviders.ProviderResults; import info.movito.themoviedbapi.model.tv.core.Translations; import info.movito.themoviedbapi.model.tv.core.credits.AggregateCredits; import info.movito.themoviedbapi.model.tv.core.credits.Credits; import info.movito.themoviedbapi.model.tv.season.AccountStateResults; import info.movito.themoviedbapi.model.tv.season.ChangeResults; import info.movito.themoviedbapi.model.tv.season.ExternalIds; import info.movito.themoviedbapi.model.tv.season.Images; import info.movito.themoviedbapi.model.tv.season.TvSeasonDb; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.appendtoresponse.TvSeasonsAppendToResponse; import static info.movito.themoviedbapi.TmdbTvSeries.TMDB_METHOD_TV; /** * The movie database api for tv seasons. See the * documentation for more info. */ public class TmdbTvSeasons extends AbstractTmdbApi { public static final String TMDB_METHOD_TV_SEASON = "season"; /** * Create a new TmdbTvSeasons instance to call the tv seasons TMDb API methods. */ TmdbTvSeasons(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Query the details of the TV season.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the TV series. * @param seasonNumber The season number. * @param language nullable - The language to query the results in. Default: en-US. * @param appendToResponse nullable - additional namespaces to append to the result (20 max). * @return The TV season details. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeasonDb getDetails(int seriesId, int seasonNumber, String language, TvSeasonsAppendToResponse... appendToResponse) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber) .addLanguage(language) .addAppendToResponses(appendToResponse); return mapJsonResult(apiUrl, TvSeasonDb.class); } /** *

Get the rating, watchlist and favourite status.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the TV series. * @param seasonNumber The season number. * @param sessionId nullable - The session id of the user. * @param guestSessionId nullable - The guest session id of the user. * @return The account states. * @throws TmdbException If there was an error making the request or mapping the response. */ public AccountStateResults getAccountStates(int seriesId, int seasonNumber, String sessionId, String guestSessionId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "account_states") .addQueryParam("session_id", sessionId) .addQueryParam("guest_session_id", guestSessionId); return mapJsonResult(apiUrl, AccountStateResults.class); } /** *

Get the aggregate credits (cast and crew) that have been added to a TV season.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the TV series. * @param seasonNumber The season number. * @param language nullable - The language to query the results in. Default: en-US. * @return The aggregate credits. * @throws TmdbException If there was an error making the request or mapping the response. */ public AggregateCredits getAggregateCredits(int seriesId, int seasonNumber, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "aggregate_credits") .addLanguage(language); return mapJsonResult(apiUrl, AggregateCredits.class); } /** *

Get the recent changes for a TV season.

*

See the documentation for more info.

* * @param seasonId The TMDb id of the TV season. * @param startDate nullable - The start date, in format: YYYY-MM-DD. * @param endDate nullable - The end date, in format: YYYY-MM-DD. * @param page nullable - The page of results to return. Default: 1. * @return The changes. * @throws TmdbException If there was an error making the request or mapping the response. */ public ChangeResults getChanges(int seasonId, String startDate, String endDate, int page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, TMDB_METHOD_TV_SEASON, seasonId, "changes") .addQueryParam("start_date", startDate) .addQueryParam("end_date", endDate) .addPage(page); return mapJsonResult(apiUrl, ChangeResults.class); } /** *

Get the latest tv season credits.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the TV series. * @param seasonNumber The season number. * @param language nullable - The language to query the results in. Default: en-US. * @return The credits. * @throws TmdbException If there was an error making the request or mapping the response. */ public Credits getCredits(int seriesId, int seasonNumber, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "credits") .addLanguage(language); return mapJsonResult(apiUrl, Credits.class); } /** *

Get a list of external IDs that have been added to a TV season.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the TV series. * @param seasonNumber The season number. * @return The external IDs. * @throws TmdbException If there was an error making the request or mapping the response. */ public ExternalIds getExternalIds(int seriesId, int seasonNumber) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "external_ids"); return mapJsonResult(apiUrl, ExternalIds.class); } /** *

Get the images that belong to a TV season.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the TV series. * @param seasonNumber The season number. * @param language nullable - The language to query the results in. Default: en-US. * @param includeImageLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it * @return The images. * @throws TmdbException If there was an error making the request or mapping the response. */ public Images getImages(int seriesId, int seasonNumber, String language, String... includeImageLanguage) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "images") .addLanguage(language) .addQueryParamCommandSeparated("include_image_language", includeImageLanguage); return mapJsonResult(apiUrl, Images.class); } /** *

Get the translations for a TV season.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the TV series. * @param seasonNumber The season number. * @return The translations. * @throws TmdbException If there was an error making the request or mapping the response. */ public Translations getTranslations(int seriesId, int seasonNumber) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "translations"); return mapJsonResult(apiUrl, Translations.class); } /** *

Get the videos that belong to a TV season.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the TV series. * @param seasonNumber The season number. * @param language nullable - The language to query the results in. Default: en-US. * @param includeVideoLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it * @return The videos. * @throws TmdbException If there was an error making the request or mapping the response. */ public VideoResults getVideos(int seriesId, int seasonNumber, String language, String... includeVideoLanguage) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "videos") .addLanguage(language) .addQueryParamCommandSeparated("include_video_language", includeVideoLanguage); return mapJsonResult(apiUrl, VideoResults.class); } /** *

Get the list of streaming providers we have for a TV season.

*

In order to use this data you must attribute the source of the data as JustWatch. If TMDb find any usage not complying with these * terms TMDb will revoke access to the API.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the TV series. * @param seasonNumber The season number. * @param language nullable - The language to query the results in. Default: en-US. * @return The watch providers. * @throws TmdbException If there was an error making the request or mapping the response. */ public ProviderResults getWatchProviders(int seriesId, int seasonNumber, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, TMDB_METHOD_TV_SEASON, seasonNumber, "watch/providers") .addLanguage(language); return mapJsonResult(apiUrl, ProviderResults.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbTvSeries.java ================================================ package info.movito.themoviedbapi; import java.util.HashMap; import info.movito.themoviedbapi.model.core.AccountStates; import info.movito.themoviedbapi.model.core.ReviewResultsPage; import info.movito.themoviedbapi.model.core.TvKeywords; import info.movito.themoviedbapi.model.core.TvSeriesResultsPage; import info.movito.themoviedbapi.model.core.responses.ResponseStatus; import info.movito.themoviedbapi.model.core.video.VideoResults; import info.movito.themoviedbapi.model.core.watchproviders.ProviderResults; import info.movito.themoviedbapi.model.tv.core.ChangeResults; import info.movito.themoviedbapi.model.tv.core.credits.AggregateCredits; import info.movito.themoviedbapi.model.tv.core.credits.Credits; import info.movito.themoviedbapi.model.tv.series.AlternativeTitleResults; import info.movito.themoviedbapi.model.tv.series.ContentRatingResults; import info.movito.themoviedbapi.model.tv.series.EpisodeGroupResults; import info.movito.themoviedbapi.model.tv.series.ExternalIds; import info.movito.themoviedbapi.model.tv.series.Images; import info.movito.themoviedbapi.model.tv.series.ScreenedTheatricallyResults; import info.movito.themoviedbapi.model.tv.series.Translations; import info.movito.themoviedbapi.model.tv.series.TvSeriesDb; import info.movito.themoviedbapi.model.tv.series.TvSeriesListResultsPage; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.appendtoresponse.TvSeriesAppendToResponse; import info.movito.themoviedbapi.util.JsonUtil; /** * The movie database api for tv series. See the * documentation for more info. */ public class TmdbTvSeries extends AbstractTmdbApi { public static final String TMDB_METHOD_TV = "tv"; /** * Create a new TmdbTvSeries instance to call the tv series TMDb API methods. */ TmdbTvSeries(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the details of a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @param appendToResponse nullable - additional namespaces to append to the result (20 max). * @return The tv series details. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesDb getDetails(int seriesId, String language, TvSeriesAppendToResponse... appendToResponse) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId) .addLanguage(language) .addAppendToResponses(appendToResponse); return mapJsonResult(apiUrl, TvSeriesDb.class); } /** *

Get the rating, watchlist and favourite status.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param sessionId nullable - The session id of the user. * @param guestSessionId nullable - The guest session id of the user. * @return The account states of the tv series. * @throws TmdbException If there was an error making the request or mapping the response. */ public AccountStates getAccountStates(int seriesId, String sessionId, String guestSessionId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "account_states") .addQueryParam("session_id", sessionId) .addQueryParam("guest_session_id", guestSessionId); return mapJsonResult(apiUrl, AccountStates.class); } /** *

Get the aggregate credits (cast and crew) that have been added to a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @throws TmdbException If there was an error making the request or mapping the response. */ public AggregateCredits getAggregateCredits(int seriesId, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "aggregate_credits") .addLanguage(language); return mapJsonResult(apiUrl, AggregateCredits.class); } /** *

Get the alternative titles that have been added to a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @return The alternative titles of the tv series. * @throws TmdbException If there was an error making the request or mapping the response. */ public AlternativeTitleResults getAlternativeTitles(int seriesId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "alternative_titles"); return mapJsonResult(apiUrl, AlternativeTitleResults.class); } /** *

Get the recent changes for a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param startDate nullable - The start date, in format: YYYY-MM-DD. * @param endDate nullable - The end date, in format: YYYY-MM-DD. * @param page nullable - The page of results to return. Default: 1. * @return The tv series changes. * @throws TmdbException If there was an error making the request or mapping the response. */ public ChangeResults getChanges(int seriesId, String startDate, String endDate, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "changes") .addQueryParam("start_date", startDate) .addQueryParam("end_date", endDate) .addPage(page); return mapJsonResult(apiUrl, ChangeResults.class); } /** *

Get the content ratings that have been added to a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @return The tv series content ratings. * @throws TmdbException If there was an error making the request or mapping the response. */ public ContentRatingResults getContentRatings(int seriesId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "content_ratings"); return mapJsonResult(apiUrl, ContentRatingResults.class); } /** *

Get the latest season credits of a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @return The tv series credits. * @throws TmdbException If there was an error making the request or mapping the response. */ public Credits getCredits(int seriesId, String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "credits") .addLanguage(language); return mapJsonResult(apiUrl, Credits.class); } /** *

Get the episode groups that have been added to a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @return The tv series episode groups. * @throws TmdbException If there was an error making the request or mapping the response. */ public EpisodeGroupResults getEpisodeGroups(int seriesId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "episode_groups"); return mapJsonResult(apiUrl, EpisodeGroupResults.class); } /** *

Get a list of external IDs that have been added to a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @return The external IDs. * @throws TmdbException If there was an error making the request or mapping the response. */ public ExternalIds getExternalIds(int seriesId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "external_ids"); return mapJsonResult(apiUrl, ExternalIds.class); } /** *

Get the images that have been added to a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @param includeImageLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it * @return The tv series images. * @throws TmdbException If there was an error making the request or mapping the response. */ public Images getImages(int seriesId, String language, String... includeImageLanguage) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "images") .addLanguage(language) .addQueryParamCommandSeparated("include_image_language", includeImageLanguage); return mapJsonResult(apiUrl, Images.class); } /** *

Get a list of keywords that have been added to a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @return The tv series keywords. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvKeywords getKeywords(int seriesId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "keywords"); return mapJsonResult(apiUrl, TvKeywords.class); } /** *

Get the newest TV show ID.

*

See the documentation for more info.

* * @return The latest tv series. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesDb getLatest() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, "latest"); return mapJsonResult(apiUrl, TvSeriesDb.class); } /** *

Get the lists that a TV series has been added to..

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The tv series lists. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesListResultsPage getLists(int seriesId, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "lists") .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, TvSeriesListResultsPage.class); } /** *

Get the recommendations for a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The tv series lists. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage getRecommendations(int seriesId, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "recommendations") .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } /** *

Get the reviews that have been added to a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The tv series reviews. * @throws TmdbException If there was an error making the request or mapping the response. */ public ReviewResultsPage getReviews(int seriesId, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "reviews") .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, ReviewResultsPage.class); } /** *

Get the seasons and episodes that have screened theatrically.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @return The tv series seasons and episodes that have screened theatrically. * @throws TmdbException If there was an error making the request or mapping the response. */ public ScreenedTheatricallyResults getScreenedTheatrically(int seriesId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "screened_theatrically"); return mapJsonResult(apiUrl, ScreenedTheatricallyResults.class); } /** *

Get the similar TV shows.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return The similar tv series. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage getSimilar(int seriesId, String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "similar") .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } /** *

Get the translations that have been added to a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @return The translations. * @throws TmdbException If there was an error making the request or mapping the response. */ public Translations getTranslations(int seriesId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "translations"); return mapJsonResult(apiUrl, Translations.class); } /** *

Get the videos that belong to a TV show.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param language nullable - The language to query the results in. Default: en-US. * @param includeVideoLanguage nullable - Specify a comma separated list of ISO-639-1 values to query, for example: en,it * @return The videos. * @throws TmdbException If there was an error making the request or mapping the response. */ public VideoResults getVideos(int seriesId, String language, String... includeVideoLanguage) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "videos") .addLanguage(language) .addQueryParamCommandSeparated("include_image_language", includeVideoLanguage); return mapJsonResult(apiUrl, VideoResults.class); } /** *

Get the list of streaming providers we have for a TV show.

*

In order to use this data you must attribute the source of the data as JustWatch. If TMDb find any usage not complying with these * terms TMDb will revoke access to the API.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @return The watch providers. * @throws TmdbException If there was an error making the request or mapping the response. */ public ProviderResults getWatchProviders(int seriesId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "watch/providers"); return mapJsonResult(apiUrl, ProviderResults.class); } /** *

Rate a TV show and save it to your rated list.

*

Note: if no guestSessionId or sessionId are provided, the method will add the rating to the API key * holder's account.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param guestSessionId nullable - The guest session id of the user. * @param sessionId nullable - The session id of the user. * @param rating The rating of the tv series. Must be: 0 < rating ≤ 10. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus addRating(int seriesId, String guestSessionId, String sessionId, double rating) throws TmdbException { if (rating < 0 || rating > 10) { throw new IllegalArgumentException("Rating must be: 0 < rating <= 10"); } ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "rating") .addQueryParam("session_id", sessionId) .addQueryParam("guest_session_id", guestSessionId); HashMap body = new HashMap<>(); body.put("value", rating); String jsonBody = JsonUtil.toJson(body); return mapJsonResult(apiUrl, jsonBody, RequestType.POST, ResponseStatus.class); } /** *

Delete a user rating.

*

Note: if no guestSessionId or sessionId are provided, the method will delete the rating for the API key * holder's account.

*

See the documentation for more info.

* * @param seriesId The TMDb id of the tv series. * @param guestSessionId nullable - The guest session id of the user. * @param sessionId nullable - The session id of the user. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ public ResponseStatus deleteRating(int seriesId, String guestSessionId, String sessionId) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, seriesId, "rating") .addQueryParam("session_id", sessionId) .addQueryParam("guest_session_id", guestSessionId); return mapJsonResult(apiUrl, null, RequestType.DELETE, ResponseStatus.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbTvSeriesLists.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.core.TvSeriesResultsPage; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; import static info.movito.themoviedbapi.TmdbTvSeries.TMDB_METHOD_TV; /** * The movie database api for tv series lists. See the * documentation for more info. */ public class TmdbTvSeriesLists extends AbstractTmdbApi { /** * Create a new TmdbTvSeriesLists instance to call the tv series lists TMDb API methods. */ TmdbTvSeriesLists(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get a list of TV shows airing today.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param timezone nullable - The timezone to use when querying the air dates. * @return a list of TV shows airing today. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage getAiringToday(String language, Integer page, String timezone) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, "airing_today") .addLanguage(language) .addPage(page) .addQueryParam("timezone", timezone); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } /** *

Get a list of TV shows that air in the next 7 days.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @param timezone nullable - The timezone to use when querying the air dates. * @return a list of TV shows that air in the next 7 days. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage getOnTheAir(String language, Integer page, String timezone) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, "on_the_air") .addLanguage(language) .addPage(page) .addQueryParam("timezone", timezone); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } /** *

Get a list of TV shows ordered by popularity.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return a list of TV shows ordered by popularity. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage getPopular(String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, "popular") .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } /** *

Get a list of TV shows ordered by rating.

*

See the documentation for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @param page nullable - The page of results to return. Default: 1. * @return a list of TV shows ordered by rating. * @throws TmdbException If there was an error making the request or mapping the response. */ public TvSeriesResultsPage getTopRated(String language, Integer page) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_TV, "top_rated") .addLanguage(language) .addPage(page); return mapJsonResult(apiUrl, TvSeriesResultsPage.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/TmdbWatchProviders.java ================================================ package info.movito.themoviedbapi; import info.movito.themoviedbapi.model.watchproviders.AvailableRegionResults; import info.movito.themoviedbapi.model.watchproviders.ProviderResults; import info.movito.themoviedbapi.tools.ApiUrl; import info.movito.themoviedbapi.tools.TmdbException; /** * The movie database api for watch providers. See the * documentation for more info. */ public class TmdbWatchProviders extends AbstractTmdbApi { protected static final String TMDB_METHOD_WATCH_PROVIDERS = "watch/providers"; /** * Create a new TmdbWatchProviders instance to call the watch providers TMDb API methods. */ TmdbWatchProviders(TmdbApi tmdbApi) { super(tmdbApi); } /** *

Get the list of the countries we have watch provider (OTT/streaming) data for.

*

See the documentation * for more info.

* * @param language nullable - The language to query the results in. Default: en-US. */ public AvailableRegionResults getAvailableRegions(String language) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_WATCH_PROVIDERS) .addLanguage(language); return mapJsonResult(apiUrl, AvailableRegionResults.class); } /** *

Get the list of streaming providers we have for movies.

*

See the documentation * for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @param watchRegion nullable - The watch region, e.g. "AD" */ public ProviderResults getMovieProviders(String language, String watchRegion) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_WATCH_PROVIDERS, "movie") .addLanguage(language) .addQueryParam("watch_region", watchRegion); return mapJsonResult(apiUrl, ProviderResults.class); } /** *

Get the list of streaming providers we have for TV shows.

*

In order to use this data you must attribute the source of the data as JustWatch. If TMDb find any usage not complying with these * terms TMDb will revoke access to the API.

*

See the documentation * for more info.

* * @param language nullable - The language to query the results in. Default: en-US. * @param watchRegion nullable - The watch region, e.g. "AD". */ public ProviderResults getTvProviders(String language, String watchRegion) throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_WATCH_PROVIDERS, "tv") .addLanguage(language) .addQueryParam("watch_region", watchRegion); return mapJsonResult(apiUrl, ProviderResults.class); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/account/Account.java ================================================ package info.movito.themoviedbapi.model.account; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.NamedIdElement; import lombok.Data; import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) @Data public class Account extends NamedIdElement { @JsonProperty("avatar") private Avatar avatar; @JsonProperty("iso_639_1") private String iso6391; @JsonProperty("iso_3166_1") private String iso31661; @JsonProperty("include_adult") private Boolean includeAdult; @JsonProperty("username") private String username; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/account/Avatar.java ================================================ package info.movito.themoviedbapi.model.account; import java.util.HashMap; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class Avatar extends AbstractJsonMapping { @JsonProperty("gravatar") private Map gravatar = new HashMap<>(); @JsonProperty("tmdb") private Map tmdb = new HashMap<>(); public String getGravatarHash() { return gravatar.get("hash"); } public String getTmdbAvatarPath() { return tmdb.get("avatar_path"); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/authentication/GuestSession.java ================================================ package info.movito.themoviedbapi.model.authentication; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class GuestSession extends AbstractJsonMapping { @JsonProperty("expires_at") private String expiresAt; @JsonProperty("guest_session_id") private String guestSessionId; @JsonProperty("success") private Boolean success; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/authentication/RequestToken.java ================================================ package info.movito.themoviedbapi.model.authentication; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class RequestToken extends AbstractJsonMapping { @JsonProperty("expires_at") private String expires; @JsonProperty("request_token") private String requestToken; @JsonProperty("success") private Boolean success; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/authentication/Session.java ================================================ package info.movito.themoviedbapi.model.authentication; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class Session extends AbstractJsonMapping { @JsonProperty("session_id") private String sessionId; @JsonProperty("success") private Boolean success; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/certifications/Certification.java ================================================ package info.movito.themoviedbapi.model.certifications; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class Certification extends AbstractJsonMapping { @JsonProperty("certification") private String certification; @JsonProperty("meaning") private String meaning; @JsonProperty("order") private Integer order; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/certifications/CertificationResults.java ================================================ package info.movito.themoviedbapi.model.certifications; import java.util.HashMap; import java.util.List; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class CertificationResults extends AbstractJsonMapping { @JsonProperty("certifications") private Map> certifications = new HashMap<>(); } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/changes/Change.java ================================================ package info.movito.themoviedbapi.model.changes; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.IdElement; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class Change extends IdElement { @JsonProperty("adult") private Boolean adult; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/changes/ChangesResultsPage.java ================================================ package info.movito.themoviedbapi.model.changes; import info.movito.themoviedbapi.model.core.ResultsPage; public class ChangesResultsPage extends ResultsPage { } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/collections/CollectionInfo.java ================================================ package info.movito.themoviedbapi.model.collections; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.NamedIdElement; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class CollectionInfo extends NamedIdElement { @JsonProperty("overview") private String overview; @JsonProperty("poster_path") private String posterPath; @JsonProperty("backdrop_path") private String backdropPath; @JsonProperty("parts") private List parts = new ArrayList<>(); } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/collections/Data.java ================================================ package info.movito.themoviedbapi.model.collections; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.EqualsAndHashCode; @lombok.Data @EqualsAndHashCode(callSuper = false) public class Data extends AbstractJsonMapping { @JsonProperty("title") private String title; @JsonProperty("overview") private String overview; @JsonProperty("homepage") private String homepage; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/collections/Images.java ================================================ package info.movito.themoviedbapi.model.collections; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.IdElement; import info.movito.themoviedbapi.model.core.image.Artwork; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class Images extends IdElement { @JsonProperty("backdrops") private List backdrops = new ArrayList<>(); @JsonProperty("posters") private List posters = new ArrayList<>(); } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/collections/Part.java ================================================ package info.movito.themoviedbapi.model.collections; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.IdElement; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class Part extends IdElement { @JsonProperty("adult") private boolean adult; @JsonProperty("backdrop_path") private String backdropPath; @JsonProperty("title") private String title; @JsonProperty("original_language") private String originalLanguage; @JsonProperty("original_title") private String originalTitle; @JsonProperty("overview") private String overview; @JsonProperty("poster_path") private String posterPath; @JsonProperty("media_type") private String mediaType; @JsonProperty("genre_ids") private List genreIds = new ArrayList<>(); @JsonProperty("popularity") private Double popularity; @JsonProperty("release_date") private String releaseDate; @JsonProperty("video") private Boolean video; @JsonProperty("vote_average") private Double voteAverage; @JsonProperty("vote_count") private Integer voteCount; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/collections/Translation.java ================================================ package info.movito.themoviedbapi.model.collections; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.EqualsAndHashCode; @lombok.Data @EqualsAndHashCode(callSuper = false) public class Translation extends AbstractJsonMapping { @JsonProperty("iso_3166_1") private String iso31661; @JsonProperty("iso_639_1") private String iso6391; @JsonProperty("name") private String name; @JsonProperty("english_name") private String englishName; @JsonProperty("data") private Data data; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/collections/Translations.java ================================================ package info.movito.themoviedbapi.model.collections; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.IdElement; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class Translations extends IdElement { @JsonProperty("translations") private List translations = new ArrayList<>(); } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/companies/AlternativeNamesResultsPage.java ================================================ package info.movito.themoviedbapi.model.companies; import info.movito.themoviedbapi.model.core.AlternativeName; import info.movito.themoviedbapi.model.core.Results; public class AlternativeNamesResultsPage extends Results { } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/companies/Company.java ================================================ package info.movito.themoviedbapi.model.companies; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.NamedIdElement; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class Company extends NamedIdElement { @JsonProperty("description") private String description; @JsonProperty("headquarters") private String headquarters; @JsonProperty("homepage") private String homepage; @JsonProperty("logo_path") private String logoPath; @JsonProperty("origin_country") private String originCountry; @JsonProperty("parent_company") private Integer parentCompanyId; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/configuration/Configuration.java ================================================ package info.movito.themoviedbapi.model.configuration; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class Configuration extends AbstractJsonMapping { @JsonProperty("images") private ImageConfig imageConfig; @JsonProperty("change_keys") private List changeKeys = new ArrayList<>(); } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/configuration/Country.java ================================================ package info.movito.themoviedbapi.model.configuration; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class Country extends AbstractJsonMapping { @JsonProperty("iso_3166_1") private String iso31661; @JsonProperty("english_name") private String englishName; @JsonProperty("native_name") private String nativeName; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/configuration/ImageConfig.java ================================================ package info.movito.themoviedbapi.model.configuration; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class ImageConfig extends AbstractJsonMapping { @JsonProperty("base_url") private String baseUrl; @JsonProperty("secure_base_url") private String secureBaseUrl; @JsonProperty("poster_sizes") private List posterSizes = new ArrayList<>(); @JsonProperty("backdrop_sizes") private List backdropSizes = new ArrayList<>(); @JsonProperty("profile_sizes") private List profileSizes = new ArrayList<>(); @JsonProperty("logo_sizes") private List logoSizes = new ArrayList<>(); @JsonProperty("still_sizes") private List stillSizes = new ArrayList<>(); } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/configuration/Job.java ================================================ package info.movito.themoviedbapi.model.configuration; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class Job extends AbstractJsonMapping { @JsonProperty("department") private String department; @JsonProperty("jobs") private List jobs = new ArrayList<>(); } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/configuration/Timezone.java ================================================ package info.movito.themoviedbapi.model.configuration; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class Timezone extends AbstractJsonMapping { @JsonProperty("iso_3166_1") private String iso31661; @JsonProperty("zones") private List zones = new ArrayList<>(); } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/AbstractJsonMapping.java ================================================ package info.movito.themoviedbapi.model.core; import java.io.Serial; import java.io.Serializable; import java.util.HashMap; import java.util.Map; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; /** * @author Holger Brandl */ public abstract class AbstractJsonMapping implements Serializable { @Serial private static final long serialVersionUID = -640106859893308644L; private final Map newItems = new HashMap<>(); /** * Gets the new items that were not mapped to any field from a model extending this class. * * @return the new items. */ @JsonAnyGetter public Map getNewItems() { return newItems; } @JsonAnySetter public void setNewItems(String name, Object value) { newItems.put(name, value); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/AccountStates.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class AccountStates extends IdElement { @JsonProperty("favorite") private Boolean favorite; @JsonProperty("rated") private Object rated; @JsonProperty("watchlist") private Boolean watchlist; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/AlternativeName.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class AlternativeName extends AbstractJsonMapping { @JsonProperty("name") private String name; @JsonProperty("type") private String type; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/AlternativeTitle.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class AlternativeTitle extends AbstractJsonMapping { @JsonProperty("iso_3166_1") private String iso31661; @JsonProperty("title") private String title; @JsonProperty("type") private String type; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/Genre.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("genre") public class Genre extends NamedIdElement { } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/Genres.java ================================================ package info.movito.themoviedbapi.model.core; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class Genres extends AbstractJsonMapping { @JsonProperty("genres") private List genres = new ArrayList<>(); } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/IdElement.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; /** * Base class for json wrappers with id element. * * @author Holger Brandl */ @Data @EqualsAndHashCode(callSuper = false) public class IdElement extends AbstractJsonMapping { @JsonProperty("id") private int id; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/Language.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class Language extends AbstractJsonMapping { @JsonProperty("iso_639_1") private String iso6391; @JsonProperty("english_name") private String englishName; @JsonProperty("name") private String name; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/Movie.java ================================================ package info.movito.themoviedbapi.model.core; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) @JsonIgnoreProperties(value = {"media_type"}) public class Movie extends IdElement { @JsonProperty("adult") private Boolean adult; @JsonProperty("backdrop_path") private String backdropPath; @JsonProperty("genre_ids") private List genreIds = new ArrayList<>(); @JsonProperty("origin_country") private List originCountry = new ArrayList<>(); @JsonProperty("original_language") private String originalLanguage; @JsonProperty("original_title") private String originalTitle; @JsonProperty("overview") private String overview; @JsonProperty("popularity") private Double popularity; @JsonProperty("poster_path") private String posterPath; @JsonProperty("release_date") private String releaseDate; @JsonProperty("title") private String title; @JsonProperty("video") private Boolean video; @JsonProperty("vote_average") private Double voteAverage; @JsonProperty("vote_count") private Integer voteCount; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/MovieDbResultsPage.java ================================================ package info.movito.themoviedbapi.model.core; import info.movito.themoviedbapi.model.movies.MovieDb; public class MovieDbResultsPage extends ResultsPage { } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/MovieResultsPage.java ================================================ package info.movito.themoviedbapi.model.core; public class MovieResultsPage extends ResultsPage { } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/NamedElement.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class NamedElement extends AbstractJsonMapping { @JsonProperty("name") private String name; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/NamedIdElement.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class NamedIdElement extends IdElement { @JsonProperty("name") private String name; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/NamedStringIdElement.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class NamedStringIdElement extends StringIdElement { @JsonProperty("name") private String name; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/ProductionCompany.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) @JsonRootName("production_company") public class ProductionCompany extends NamedIdElement { @JsonProperty("logo_path") private String logoPath; @JsonProperty("origin_country") private String originCountry; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/ProductionCountry.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) @JsonRootName("production_country") public class ProductionCountry extends AbstractJsonMapping { @JsonProperty("iso_3166_1") private String isoCode; @JsonProperty("name") private String name; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/Results.java ================================================ package info.movito.themoviedbapi.model.core; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public abstract class Results extends IdElement implements Iterable { @JsonProperty("results") private List results = new ArrayList<>(); @Override public Iterator iterator() { return results.iterator(); } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/ResultsPage.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public abstract class ResultsPage extends Results { @JsonProperty("page") private Integer page; @JsonProperty("total_pages") private Integer totalPages; @JsonProperty("total_results") private Integer totalResults; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/Review.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.reviews.AuthorDetails; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class Review extends StringIdElement { @JsonProperty("author") private String author; @JsonProperty("author_details") private AuthorDetails authorDetails; @JsonProperty("content") private String content; @JsonProperty("created_at") private String createdAt; @JsonProperty("updated_at") private String updatedAt; @JsonProperty("url") private String url; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/ReviewResultsPage.java ================================================ package info.movito.themoviedbapi.model.core; public class ReviewResultsPage extends ResultsPage { } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/StringIdElement.java ================================================ package info.movito.themoviedbapi.model.core; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; /** * Base class for json wrappers with id element. * * @author Holger Brandl */ @Data @EqualsAndHashCode(callSuper = false) public class StringIdElement extends AbstractJsonMapping { @JsonProperty("id") private String id; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/TvKeywords.java ================================================ package info.movito.themoviedbapi.model.core; import info.movito.themoviedbapi.model.keywords.Keyword; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class TvKeywords extends Results { } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/TvSeries.java ================================================ package info.movito.themoviedbapi.model.core; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) @JsonIgnoreProperties(value = {"media_type"}) public class TvSeries extends IdElement { @JsonProperty("adult") private Boolean adult; @JsonProperty("backdrop_path") private String backdropPath; @JsonProperty("genre_ids") private List genreIds = new ArrayList<>(); @JsonProperty("origin_country") private List originCountry = new ArrayList<>(); @JsonProperty("original_language") private String originalLanguage; @JsonProperty("original_name") private String originalName; @JsonProperty("overview") private String overview; @JsonProperty("popularity") private Double popularity; @JsonProperty("poster_path") private String posterPath; @JsonProperty("first_air_date") private String firstAirDate; @JsonProperty("name") private String name; @JsonProperty("vote_average") private Double voteAverage; @JsonProperty("vote_count") private Integer voteCount; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/TvSeriesResultsPage.java ================================================ package info.movito.themoviedbapi.model.core; public class TvSeriesResultsPage extends ResultsPage { } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/image/Artwork.java ================================================ package info.movito.themoviedbapi.model.core.image; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class Artwork extends AbstractJsonMapping { @JsonProperty("iso_639_1") private String iso6391; @JsonProperty("file_path") private String filePath; @JsonProperty("aspect_ratio") private Double aspectRatio; @JsonProperty("height") private Integer height; @JsonProperty("width") private Integer width; @JsonProperty("vote_average") private Double voteAverage; @JsonProperty("vote_count") private Integer voteCount; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/image/Image.java ================================================ package info.movito.themoviedbapi.model.core.image; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.StringIdElement; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class Image extends StringIdElement { @JsonProperty("aspect_ratio") private Double aspectRatio; @JsonProperty("file_path") private String filePath; @JsonProperty("height") private Integer height; @JsonProperty("file_type") private String fileType; @JsonProperty("vote_average") private Double voteAverage; @JsonProperty("vote_count") private Integer voteCount; @JsonProperty("width") private Integer width; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/image/ImageResults.java ================================================ package info.movito.themoviedbapi.model.core.image; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.IdElement; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class ImageResults extends IdElement { @JsonProperty("logos") private List logos = new ArrayList<>(); } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/multi/Multi.java ================================================ package info.movito.themoviedbapi.model.core.multi; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; /** * Interface that is needed for /search/multi request *

* {@link MultiMovie}, {@link MultiPerson} and {@link MultiTvSeries} implement this interface.

*

Each of them returns corresponding {@link MediaType}

* * @see info.movito.themoviedbapi.TmdbSearch#searchMulti(String, Boolean, String, Integer) */ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "media_type") @JsonSubTypes({ @JsonSubTypes.Type(value = MultiMovie.class, name = "movie"), @JsonSubTypes.Type(value = MultiPerson.class, name = "person"), @JsonSubTypes.Type(value = MultiTvSeries.class, name = "tv") }) public interface Multi { /** * Used to determine type Multi object without {@code instanceof()} or {@code getClass}. */ MediaType getMediaType(); /** * The type of media. */ enum MediaType { MOVIE, PERSON, TV_SERIES } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/multi/MultiMovie.java ================================================ package info.movito.themoviedbapi.model.core.multi; import info.movito.themoviedbapi.model.core.Movie; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class MultiMovie extends Movie implements Multi { @Override public MediaType getMediaType() { return MediaType.MOVIE; } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/multi/MultiPerson.java ================================================ package info.movito.themoviedbapi.model.core.multi; import info.movito.themoviedbapi.model.core.popularperson.PopularPerson; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class MultiPerson extends PopularPerson implements Multi { @Override public MediaType getMediaType() { return MediaType.PERSON; } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/multi/MultiResultsPage.java ================================================ package info.movito.themoviedbapi.model.core.multi; import info.movito.themoviedbapi.model.core.ResultsPage; public class MultiResultsPage extends ResultsPage { } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/multi/MultiTvSeries.java ================================================ package info.movito.themoviedbapi.model.core.multi; import info.movito.themoviedbapi.model.core.TvSeries; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class MultiTvSeries extends TvSeries implements Multi { @Override public MediaType getMediaType() { return MediaType.TV_SERIES; } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/popularperson/KnownFor.java ================================================ package info.movito.themoviedbapi.model.core.popularperson; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.IdElement; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class KnownFor extends IdElement { @JsonProperty("adult") private Boolean adult; @JsonProperty("backdrop_path") private String backdropPath; @JsonProperty("genre_ids") private List genreIds = new ArrayList<>(); @JsonProperty("popularity") private Double popularity; @JsonProperty("media_type") private String mediaType; @JsonProperty("original_language") private String originalLanguage; @JsonProperty("original_title") private String originalTitle; @JsonProperty("overview") private String overview; @JsonProperty("poster_path") private String posterPath; @JsonProperty("release_date") private String releaseDate; @JsonProperty("title") private String title; @JsonProperty("video") private Boolean video; @JsonProperty("vote_average") private Double voteAverage; @JsonProperty("vote_count") private Integer voteCount; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/popularperson/PopularPerson.java ================================================ package info.movito.themoviedbapi.model.core.popularperson; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.NamedIdElement; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) @JsonIgnoreProperties(value = {"media_type"}) public class PopularPerson extends NamedIdElement { @JsonProperty("adult") private Boolean adult; @JsonProperty("gender") private Integer gender; @JsonProperty("known_for") private List knownFor = new ArrayList<>(); @JsonProperty("known_for_department") private String knownForDepartment; @JsonProperty("original_name") private String originalName; @JsonProperty("popularity") private Double popularity; @JsonProperty("profile_path") private String profilePath; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/popularperson/PopularPersonResultsPage.java ================================================ package info.movito.themoviedbapi.model.core.popularperson; import info.movito.themoviedbapi.model.core.ResultsPage; public class PopularPersonResultsPage extends ResultsPage { } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/responses/ResponseStatus.java ================================================ package info.movito.themoviedbapi.model.core.responses; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import info.movito.themoviedbapi.tools.TmdbResponseCode; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class ResponseStatus extends AbstractJsonMapping { @JsonProperty("status_code") private TmdbResponseCode statusCode; @JsonProperty("status_message") private String statusMessage; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/responses/ResponseStatusAuthentication.java ================================================ package info.movito.themoviedbapi.model.core.responses; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class ResponseStatusAuthentication extends ResponseStatus { @JsonProperty("success") private Boolean success; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/responses/ResponseStatusDelete.java ================================================ package info.movito.themoviedbapi.model.core.responses; import com.fasterxml.jackson.annotation.JsonProperty; import info.movito.themoviedbapi.model.core.AbstractJsonMapping; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class ResponseStatusDelete extends AbstractJsonMapping { @JsonProperty("success") private Boolean success; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/responses/TmdbResponseException.java ================================================ package info.movito.themoviedbapi.model.core.responses; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.TmdbResponseCode; import lombok.Getter; import lombok.ToString; @Getter @ToString public class TmdbResponseException extends TmdbException { private final TmdbResponseCode responseCode; public TmdbResponseException(TmdbResponseCode responseCode) { super(responseCode.toString()); this.responseCode = responseCode; } public TmdbResponseException(String message) { super(message); this.responseCode = null; } public TmdbResponseException(Exception exception) { super(exception); this.responseCode = null; } } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/video/Video.java ================================================ package info.movito.themoviedbapi.model.core.video; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; import info.movito.themoviedbapi.model.core.NamedStringIdElement; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) @JsonRootName("video") public class Video extends NamedStringIdElement { @JsonProperty("iso_639_1") private String iso6391; @JsonProperty("iso_3166_1") private String iso31661; @JsonProperty("key") private String key; @JsonProperty("site") private String site; @JsonProperty("size") private Integer size; @JsonProperty("type") private String type; @JsonProperty("official") private Boolean official; @JsonProperty("published_at") private String publishedAt; } ================================================ FILE: src/main/java/info/movito/themoviedbapi/model/core/video/VideoResults.java ================================================ package info.movito.themoviedbapi.model.core.video; import info.movito.themoviedbapi.model.core.Results; public class VideoResults extends Results