|
|
|
@ -423,24 +423,18 @@ public class TheMovieDb {
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException {
|
|
|
|
public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException {
|
|
|
|
URL returnUrl = null;
|
|
|
|
|
|
|
|
StringBuilder sb;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!tmdbConfig.isValidSize(requiredSize)) {
|
|
|
|
if (!tmdbConfig.isValidSize(requiredSize)) {
|
|
|
|
sb = new StringBuilder();
|
|
|
|
throw new MovieDbException(MovieDbExceptionType.INVALID_IMAGE, requiredSize);
|
|
|
|
sb.append(" - Invalid size requested: ").append(requiredSize);
|
|
|
|
|
|
|
|
LOGGER.warn(sb.toString());
|
|
|
|
|
|
|
|
return returnUrl;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
StringBuilder sb = new StringBuilder(tmdbConfig.getBaseUrl());
|
|
|
|
sb = new StringBuilder(tmdbConfig.getBaseUrl());
|
|
|
|
|
|
|
|
sb.append(requiredSize);
|
|
|
|
sb.append(requiredSize);
|
|
|
|
sb.append(imagePath);
|
|
|
|
sb.append(imagePath);
|
|
|
|
|
|
|
|
try {
|
|
|
|
return (new URL(sb.toString()));
|
|
|
|
return (new URL(sb.toString()));
|
|
|
|
} catch (MalformedURLException ex) {
|
|
|
|
} catch (MalformedURLException ex) {
|
|
|
|
LOGGER.warn("Failed to create image URL: " + ex.getMessage());
|
|
|
|
LOGGER.warn("Failed to create image URL: " + ex.getMessage());
|
|
|
|
throw new MovieDbException(MovieDbExceptionType.INVALID_URL, returnUrl.toString());
|
|
|
|
throw new MovieDbException(MovieDbExceptionType.INVALID_URL, sb.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|