/**
     * Format data for the application
     *
     * @param existingList List to be extended
     * @return List with items
     */
    public ArrayList<Media> formatForPopcorn(ArrayList<Media> existingList) {
      ArrayList<LinkedTreeMap<String, Object>> movies = new ArrayList<>();
      if (data != null) {
        movies = (ArrayList<LinkedTreeMap<String, Object>>) data.get("movies");
      }

      for (LinkedTreeMap<String, Object> item : movies) {
        Movie movie = new Movie(sMediaProvider, sSubsProvider);

        Double id = (Double) item.get("id");
        movie.videoId = Integer.toString(id.intValue());
        movie.imdbId = (String) item.get("imdb_code");

        int existingItem = isInResults(existingList, movie.videoId);
        if (existingItem == -1) {
          movie.title = (String) item.get("title");
          Double year = (Double) item.get("year");
          movie.year = Integer.toString(year.intValue());
          movie.rating = item.get("rating").toString();
          movie.genre = ((ArrayList<String>) item.get("genres")).get(0);
          movie.image = (String) item.get("medium_cover_image");

          if (movie.image != null) {
            movie.image = movie.image.replace("medium-cover", "large-cover");
          }

          ArrayList<LinkedTreeMap<String, Object>> torrents =
              (ArrayList<LinkedTreeMap<String, Object>>) item.get("torrents");
          if (torrents != null) {
            for (LinkedTreeMap<String, Object> torrentObj : torrents) {
              String quality = (String) torrentObj.get("quality");
              if (quality == null || quality.equals("3D")) continue;

              Media.Torrent torrent = new Media.Torrent();

              torrent.seeds = ((Double) torrentObj.get("seeds")).intValue();
              torrent.peers = ((Double) torrentObj.get("peers")).intValue();
              torrent.hash = (String) torrentObj.get("hash");
              try {
                torrent.url =
                    "magnet:?xt=urn:btih:"
                        + torrent.hash
                        + "&amp;dn="
                        + URLEncoder.encode(item.get("title_long").toString(), "utf-8")
                        + "&amp;tr=http://exodus.desync.com:6969/announce&amp;tr=udp://tracker.openbittorrent.com:80/announce&amp;tr=udp://open.demonii.com:1337/announce&amp;tr=udp://exodus.desync.com:6969/announce&amp;tr=udp://tracker.yify-torrents.com/announce";
              } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
                torrent.url = (String) torrentObj.get("url");
              }

              movie.torrents.put(quality, torrent);
            }
          }

          existingList.add(movie);
        }
      }
      return existingList;
    }
    /**
     * Format data for the application
     *
     * @return List with items
     */
    public Movie formatDetailForPopcorn() {
      Movie movie = new Movie(sMediaProvider, sSubsProvider);
      LinkedTreeMap<String, Object> movieObj = data;
      if (movieObj == null) return movie;

      Double id = (Double) movieObj.get("id");
      movie.videoId = Integer.toString(id.intValue());
      movie.imdbId = (String) movieObj.get("imdb_code");

      movie.title = (String) movieObj.get("title");
      Double year = (Double) movieObj.get("year");
      movie.year = Integer.toString(year.intValue());
      movie.rating = movieObj.get("rating").toString();
      movie.genre = ((ArrayList<String>) movieObj.get("genres")).get(0);

      ArrayList<LinkedTreeMap<String, Object>> torrents =
          (ArrayList<LinkedTreeMap<String, Object>>) movieObj.get("torrents");
      if (torrents != null) {
        for (LinkedTreeMap<String, Object> torrentObj : torrents) {
          String quality = (String) torrentObj.get("quality");
          if (quality == null) continue;

          Media.Torrent torrent = new Media.Torrent();

          torrent.seeds = ((Double) torrentObj.get("seeds")).intValue();
          torrent.peers = ((Double) torrentObj.get("peers")).intValue();
          torrent.hash = (String) torrentObj.get("hash");
          try {
            String magnet =
                "magnet:?xt=urn:btih:"
                    + torrent.hash
                    + "&amp;dn="
                    + URLEncoder.encode(movieObj.get("title_long").toString(), "utf-8")
                    + "&amp;tr=http://exodus.desync.com:6969/announce&amp;tr=udp://tracker.openbittorrent.com:80/announce&amp;tr=udp://open.demonii.com:1337/announce&amp;tr=udp://exodus.desync.com:6969/announce&amp;tr=udp://tracker.yify-torrents.com/announce";
            torrent.url = magnet;
          } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            torrent.url = (String) torrentObj.get("url");
          }

          movie.torrents.put(quality, torrent);
        }
      }

      return movie;
    }