Upstream bug 563283 by thansen from Freenode. diff -NrU5 banshee-1-1.4.2.orig/src/Core/Banshee.Core/Banshee.Streaming/SaveTrackMetadataJob.cs banshee-1-1.4.2/src/Core/Banshee.Core/Banshee.Streaming/SaveTrackMetadataJob.cs --- banshee-1-1.4.2.orig/src/Core/Banshee.Core/Banshee.Streaming/SaveTrackMetadataJob.cs 2008-10-06 18:27:31.000000000 +0200 +++ banshee-1-1.4.2/src/Core/Banshee.Core/Banshee.Streaming/SaveTrackMetadataJob.cs 2009-01-28 16:56:18.000000000 +0100 @@ -27,10 +27,11 @@ // using System; using Mono.Unix; +using Banshee.Base; using Banshee.Collection; using Banshee.Configuration.Schema; namespace Banshee.Streaming { @@ -84,26 +85,28 @@ file.Tag.Comment = track.Comment; file.Tag.Disc = (uint)track.DiscNumber; file.Tag.DiscCount = (uint)track.DiscCount; file.Tag.Year = (uint)track.Year; file.Tag.BeatsPerMinute = (uint)track.Bpm; - - SaveIsCompilation (file.Tag, track.IsCompilation); + + SaveIsCompilation (file, track.IsCompilation); file.Save (); } - private static void SaveIsCompilation (TagLib.Tag tag, bool is_compilation) + private static void SaveIsCompilation (TagLib.File file, bool is_compilation) { - TagLib.Id3v2.Tag id3v2_tag = tag as TagLib.Id3v2.Tag; - if (id3v2_tag != null) { - id3v2_tag.IsCompilation = is_compilation; - return; - } + try { + TagLib.Id3v2.Tag id3v2_tag = file.GetTag(TagLib.TagTypes.Id3v2, true) as TagLib.Id3v2.Tag; + if (id3v2_tag != null) { + id3v2_tag.IsCompilation = is_compilation; + } + } catch {} - TagLib.Mpeg4.AppleTag apple_tag = tag as TagLib.Mpeg4.AppleTag; - if (apple_tag != null) { - apple_tag.IsCompilation = is_compilation; - return; - } + try { + TagLib.Mpeg4.AppleTag apple_tag = file.GetTag(TagLib.TagTypes.Apple,true) as TagLib.Mpeg4.AppleTag; + if (apple_tag != null) { + apple_tag.IsCompilation = is_compilation; + } + } catch {} } } } diff -NrU5 banshee-1-1.4.2.orig/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs banshee-1-1.4.2/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs --- banshee-1-1.4.2.orig/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs 2009-01-09 00:17:58.000000000 +0100 +++ banshee-1-1.4.2/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs 2009-01-28 16:57:49.000000000 +0100 @@ -139,11 +139,11 @@ FindTrackMediaAttributes (track, file); track.ArtistName = Choose (file.Tag.JoinedPerformers, track.ArtistName, preferTrackInfo); track.AlbumTitle = Choose (file.Tag.Album, track.AlbumTitle, preferTrackInfo); track.AlbumArtist = Choose (file.Tag.FirstAlbumArtist, track.AlbumArtist, preferTrackInfo); - track.IsCompilation = IsCompilation (file.Tag); + track.IsCompilation = IsCompilation (file); track.TrackTitle = Choose (file.Tag.Title, track.TrackTitle, preferTrackInfo); track.Genre = Choose (file.Tag.FirstGenre, track.Genre, preferTrackInfo); track.Composer = Choose (file.Tag.FirstComposer, track.Composer, preferTrackInfo); track.Conductor = Choose (file.Tag.Conductor, track.Conductor, preferTrackInfo); @@ -180,25 +180,29 @@ // TODO look for track number in the file name if not set? // TODO could also pull artist/album from folders _iff_ files two levels deep in the MusicLibrary folder // TODO these ideas could also be done in an extension that collects such hacks } - private static bool IsCompilation (TagLib.Tag tag) + private static bool IsCompilation (TagLib.File file) { - TagLib.Id3v2.Tag id3v2_tag = tag as TagLib.Id3v2.Tag; - if (id3v2_tag != null && id3v2_tag.IsCompilation) - return true; - - TagLib.Mpeg4.AppleTag apple_tag = tag as TagLib.Mpeg4.AppleTag; - if (apple_tag != null && apple_tag.IsCompilation) - return true; + try { + TagLib.Id3v2.Tag id3v2_tag = file.GetTag(TagLib.TagTypes.Id3v2, true) as TagLib.Id3v2.Tag; + if (id3v2_tag != null && id3v2_tag.IsCompilation) + return true; + } catch {} + try { + TagLib.Mpeg4.AppleTag apple_tag = file.GetTag(TagLib.TagTypes.Apple,true) as TagLib.Mpeg4.AppleTag; + if (apple_tag != null && apple_tag.IsCompilation) + return true; + } catch {} + // FIXME the FirstAlbumArtist != FirstPerformer check might return true for half the // tracks on a compilation album, but false for some // TODO checked for 'Soundtrack' (and translated) in the title? - if (tag.Performers.Length > 0 && tag.AlbumArtists.Length > 0 && - (tag.Performers.Length != tag.AlbumArtists.Length || tag.FirstAlbumArtist != tag.FirstPerformer)) { + if (file.Tag.Performers.Length > 0 && file.Tag.AlbumArtists.Length > 0 && + (file.Tag.Performers.Length != file.Tag.AlbumArtists.Length || file.Tag.FirstAlbumArtist != file.Tag.FirstPerformer)) { return true; } return false; }