gt:         if (StringUtils.isNotBlank(language)) {
context: /*
   *      Copyright (c) 2004-2016 Matthew Altman & Stuart Boston
   *
   *      This file is part of TheTVDB API.
   *
   *      TheTVDB API is free software: you can redistribute it and/or modify
   *      it under the terms of the GNU General Public License as published by
   *      the Free Software Foundation, either version 3 of the License, or
   *      any later version.
   *
   *      TheTVDB API is distributed in the hope that it will be useful,
   *      but WITHOUT ANY WARRANTY; without even the implied warranty of
   *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *      GNU General Public License for more details.
   *
   *      You should have received a copy of the GNU General Public License
   *      along with TheTVDB API.  If not, see <http://www.gnu.org/licenses/>.
   *
   */
  package com.omertron.thetvdbapi;
  
  import com.omertron.thetvdbapi.model.Actor;
  import com.omertron.thetvdbapi.model.Banners;
  import com.omertron.thetvdbapi.model.Episode;
  import com.omertron.thetvdbapi.model.Language;
  import com.omertron.thetvdbapi.model.Series;
  import com.omertron.thetvdbapi.model.TVDBUpdates;
  import com.omertron.thetvdbapi.tools.DOMHelper;
  import com.omertron.thetvdbapi.tools.TvdbParser;
  import java.io.UnsupportedEncodingException;
  import java.net.URLEncoder;
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  import java.util.Collections;
  import java.util.Date;
  import java.util.List;
  import org.apache.commons.lang3.StringUtils;
  import org.apache.commons.lang3.math.NumberUtils;
  import org.apache.http.client.HttpClient;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.yamj.api.common.http.SimpleHttpClientBuilder;
  
  /**
   * @author altman.matthew
   * @author stuart.boston
   */
  public class TheTVDBApi {
  
      private static final Logger LOG = LoggerFactory.getLogger(TheTVDBApi.class);
      private String apiKey = null;
      private HttpClient httpClient;
      private static final String BASE_URL = "http://thetvdb.com/api/";
      private static final String SERIES_URL = "/series/";
      private static final String ALL_URL = "/all/";
      private static final String WEEKLY_UPDATES_URL = "/updates/updates_week.xml";
      private static final String URL = "URL: {}";
  
      /**
       * Create an API object with the passed API Key
       *
       * @param apiKey Must be valid
       */
      public TheTVDBApi(String apiKey) {
          // No HttpClient passed, so use a default
          this(apiKey, new SimpleHttpClientBuilder().build());
      }
  
      /**
       * Create an API object with the passed API key and using the supplied
       * HttpClient
       *
       * @param apiKey Must not be null or empty
       * @param httpClient
       */
      public TheTVDBApi(String apiKey, HttpClient httpClient) {
          if (StringUtils.isBlank(apiKey)) {
              return;
          }
  
          this.apiKey = apiKey;
          this.httpClient = httpClient;
          DOMHelper.setHttpClient(this.httpClient);
      }
  
      /**
       * Get the series information
       *
       * @param id
       * @param language
       * @return
       * @throws com.omertron.thetvdbapi.TvDbException
       */
      public Series getSeries(String id, String language) throws TvDbException {
          StringBuilder urlBuilder = new StringBuilder();
          urlBuilder.append(BASE_URL)
                    .append(apiKey)
                    .append(SERIES_URL)
                    .append(id)
                    .append("/");
          if (StringUtils.isNotBlank(language)) {
              urlBuilder.append(language);
          }
  
          LOG.trace(URL, urlBuilder.toString());
          List<Series> seriesList = TvdbParser.getSeriesList(urlBuilder.toString());
          if (seriesList.isEmpty()) {
              return null;
          }
          return seriesList.get(0);
      }
  
      /**
       * Get all the episodes for a series. Note: This could be a lot of records
       *
       * @param id
       * @param language
       * @return
       * @throws com.omertron.thetvdbapi.TvDbException
       */
      public List<Episode> getAllEpisodes(String id, String language) throws TvDbException {
          List<Episode> episodeList = Collections.emptyList();
  
          if (isValidNumber(id)) {
              StringBuilder urlBuilder = new StringBuilder();
              urlBuilder.append(BASE_URL)
                        .append(apiKey)
                        .append(SERIES_URL)
                        .append(id)
                        .append(ALL_URL);
              if (StringUtils.isNotBlank(language)) {
                  urlBuilder.append(language);
              }
  
              LOG.trace(URL, urlBuilder.toString());
              episodeList = TvdbParser.getAllEpisodes(urlBuilder.toString(), -1);
          }
          return episodeList;
      }
  
      /**
       * Get all the episodes from a specific season for a series. Note: This
       * could be a lot of records
       *
       * @param id
       * @param season
       * @param language
       * @return
       * @throws com.omertron.thetvdbapi.TvDbException
       */
      public List<Episode> getSeasonEpisodes(String id, int season, String language) throws TvDbException {
          StringBuilder urlBuilder = new StringBuilder();
          urlBuilder.append(BASE_URL)
                    .append(apiKey)
                    .append(SERIES_URL)
                    .append(id)
                    .append(ALL_URL);
          if (StringUtils.isNotBlank(language)) {
              urlBuilder.append(language);
          }
  
          LOG.trace(URL, urlBuilder.toString());
          return TvdbParser.getAllEpisodes(urlBuilder.toString(), season);
      }
  
      /**
       * Get a specific episode's information
       *
       * @param seriesId
       * @param seasonNbr
       * @param episodeNbr
       * @param language
       * @return
       * @throws com.omertron.thetvdbapi.TvDbException
       */
      public Episode getEpisode(String seriesId, int seasonNbr, int episodeNbr, String language) throws TvDbException {
          return getTVEpisode(seriesId, seasonNbr, episodeNbr, language, "/default/");
      }
  
      /**
       * Get a specific DVD episode's information
       *
       * @param seriesId
       * @param seasonNbr
       * @param episodeNbr
       * @param language
       * @return
       * @throws com.omertron.thetvdbapi.TvDbException
       */
      public Episode getDVDEpisode(String seriesId, int seasonNbr, int episodeNbr, String language) throws TvDbException {
          return getTVEpisode(seriesId, seasonNbr, episodeNbr, language, "/dvd/");
      }
  
      /**
       * Generic function to get either the standard TV episode list or the DVD
       * list
       *
       * @param seriesId
       * @param seasonNbr
       * @param episodeNbr
       * @param language
       * @param episodeType
       * @return
       * @throws com.omertron.thetvdbapi.TvDbException
       */
      private Episode getTVEpisode(String seriesId, int seasonNbr, int episodeNbr, String language, String episodeType) throws TvDbException {
          if (!isValidNumber(seriesId) || !isValidNumber(seasonNbr) || !isValidNumber(episodeNbr)) {
              // Invalid number passed
              return new Episode();
          }
  
          StringBuilder urlBuilder = new StringBuilder();
          urlBuilder.append(BASE_URL)
                    .append(apiKey)
                    .append(SERIES_URL)
                    .append(seriesId)
                    .append(episodeType)
                    .append(seasonNbr)
                    .append("/")
                    .append(episodeNbr)
                    .append("/");
  