* added {i} model index and {di} model duplicate index bindings

This commit is contained in:
Reinhard Pointner 2013-02-07 12:25:46 +00:00
parent 44bd948156
commit 4cb918af32
6 changed files with 55 additions and 7 deletions

View File

@ -514,7 +514,7 @@ public class CmdlineOperations implements CmdlineInterface {
List<Match<File, ?>> matches = new ArrayList<Match<File, ?>>();
for (Entry<File, AudioTrack> it : service.lookup(audioFiles).entrySet()) {
if (it.getKey() != null && it.getValue() != null) {
matches.add(new Match<File, AudioTrack>(it.getKey(), it.getValue()));
matches.add(new Match<File, AudioTrack>(it.getKey(), it.getValue().clone()));
}
}

View File

@ -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<File>(getContext().keySet()).indexOf(getMediaFile()) + 1;
@Define("i")
public Integer getModelIndex() {
return identityIndexOf(getContext().values(), getInfoObject());
}
@Define("di")
public Integer getDuplicateIndex() {
List<Object> duplicates = new ArrayList<Object>();
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);

View File

@ -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

View File

@ -35,7 +35,7 @@ class AudioFingerprintMatcher implements AutoCompleteMatcher {
// check audio files against acoustid
for (Entry<File, AudioTrack> it : service.lookup(filter(files, AUDIO_FILES)).entrySet()) {
if (it.getKey().exists() && it.getValue() != null) {
matches.add(new Match<File, AudioTrack>(it.getKey(), it.getValue()));
matches.add(new Match<File, AudioTrack>(it.getKey(), it.getValue().clone()));
}
}

View File

@ -321,7 +321,9 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
// group by subtitles first and then by files in general
for (List<File> filesPerType : mapByExtension(files).values()) {
EpisodeMatcher matcher = new EpisodeMatcher(filesPerType, episodes, false);
matches.addAll(matcher.match());
for (Match<File, Object> it : matcher.match()) {
matches.add(new Match<File, Episode>(it.getValue(), ((Episode) it.getCandidate()).clone()));
}
}
return matches;

View File

@ -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());