From 83b0f999d9236efa65b75b779e5a12f66c818bbe Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 5 Apr 2016 18:05:47 +0000 Subject: [PATCH] Add database property to AudioTrack object --- source/net/filebot/web/AcoustIDClient.java | 2 +- source/net/filebot/web/AudioTrack.java | 13 +++++++++++-- source/net/filebot/web/AudioTrackFormat.java | 5 +---- source/net/filebot/web/ID3Lookup.java | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/source/net/filebot/web/AcoustIDClient.java b/source/net/filebot/web/AcoustIDClient.java index 95dc4848..950d6fa9 100644 --- a/source/net/filebot/web/AcoustIDClient.java +++ b/source/net/filebot/web/AcoustIDClient.java @@ -120,7 +120,7 @@ public class AcoustIDClient implements MusicIdentificationService { if (artist == null || title == null || releaseGroup.isEmpty()) return null; - AudioTrack audioTrack = new AudioTrack(artist, title, null); + AudioTrack audioTrack = new AudioTrack(artist, title, null, getIdentifier()); audioTrack.mbid = getString(result, "id"); String type = getString(releaseGroup, "type"); diff --git a/source/net/filebot/web/AudioTrack.java b/source/net/filebot/web/AudioTrack.java index 604f2d11..80e177be 100644 --- a/source/net/filebot/web/AudioTrack.java +++ b/source/net/filebot/web/AudioTrack.java @@ -4,6 +4,8 @@ import java.io.Serializable; public class AudioTrack implements Serializable { + protected String database; + protected String artist; protected String title; protected String album; @@ -33,15 +35,17 @@ public class AudioTrack implements Serializable { this.trackIndex = other.trackIndex; this.trackCount = other.trackCount; this.mbid = other.mbid; + this.database = other.database; } - public AudioTrack(String artist, String title, String album) { + public AudioTrack(String artist, String title, String album, String database) { this.artist = artist; this.title = title; this.album = album; + this.database = database; } - public AudioTrack(String artist, String title, String album, String albumArtist, String trackTitle, SimpleDate albumReleaseDate, Integer mediumIndex, Integer mediumCount, Integer trackIndex, Integer trackCount, String mbid) { + public AudioTrack(String artist, String title, String album, String albumArtist, String trackTitle, SimpleDate albumReleaseDate, Integer mediumIndex, Integer mediumCount, Integer trackIndex, Integer trackCount, String mbid, String database) { this.artist = artist; this.title = title; this.album = album; @@ -53,6 +57,7 @@ public class AudioTrack implements Serializable { this.trackIndex = trackIndex; this.trackCount = trackCount; this.mbid = mbid; + this.database = database; } public String getArtist() { @@ -99,6 +104,10 @@ public class AudioTrack implements Serializable { return mbid; } + public String getDatabase() { + return database; + } + @Override public AudioTrack clone() { return new AudioTrack(this); diff --git a/source/net/filebot/web/AudioTrackFormat.java b/source/net/filebot/web/AudioTrackFormat.java index 83d62410..230cfaf0 100644 --- a/source/net/filebot/web/AudioTrackFormat.java +++ b/source/net/filebot/web/AudioTrackFormat.java @@ -1,12 +1,10 @@ package net.filebot.web; - import java.text.FieldPosition; import java.text.Format; import java.text.ParsePosition; - public class AudioTrackFormat extends Format { @Override @@ -14,13 +12,12 @@ public class AudioTrackFormat extends Format { return sb.append(obj.toString()); } - @Override public AudioTrack parseObject(String source, ParsePosition pos) { String[] s = source.split(" - ", 2); if (s.length == 2) { pos.setIndex(source.length()); - return new AudioTrack(s[0].trim(), s[1].trim(), "VA"); + return new AudioTrack(s[0].trim(), s[1].trim(), "VA", null); } else { pos.setErrorIndex(0); return null; diff --git a/source/net/filebot/web/ID3Lookup.java b/source/net/filebot/web/ID3Lookup.java index c31c5734..98626176 100644 --- a/source/net/filebot/web/ID3Lookup.java +++ b/source/net/filebot/web/ID3Lookup.java @@ -70,7 +70,7 @@ public class ID3Lookup implements MusicIdentificationService { } } - info.put(f, new AudioTrack(artist, title, album, albumArtist, trackTitle, albumReleaseDate, mediumIndex, mediumCount, trackIndex, trackCount, mbid)); + info.put(f, new AudioTrack(artist, title, album, albumArtist, trackTitle, albumReleaseDate, mediumIndex, mediumCount, trackIndex, trackCount, mbid, getIdentifier())); } } catch (Throwable e) { debug.warning(e.getMessage());