New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Title fallback language implementation #4

Merged
merged 3 commits into from Aug 8, 2017

Conversation

Projects
None yet
2 participants
@ProIcons
Member

ProIcons commented Aug 3, 2017

Title Fallback Language System Implementation.

TMDb Service when you query an object in a specific language, and this specific object is not translated for this language, returns to you this object localized on its original language.

This behavior is unwanted while some objects are not localized in english, and if a user has the ability to talk in the English language but selects as his default language his primary one, and this object is not localized on his language, and it's original language is a language he cannot speak or read. It will result to an unwanted result.

This system allows users to have a fallback language for every object they query with this scraper.

For instance if you have a movie object originating from Japan, and has no localization for Greek Language, and you have set the Greek language as your default language. You'll end up getting a Japan Localized object.

If however you choose to have as fallback language the English one, which most of the objects are translated into this language. With the sacrifice of some more queries to the api, you will end up having a readable in English language object.

This Functionality won't be enabled by default.

For those who want to enable it they have to navigate on their

Settings -> Movies/TV Shows -> Scraper -> themoviedb.org -> titleFallback

And check the according checkbox to enable the functionality
And select from the titleFallbackLanguage Select List the according language they want to set as their fallback.

As of now there are no known bugs. In some tv shows such as "The Simpsons" which contains something over 650 episodes, the scraping time with this functionality enabled is slow, over 10 seconds.

For the Testing Section, the data were chosen by the following algorithms:

   public static void findTvSeriesWithTitleIsNotOriginalTitleAndOriginalLanguageIsEnglish() throws IOException {
        JsonReader reader = new JsonReader(new FileReader("tv_series_ids_05_23_2017.json"));
        Results data = gson.fromJson(reader, Results.class);
        for (Item p : data.results) {

            System.out.println(p.name+" - "+p.id);
            try {
                TvShow tvShow = wrapper.tvService().tv(p.id, "de", new AppendToResponse(AppendToResponseItem.TRANSLATIONS)).execute().body();
                if (!tvShow.original_language.equals("en") && tvShow.original_name.equals(tvShow.name) && tvShow.overview != null && !tvShow.overview.equals("")) {
                    boolean found = false;
                    for (Translations.Translation translation : tvShow.translations.translations) {
                        if (translation.iso_639_1.equals("el")) {
                            TvShow tvShow2 = wrapper.tvService().tv(tvShow.id, "el").execute().body();
                            if (!tvShow2.original_name.equals(tvShow2.name)) {
                                System.out.println("Found!");
                                found = true;
                            }
                            break;
                        }
                    }
                    if (found)
                        break;

                }
            } catch (Exception exc) {
                System.out.println("\t"+exc.getMessage());
                continue;
            }
        }
    }
   public static void findTvepisodeWithGreekLanguageAndNotEmptyOverview() throws IOException {
        JsonReader reader = new JsonReader(new FileReader("tv_series_ids_05_23_2017.json"));
        Results data = gson.fromJson(reader, Results.class);
        int score;
        for (Item p : data.results) {
            score=0;
            int episodes = 0;
            int seasons = 0;
            System.out.println(p.name+" - "+p.id);
            try {

                TvShow show = wrapper.tvService().tv(p.id,"el").execute().body();

                for (TvSeason season : show.seasons) {
                    seasons++;
                    TvSeason ses = wrapper.tvSeasonsService().season(p.id, season.season_number, "el").execute().body();
                    for (BaseTvEpisode episode : ses.episodes) {
                        episodes++;
                        if (episode.name == null || episode.name.equals(""))
                            continue;
                        String nameToken = episode.name.split(" ")[0];
                        if ((nameToken.equals("Επεισόδιο") || nameToken.equals("Επεισοδιο"))) {
                            System.out.println("Possible Scanning... S" + seasons+ "E"+episodes+" - "+episode.name + " - " + episode.overview);
                            if (!episode.overview.equals("")) {
                                System.out.println("Found!");
                                score = 1;
                                break;
                            }
                        }

                    }
                    if (score == 1)
                        break;
                }
                if (score == 1)
                    break;

            } catch (Exception exc) {
                System.out.println("\t"+exc.getMessage());
                continue;
            }
            System.out.println("\t\tSeasons: " + seasons + "  -  Episodes:" + episodes);
        }
    }

Static Variable Decleration.

The static variable is used only for tests for debugging purposes. It won't affect anyhow the operation of the scraper

ProIcons and others added some commits May 19, 2017

Title fallback language implementation
-Added support to scrape title in a fallback language, when title is not translated on the preferred language.

-Fixed Compatibility to work with UweTrottmann/tmdb-java#45 and to Comply with JDK 7.

Updated POM and Tests
-Updated tmdb2-java version on pom, with the latest released version.
-Updated tests.

Updated based on Reviews
Title Fallback Language System Implementation.
-Added Fallback System on TmdbMovieMetadataProvider
-Added Fallback System on TmdbMovieSetMetadataProvider
-Added Fallback System on TmdbTvShowMetadataProvider
-Obsolete test file removed.
-Created tests for the 3 MetadataProviders.

@mlaggner mlaggner merged commit d1a6765 into tinyMediaManager:master Aug 8, 2017

@mlaggner

This comment has been minimized.

Show comment
Hide comment
@mlaggner

mlaggner Aug 8, 2017

Contributor

thanks - your contribution looks good so far

Contributor

mlaggner commented Aug 8, 2017

thanks - your contribution looks good so far

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment