Skip to content
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

when scrape title and missing preferred country then fallback to international title, patch attached #2613

Closed
Omertron opened this issue Mar 16, 2015 · 3 comments

Comments

@Omertron
Copy link
Member

Original issue 2614 created by Omertron on 2013-02-27T06:15:09.000Z:

I propose new boolean property "imdb.aka.fallback.international".
true - scrape title from AKAs takes international title when lack preferred country title

@@ -75,6 +75,7 @@
private static final Logger logger = Logger.getLogger(ImdbPlugin.class);
private static final String LOG_MESSAGE = "ImdbPlugin: ";
protected String preferredCountry;

  • protected boolean prefCountryFallback;
    private String imdbPlot;
    protected WebBrowser webBrowser;
    protected boolean downloadFanart;
    @@ -136,6 +137,7 @@
    webBrowser = new WebBrowser();
 preferredCountry = PropertiesUtil.getProperty("imdb.preferredCountry", "USA");
  •    prefCountryFallback = PropertiesUtil.getBooleanProperty("imdb.aka.fallback.international", Boolean.FALSE);
     imdbPlot = PropertiesUtil.getProperty("imdb.plot", "short");
     downloadFanart = PropertiesUtil.getBooleanProperty("fanart.movie.download", Boolean.FALSE);
     fanartToken = PropertiesUtil.getProperty("mjb.scanner.fanartToken", ".fanart");
    
    @@ -1164,6 +1166,30 @@
    }
    }
    }
  •        if (foundValue==null && prefCountryFallback) {
    
  •            for (Map.Entry<String,String> aka : akas.entrySet()) {
    
  •                int startIndex = aka.getKey().indexOf("International");
    
  •                if (startIndex > -1) {
    
  •                    String extracted = aka.getKey().substring(startIndex);
    
  •                    int endIndex = extracted.indexOf("/");
    
  •                    if (endIndex > -1) {
    
  •                        extracted = extracted.substring(0, endIndex);
    
  •                    }
    
  •                    boolean valid = Boolean.TRUE;
    
  •                    for (String ignore : akaIgnoreVersions) {
    
  •                        if (StringUtils.isNotBlank(ignore) && StringUtils.containsIgnoreCase(extracted, ignore.trim())) {
    
  •                            valid = Boolean.FALSE;
    
  •                            break;
    
  •                        }
    
  •                    }
    
  •                    if (valid) {
    
  •                        foundValue = aka.getValue().trim();
    
  •                        break;
    
  •                    }
    
  •                }
    
  •            }
    
  •        }
         movie.setTitle(foundValue, IMDB_PLUGIN_ID);
     }
    
    }
@Omertron
Copy link
Member Author

Comment #1 originally posted by Omertron on 2013-02-27T08:28:47.000Z:

Better idea: fallback to list of languages, defined in new property "imdb.aka.scrape.fallback"
ie.:
imdb.preferredCountry=USA
imdb.aka.scrape.fallback=UK,International,(original title)
gives searching AKAs for USA -> UK -> International -> (original title)

@@ -75,6 +75,7 @@
private static final Logger logger = Logger.getLogger(ImdbPlugin.class);
private static final String LOG_MESSAGE = "ImdbPlugin: ";
protected String preferredCountry;

  • protected String prefCountryFallback;
    private String imdbPlot;
    protected WebBrowser webBrowser;
    protected boolean downloadFanart;
    @@ -136,6 +137,7 @@
    webBrowser = new WebBrowser();
 preferredCountry = PropertiesUtil.getProperty("imdb.preferredCountry", "USA");
  •    prefCountryFallback = PropertiesUtil.getProperty("imdb.aka.scrape.fallback", "");
     imdbPlot = PropertiesUtil.getProperty("imdb.plot", "short");
     downloadFanart = PropertiesUtil.getBooleanProperty("fanart.movie.download", Boolean.FALSE);
     fanartToken = PropertiesUtil.getProperty("mjb.scanner.fanartToken", ".fanart");
    

    @@ -1142,8 +1144,13 @@
    }

         String foundValue = null;
    
  •        String prefCountrys = preferredCountry;
    
  •        if (StringUtils.isNotBlank(prefCountryFallback)) {
    
  •            prefCountrys = prefCountrys + "," + prefCountryFallback;
    
  •        }
    
  •        for (String prefCountry : prefCountrys.split(",")) {
         for (Map.Entry<String,String> aka : akas.entrySet()) {
    
  •            int startIndex = aka.getKey().indexOf(preferredCountry);
    
  •                int startIndex = aka.getKey().indexOf(prefCountry);
             if (startIndex > -1) {
                 String extracted = aka.getKey().substring(startIndex);
                 int endIndex = extracted.indexOf("/");
    

    @@ -1164,6 +1171,8 @@
    }
    }
    }

  •            if (foundValue!=null) { break; }
    
  •        }
         movie.setTitle(foundValue, IMDB_PLUGIN_ID);
     }
    

    }

@Omertron
Copy link
Member Author

Comment #2 originally posted by Omertron on 2013-03-11T13:24:00.000Z:

This issue was closed by revision r3648.

@Omertron
Copy link
Member Author

Comment #3 originally posted by Omertron on 2013-03-11T13:27:22.000Z:

This issue was updated by revision r3649.

Updated wiki page for property configuration

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

No branches or pull requests

1 participant