@Override public HashMapWrapper checkAndDownloadEpisodes(ArrayList<ConfSeries> seriesList) { HashMap<ConfSeries, ArrayListWrapper> seriesMap = new HashMap<>(); ArrayList<String> fileNames = null; for (ConfSeries confSeries : seriesList) { fileNames = new ArrayList<>(); Series downloadSeries = this.getSeriesImdbID(confSeries.getTitle()); Integer newLastWatched = 0; this.mergeSeries(confSeries, downloadSeries); downloadSeries = this.getSeriesDownloads(downloadSeries); String fileName = null; Integer lastWatched = Integer.parseInt(confSeries.getLastWatched()); for (int i = 0; i < downloadSeries.getEpisodes().size(); i++) { Episode episode = downloadSeries.getEpisodes().get(i); String preferredQuality = confSeries.getPreferredQuality(); if (i + 1 > lastWatched) { switch (preferredQuality) { case "480p": fileName = this.startDownload(episode.getTorrents().getTorrent_480p()); break; case "720p": fileName = this.startDownload(episode.getTorrents().getTorrent_720p()); break; default: fileName = this.startDownload(episode.getTorrents().getTorrent_0()); break; } fileNames.add(fileName); newLastWatched = i + 1; } else { newLastWatched = lastWatched; } } confSeries.setLastWatched(newLastWatched.toString()); seriesMap.put(confSeries, new ArrayListWrapper(fileNames)); } return new HashMapWrapper(seriesMap); }
public void mergeSeries(ConfSeries confSeries, Series downloadSeries) { downloadSeries.setPreferredQuality(confSeries.getPreferredQuality()); downloadSeries.setLastWatched(confSeries.getLastWatched()); downloadSeries.setSubsLanguage(confSeries.getSubsLanguage()); }