Example #1
0
  public boolean showAddNew(
      String tvdbid,
      Language language,
      Boolean seasonFolders,
      Status status,
      EnumSet<Show.Quality> initial,
      EnumSet<Quality> archive)
      throws Exception {
    StringBuilder builder = new StringBuilder("show.addnew");
    builder.append("&tvdbid=");
    builder.append(tvdbid);
    if (language != null) {
      builder.append("&lang=");
      builder.append(language.getAbbrev());
    }
    if (seasonFolders != null) {
      // the option isnt called season folders anymore
      if (apiVersion >= 3) {
        builder.append("&flatten_folders=");
      } else {
        builder.append("&season_folder=");
      }
      // if you pass me a boolean you better damn well have checked the version number
      builder.append(seasonFolders ? "1" : "0");
    }
    if (status != null) {
      builder.append("&status=");
      builder.append(status.toJson());
    }
    if (initial != null) {
      builder.append("&initial=");
      Iterator<Quality> iter = initial.iterator();
      if (iter.hasNext()) {
        builder.append(iter.next().toString().toLowerCase());
        while (iter.hasNext()) {
          builder.append("|");
          builder.append(iter.next().toString().toLowerCase());
        }
      }
    }
    if (archive != null) {
      builder.append("&archive=");
      Iterator<Show.Quality> iter = archive.iterator();
      if (iter.hasNext()) {
        builder.append(iter.next().toString().toLowerCase());
        while (iter.hasNext()) {
          builder.append("|");
          builder.append(iter.next().toString().toLowerCase());
        }
      }
    }

    return this.<Object>commandSuccessful(
        builder.toString(), new TypeToken<JsonResponse<Object>>() {}.getType());
  }
Example #2
0
 public SearchResults sbSearchTvDb(String query, Language language) throws Exception {
   StringBuilder builder = new StringBuilder("sb.searchtvdb");
   builder.append("&name=");
   builder.append(query);
   if (language != null) {
     builder.append("&lang=");
     builder.append(language.getAbbrev());
   }
   // having to use all these generics is kind of annoying
   TvDbResultsJson results =
       this.<TvDbResultsJson>commandData(
           builder.toString(), new TypeToken<JsonResponse<TvDbResultsJson>>() {}.getType());
   SearchResults ret = new SearchResults();
   for (TvDbResultJson json : results.results) { // lol results of results :)
     ret.results.add(new SearchResultTvDb(json));
   }
   return ret;
 }