public ArrayList<Media> formatListForPopcorn(ArrayList<Media> existingList) { for (LinkedTreeMap<String, Object> item : showsList) { Show show = new Show(sMediaProvider, sSubsProvider); show.title = (String) item.get("title"); show.videoId = (String) item.get("imdb_id"); show.seasons = (Integer) item.get("seasons"); show.tvdbId = (String) item.get("tvdb_id"); show.year = (String) item.get("year"); LinkedTreeMap<String, String> images = (LinkedTreeMap<String, String>) item.get("images"); show.image = images.get("poster").replace("/original/", "/medium/"); show.headerImage = images.get("fanart").replace("/original/", "/medium/"); existingList.add(show); } return existingList; }
public ArrayList<Media> formatDetailForPopcorn() { ArrayList<Media> list = new ArrayList<>(); try { Show show = new Show(sMediaProvider, sSubsProvider); show.title = (String) showData.get("title"); show.videoId = (String) showData.get("imdb_id"); show.imdbId = (String) showData.get("imdb_id"); show.tvdbId = (String) showData.get("tvdb_id"); show.seasons = ((Double) showData.get("num_seasons")).intValue(); show.year = (String) showData.get("year"); LinkedTreeMap<String, String> images = (LinkedTreeMap<String, String>) showData.get("images"); show.image = images.get("poster").replace("/original/", "/medium/"); show.fullImage = images.get("poster"); show.headerImage = images.get("fanart").replace("/original/", "/medium/"); if (showData.get("status") != null) { String status = (String) showData.get("status"); if (status.equalsIgnoreCase("ended")) { show.status = Show.Status.ENDED; } else if (status.equalsIgnoreCase("returning series")) { show.status = Show.Status.CONTINUING; } else if (status.equalsIgnoreCase("in production")) { show.status = Show.Status.CONTINUING; } else if (status.equalsIgnoreCase("canceled")) { show.status = Show.Status.CANCELED; } } show.country = (String) showData.get("country"); show.network = (String) showData.get("network"); show.synopsis = (String) showData.get("synopsis"); show.runtime = (String) showData.get("runtime"); show.airDay = (String) showData.get("air_day"); show.airTime = (String) showData.get("air_time"); show.genre = ((ArrayList<String>) showData.get("genres")).get(0); show.rating = Double.toString( ((LinkedTreeMap<String, Double>) showData.get("rating")).get("percentage") / 10); ArrayList<LinkedTreeMap<String, Object>> episodes = (ArrayList<LinkedTreeMap<String, Object>>) showData.get("episodes"); for (LinkedTreeMap<String, Object> episode : episodes) { try { Episode episodeObject = new Episode(sMediaProvider, sSubsProvider, sMetaProvider); LinkedTreeMap<String, LinkedTreeMap<String, Object>> torrents = (LinkedTreeMap<String, LinkedTreeMap<String, Object>>) episode.get("torrents"); for (String key : torrents.keySet()) { if (!key.equals("0")) { LinkedTreeMap<String, Object> item = torrents.get(key); Media.Torrent torrent = new Media.Torrent(); torrent.url = item.get("url").toString(); torrent.seeds = ((Double) item.get("seeds")).intValue(); torrent.peers = ((Double) item.get("peers")).intValue(); episodeObject.torrents.put(key, torrent); } } episodeObject.showName = show.title; episodeObject.dateBased = (Boolean) episode.get("date_based"); episodeObject.aired = ((Double) episode.get("first_aired")).intValue(); episodeObject.title = (String) episode.get("title"); episodeObject.overview = (String) episode.get("overview"); episodeObject.season = ((Double) episode.get("season")).intValue(); episodeObject.episode = ((Double) episode.get("episode")).intValue(); episodeObject.videoId = show.videoId + episodeObject.season + episodeObject.episode; episodeObject.imdbId = show.imdbId; episodeObject.image = episodeObject.fullImage = episodeObject.headerImage = show.headerImage; show.episodes.add(episodeObject); } catch (Exception e) { e.printStackTrace(); } } list.add(show); } catch (Exception e) { e.printStackTrace(); } return list; }