All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.moviejukebox.plugin.poster.FilmAffinityPosterPlugin Maven / Gradle / Ivy

There is a newer version: 2.9
Show newest version
/*
 *      Copyright (c) 2004-2012 YAMJ Members
 *      http://code.google.com/p/moviejukebox/people/list 
 *  
 *      Web: http://code.google.com/p/moviejukebox/
 *  
 *      This software is licensed under a Creative Commons License
 *      See this page: http://code.google.com/p/moviejukebox/wiki/License
 *  
 *      For any reuse or distribution, you must make clear to others the 
 *      license terms of this work.  
 */
package com.moviejukebox.plugin.poster;

import com.moviejukebox.model.IImage;
import com.moviejukebox.model.IMovieBasicInformation;
import com.moviejukebox.model.Identifiable;
import com.moviejukebox.model.Movie;
import com.moviejukebox.model.Image;
import com.moviejukebox.plugin.FilmAffinityInfo;
import com.moviejukebox.tools.HTMLTools;
import com.moviejukebox.tools.WebBrowser;
import org.apache.log4j.Logger;

public class FilmAffinityPosterPlugin extends AbstractMoviePosterPlugin implements ITvShowPosterPlugin {
    private WebBrowser webBrowser;
    private FilmAffinityInfo filmAffinityInfo;
    private static final Logger logger = Logger.getLogger(FilmAffinityPosterPlugin.class);

    public FilmAffinityPosterPlugin() {
        super();
        
        // Check to see if we are needed        
        /*if (!isNeeded()) {
            return;
        }*/
        
        webBrowser = new WebBrowser();
        filmAffinityInfo = new FilmAffinityInfo();
    }

    @Override
    public String getIdFromMovieInfo(String title, String year) {
        return filmAffinityInfo.getIdFromMovieInfo(title, year);
    }

    public String getIdFromMovieInfo(String title, String year, int tvSeason) {
        return filmAffinityInfo.getIdFromMovieInfo(title, year, tvSeason);
    }

    @Override
    public IImage getPosterUrl(String id) {
        String posterURL = Movie.UNKNOWN;
        if (!Movie.UNKNOWN.equals(id)) {
            try {
                StringBuilder sb = new StringBuilder("http://www.filmaffinity.com/es/");
                sb.append(id);

                String xml = webBrowser.request(sb.toString());
                posterURL = HTMLTools.extractTag(xml, "




© 2015 - 2024 Weber Informatics LLC | Privacy Policy