From 4cb918af32e7a09f7e3e209976eaeb3318db01f1 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 7 Feb 2013 12:25:46 +0000 Subject: [PATCH] * added {i} model index and {di} model duplicate index bindings --- .../filebot/cli/CmdlineOperations.java | 2 +- .../filebot/format/MediaBindingBean.java | 32 +++++++++++++++++-- .../filebot/media/ReleaseInfo.properties | 2 +- .../ui/rename/AudioFingerprintMatcher.java | 2 +- .../filebot/ui/rename/EpisodeListMatcher.java | 4 ++- .../sourceforge/filebot/web/AudioTrack.java | 20 ++++++++++++ 6 files changed, 55 insertions(+), 7 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/CmdlineOperations.java b/source/net/sourceforge/filebot/cli/CmdlineOperations.java index 5dbba53f..2e086095 100644 --- a/source/net/sourceforge/filebot/cli/CmdlineOperations.java +++ b/source/net/sourceforge/filebot/cli/CmdlineOperations.java @@ -514,7 +514,7 @@ public class CmdlineOperations implements CmdlineInterface { List> matches = new ArrayList>(); for (Entry it : service.lookup(audioFiles).entrySet()) { if (it.getKey() != null && it.getValue() != null) { - matches.add(new Match(it.getKey(), it.getValue())); + matches.add(new Match(it.getKey(), it.getValue().clone())); } } diff --git a/source/net/sourceforge/filebot/format/MediaBindingBean.java b/source/net/sourceforge/filebot/format/MediaBindingBean.java index 7db7d0bd..4e0b0741 100644 --- a/source/net/sourceforge/filebot/format/MediaBindingBean.java +++ b/source/net/sourceforge/filebot/format/MediaBindingBean.java @@ -17,6 +17,7 @@ import static net.sourceforge.tuned.StringUtilities.*; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; @@ -632,9 +633,22 @@ public class MediaBindingBean { } - @Define("index") - public Integer getIndex() { - return new ArrayList(getContext().keySet()).indexOf(getMediaFile()) + 1; + @Define("i") + public Integer getModelIndex() { + return identityIndexOf(getContext().values(), getInfoObject()); + } + + + @Define("di") + public Integer getDuplicateIndex() { + List duplicates = new ArrayList(); + for (Object it : getContext().values()) { + if (getInfoObject().equals(it)) { + duplicates.add(it); + } + } + int di = identityIndexOf(duplicates, getInfoObject()); + return di == 0 ? null : di; } @@ -718,6 +732,18 @@ public class MediaBindingBean { } + private Integer identityIndexOf(Iterable c, Object o) { + Iterator itr = c.iterator(); + for (int i = 0; itr.hasNext(); i++) { + Object next = itr.next(); + System.out.println(String.format("%s VS %s", System.identityHashCode(o), System.identityHashCode(next))); + if (o == next) + return i; + } + return null; + } + + private String getMediaInfo(StreamKind streamKind, int streamNumber, String... keys) { for (String key : keys) { String value = getMediaInfo().get(streamKind, streamNumber, key); diff --git a/source/net/sourceforge/filebot/media/ReleaseInfo.properties b/source/net/sourceforge/filebot/media/ReleaseInfo.properties index d611f942..3f4b5a29 100644 --- a/source/net/sourceforge/filebot/media/ReleaseInfo.properties +++ b/source/net/sourceforge/filebot/media/ReleaseInfo.properties @@ -1,5 +1,5 @@ # source names mostly copied from [http://en.wikipedia.org/wiki/Pirated_movie_release_types] -pattern.video.source: CAMRip|CAM|PDVD|TS|TELESYNC|PDVD|PPV|PPVRip|Screener|SCR|SCREENER|DVDSCR|DVDSCREENER|BDSCR|R4|R5|R5LINE|R5.LINE|DVD|DVDRip|DVDR|TVRip|DSR|PDTV|HDTV|DVB|DVBRip|DTHRip|VODRip|VODR|BDRip|BRRip|BluRay|BDR|BR-Scr|BR-Screener|HDDVD|HDRip|WorkPrint|VHS|VCD|TELECINE|WEB-DL|WEBRip|ithd|iTunesHD +pattern.video.source: CAMRip|CAM|PDVD|TS|TELESYNC|PDVD|PPV|PPVRip|Screener|SCR|SCREENER|DVDSCR|DVDSCREENER|BDSCR|R4|R5|R5LINE|R5.LINE|DVD|DVDRip|DVDR|TVRip|DSR|PDTV|SDTV|HDTV|DVB|DVBRip|DTHRip|VODRip|VODR|BDRip|BRRip|BluRay|BDR|BR-Scr|BR-Screener|HDDVD|HDRip|WorkPrint|VHS|VCD|TELECINE|WEB-DL|WEBRip|ithd|iTunesHD # additional release info patterns pattern.video.format: DivX|Xvid|AVC|x264|h264|3ivx|mpeg|mpeg4|mp3|aac|ac3|dd20|dd51|2ch|6ch|DTS|WS|HR|7p|720p|18p|1080p|NTSC diff --git a/source/net/sourceforge/filebot/ui/rename/AudioFingerprintMatcher.java b/source/net/sourceforge/filebot/ui/rename/AudioFingerprintMatcher.java index e711ebd1..fad4ac14 100644 --- a/source/net/sourceforge/filebot/ui/rename/AudioFingerprintMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/AudioFingerprintMatcher.java @@ -35,7 +35,7 @@ class AudioFingerprintMatcher implements AutoCompleteMatcher { // check audio files against acoustid for (Entry it : service.lookup(filter(files, AUDIO_FILES)).entrySet()) { if (it.getKey().exists() && it.getValue() != null) { - matches.add(new Match(it.getKey(), it.getValue())); + matches.add(new Match(it.getKey(), it.getValue().clone())); } } diff --git a/source/net/sourceforge/filebot/ui/rename/EpisodeListMatcher.java b/source/net/sourceforge/filebot/ui/rename/EpisodeListMatcher.java index 7a1cc33f..1b1e40c8 100644 --- a/source/net/sourceforge/filebot/ui/rename/EpisodeListMatcher.java +++ b/source/net/sourceforge/filebot/ui/rename/EpisodeListMatcher.java @@ -321,7 +321,9 @@ class EpisodeListMatcher implements AutoCompleteMatcher { // group by subtitles first and then by files in general for (List filesPerType : mapByExtension(files).values()) { EpisodeMatcher matcher = new EpisodeMatcher(filesPerType, episodes, false); - matches.addAll(matcher.match()); + for (Match it : matcher.match()) { + matches.add(new Match(it.getValue(), ((Episode) it.getCandidate()).clone())); + } } return matches; diff --git a/source/net/sourceforge/filebot/web/AudioTrack.java b/source/net/sourceforge/filebot/web/AudioTrack.java index abb242b4..4e33f52d 100644 --- a/source/net/sourceforge/filebot/web/AudioTrack.java +++ b/source/net/sourceforge/filebot/web/AudioTrack.java @@ -24,6 +24,20 @@ public class AudioTrack implements Serializable { } + public AudioTrack(AudioTrack other) { + this.artist = other.artist; + this.title = other.title; + this.album = other.album; + this.albumArtist = other.albumArtist; + this.trackTitle = other.trackTitle; + this.albumReleaseDate = other.albumReleaseDate; + this.mediumIndex = other.mediumIndex; + this.mediumCount = other.mediumCount; + this.trackIndex = other.trackIndex; + this.trackCount = other.trackCount; + } + + public AudioTrack(String artist, String title, String album) { this.artist = artist; this.title = title; @@ -95,6 +109,12 @@ public class AudioTrack implements Serializable { } + @Override + public AudioTrack clone() { + return new AudioTrack(this); + } + + @Override public String toString() { return String.format("%s - %s", getArtist(), getTitle());