com.moviejukebox.plugin.poster.SubBabaPosterPlugin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yamj Show documentation
Show all versions of yamj Show documentation
Static analysis of MovieJukebox project
/*
* 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.Image;
import com.moviejukebox.model.Movie;
import com.moviejukebox.scanner.artwork.PosterScanner;
import com.moviejukebox.tools.WebBrowser;
import java.awt.Dimension;
import java.io.IOException;
import java.net.URLEncoder;
import org.apache.log4j.Logger;
public class SubBabaPosterPlugin extends AbstractMoviePosterPlugin implements ITvShowPosterPlugin {
private static final Logger logger = Logger.getLogger(SubBabaPosterPlugin.class);
private WebBrowser webBrowser;
public SubBabaPosterPlugin() {
super();
// Check to see if we are needed
if (!isNeeded()) {
return;
}
webBrowser = new WebBrowser();
}
/**
* retrieve the sub-baba.com poster url matching the specified movie name.
*/
@Override
public String getIdFromMovieInfo(String title, String year) {
String response = Movie.UNKNOWN;
try {
// String searchURL = "http://www.sub-baba.com/search?page=search&type=all&submit=%E7%F4%F9&search=" + URLEncoder.encode(title, "iso-8859-8");
StringBuilder searchURL = new StringBuilder("http://www.sub-baba.com/search/query/");
searchURL.append(URLEncoder.encode(title, "iso-8859-8"));
searchURL.append("/type/1/");
String xml = webBrowser.request(searchURL.toString());
String posterID = Movie.UNKNOWN;
int index = 0;
int endIndex = 0;
while (true) {
index = xml.indexOf("", index);
if (index == -1) {
break;
}
index += 16;
endIndex = xml.indexOf("", index);
if (endIndex == -1) {
break;
}
String scanName = new String(xml.substring(index, endIndex)).trim();
index = endIndex + 11;
if (scanName.equalsIgnoreCase(title)) {
posterID = scanPosterID;
// We have a correct ID, so quit
break;
}
}
if (!Movie.UNKNOWN.equals(posterID)) {
response = posterID;
}
} catch (Exception error) {
logger.error("SubBabaPosterPlugin: Failed retreiving SubBaba Id for movie : " + title);
logger.error("SubBabaPosterPlugin: Error : " + error.getMessage());
}
return response;
}
@Override
public IImage getPosterUrl(String id) {
if (!Movie.UNKNOWN.equals(id)) {
Image posterImage = new Image();
// This is the page that contains the poster URL
StringBuilder posterUrl = new StringBuilder("http://www.sub-baba.com/download/");
posterUrl.append(id).append("/2");
// Load the poster page and extract the image filename
try {
String xml = webBrowser.request(posterUrl.toString());
int startIndex = xml.indexOf(" imageDimension.getHeight()) {
logger.debug("SubBabaPosterPlugin: Detected DVD Cover, cropping image to poster size.");
posterImage.setSubimage("0, 0, 47, 100");
}
return posterImage;
}
return Image.UNKNOWN;
}
@Override
public IImage getPosterUrl(String title, String year) {
return getPosterUrl(getIdFromMovieInfo(title, year));
}
public String getIdFromMovieInfo(String title, String year, int tvSeason) {
return getIdFromMovieInfo(title, year);
}
public IImage getPosterUrl(String title, String year, int tvSeason) {
return getPosterUrl(title, year);
}
public IImage getPosterUrl(String id, int season) {
return getPosterUrl(id);
}
@Override
public String getName() {
return "subbaba";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy