From ab94a167051c2c84bd806cbd47f4dfd3c2522627 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 21 Dec 2017 10:17:13 +0100 Subject: [PATCH] Make ID3 genre value available via {genre} binding (works only if ID3 Lookup is used) --- source/net/filebot/format/MediaBindingBean.java | 2 ++ source/net/filebot/web/AudioTrack.java | 9 ++++++++- source/net/filebot/web/ID3Lookup.java | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index c938d4b9..eb84492d 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -630,6 +630,8 @@ public class MediaBindingBean { return getMovieInfo().getGenres(); if (infoObject instanceof Episode) return getSeriesInfo().getGenres(); + if (infoObject instanceof AudioTrack) + return Stream.of(getMusic().getGenre()).filter(Objects::nonNull).collect(toList()); return null; } diff --git a/source/net/filebot/web/AudioTrack.java b/source/net/filebot/web/AudioTrack.java index ea36bcdb..8f3b8ad2 100644 --- a/source/net/filebot/web/AudioTrack.java +++ b/source/net/filebot/web/AudioTrack.java @@ -12,6 +12,7 @@ public class AudioTrack implements Serializable { protected String albumArtist; protected String trackTitle; + protected String genre; protected SimpleDate albumReleaseDate; protected Integer mediumIndex; protected Integer mediumCount; @@ -30,6 +31,7 @@ public class AudioTrack implements Serializable { this.album = other.album; this.albumArtist = other.albumArtist; this.trackTitle = other.trackTitle; + this.genre = other.genre; this.albumReleaseDate = other.albumReleaseDate; this.mediumIndex = other.mediumIndex; this.mediumCount = other.mediumCount; @@ -46,12 +48,13 @@ public class AudioTrack implements Serializable { 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, String database) { + public AudioTrack(String artist, String title, String album, String albumArtist, String trackTitle, String genre, SimpleDate albumReleaseDate, Integer mediumIndex, Integer mediumCount, Integer trackIndex, Integer trackCount, String mbid, String database) { this.artist = artist; this.title = title; this.album = album; this.albumArtist = albumArtist; this.trackTitle = trackTitle; + this.genre = genre; this.albumReleaseDate = albumReleaseDate; this.mediumIndex = mediumIndex; this.mediumCount = mediumCount; @@ -81,6 +84,10 @@ public class AudioTrack implements Serializable { return trackTitle; } + public String getGenre() { + return genre; + } + public SimpleDate getAlbumReleaseDate() { return albumReleaseDate; } diff --git a/source/net/filebot/web/ID3Lookup.java b/source/net/filebot/web/ID3Lookup.java index 09c87557..cdcb67b3 100644 --- a/source/net/filebot/web/ID3Lookup.java +++ b/source/net/filebot/web/ID3Lookup.java @@ -95,6 +95,7 @@ public class ID3Lookup implements MusicIdentificationService { String album = getString(m, "Album"); String albumArtist = getString(m, "Album/Performer"); String trackTitle = getString(m, "Track"); + String genre = getString(m, "Genre"); Integer mediumIndex = null; Integer mediumCount = null; Integer trackIndex = getInteger(m, "Track/Position"); @@ -113,7 +114,7 @@ public class ID3Lookup implements MusicIdentificationService { } } - return new AudioTrack(artist, title, album, albumArtist, trackTitle, albumReleaseDate, mediumIndex, mediumCount, trackIndex, trackCount, mbid, getIdentifier()); + return new AudioTrack(artist, title, album, albumArtist, trackTitle, genre, albumReleaseDate, mediumIndex, mediumCount, trackIndex, trackCount, mbid, getIdentifier()); } public Episode getEpisode(MediaInfo m) {