Mention status code in failed state
[rhynodge.git] / src / main / java / net / pterodactylus / rhynodge / states / EpisodeState.java
index 7ed3dce..78ca478 100644 (file)
@@ -65,6 +65,11 @@ public class EpisodeState extends AbstractState implements Iterable<Episode> {
        // ACCESSORS
        //
 
+       @Override
+       public boolean isEmpty() {
+               return episodes.isEmpty();
+       }
+
        /**
         * Returns all episodes contained in this state.
         *
@@ -106,7 +111,7 @@ public class EpisodeState extends AbstractState implements Iterable<Episode> {
 
                        @Override
                        public Integer apply(Episode episode) {
-                               return episode.season();
+                               return (episode != null ) ? episode.season() : -1;
                        }
                };
 
@@ -194,7 +199,9 @@ public class EpisodeState extends AbstractState implements Iterable<Episode> {
                 *            The torrent file to add
                 */
                public void addTorrentFile(TorrentFile torrentFile) {
-                       torrentFiles.add(torrentFile);
+                       if (!torrentFiles.contains(torrentFile)) {
+                               torrentFiles.add(torrentFile);
+                       }
                }
 
                //