2 // FilterMusic.cs : This is our interface to entagged-sharp's AudioFileWrapper
7 // Permission is hereby granted, free of charge, to any person obtaining a
8 // copy of this software and associated documentation files (the "Software"),
9 // to deal in the Software without restriction, including without limitation
10 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 // and/or sell copies of the Software, and to permit persons to whom the
12 // Software is furnished to do so, subject to the following conditions:
14 // The above copyright notice and this permission notice shall be included in
15 // all copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 // DEALINGS IN THE SOFTWARE.
32 namespace Beagle
.Filters
{
34 public class FilterMusic
: Beagle
.Daemon
.Filter
{
38 // APE / Monkeys Audio
39 AddSupportedFlavor (FilterFlavor
.NewFromExtension (".ape"));
42 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("audio/x-flac"));
45 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("audio/x-mp3"));
46 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("audio/mpeg"));
48 // MPC / Musepack / MPEG+
49 AddSupportedFlavor (FilterFlavor
.NewFromExtension (".mpc"));
50 AddSupportedFlavor (FilterFlavor
.NewFromExtension (".mp+"));
52 // M4A / Apple Audio Codec
53 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("audio/x-m4a"));
54 AddSupportedFlavor (FilterFlavor
.NewFromExtension (".m4p"));
57 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("application/ogg"));
59 // Tracker / Amiga Audio
60 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("audio/x-s3m"));
61 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("audio/x-it"));
62 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("audio/x-mod"));
63 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("audio/x-xm"));
66 AddSupportedFlavor (FilterFlavor
.NewFromMimeType ("audio/x-ms-wma"));
69 private string GetEntaggedMimeType ()
71 if (Extension
!= null && Extension
.Length
> 0)
72 return "entagged/" + Extension
.Substring (1);
77 protected override void DoPullProperties ()
82 tag
= new AudioFile (Stream
, GetEntaggedMimeType ());
83 } catch (Exception e
) {
84 Logger
.Log
.Warn (e
, "Exception filtering music");
89 foreach (string artist
in tag
.Artists
)
90 AddProperty (Beagle
.Property
.New ("fixme:artist", artist
));
92 foreach (string album
in tag
.Albums
)
93 AddProperty (Beagle
.Property
.New ("fixme:album", album
));
95 foreach (string title
in tag
.Titles
)
96 AddProperty (Beagle
.Property
.New ("fixme:title", title
));
98 foreach (string comment
in tag
.Comments
)
99 AddProperty (Beagle
.Property
.New ("fixme:comment", comment
));
101 foreach (int track
in tag
.TrackNumbers
)
102 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:tracknumber", track
));
104 foreach (int track
in tag
.TrackCounts
)
105 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:trackcount", track
));
107 foreach (int year
in tag
.Years
)
108 AddProperty (Beagle
.Property
.NewUnsearched ("fixme:year", year
));
110 foreach (string genre
in tag
.Genres
)
111 AddProperty (Beagle
.Property
.NewKeyword ("fixme:genre", genre
));