2 // FilterMusic.cs : This is the parent class of every audio tag-reading class
3 // It will retreive the tag from the subclass, then fill the
4 // beagle property as needed.
7 // Raphaël Slinckx <raf.raf@wol.be>
9 // Copyright 2004 (C) Raphaël Slinckx
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
20 // The above copyright notice and this permission notice shall be included in
21 // all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
34 using Beagle
.Util
.AudioUtil
;
36 namespace Beagle
.Filters
{
38 public abstract class FilterMusic
: Beagle
.Daemon
.Filter
{
40 private static Beagle
.Util
.Logger log
= Beagle
.Util
.Logger
.Get ("FilterMusic");
44 RegisterSupportedTypes ();
47 protected abstract Tag
GetTag (Stream s
);
49 protected abstract void RegisterSupportedTypes ();
51 protected override void DoPullProperties ()
55 tag
= GetTag (Stream
);
56 } catch (Exception e
) {
57 log
.Debug ("Exception filtering music {0}: {1}", this.GetType (), e
.Message
);
62 log
.Debug ("{0}", tag
);
64 //FIXME: Do we need to check for non-null empty values ?
65 //This should be done in Beagle.Property.New I think..
67 if (tag
.Artist
.Length
> 0)
68 AddProperty (Beagle
.Property
.New ("fixme:artist", tag
.Artist
));
70 if (tag
.Album
.Length
> 0)
71 AddProperty (Beagle
.Property
.New ("fixme:album", tag
.Album
));
73 if (tag
.Title
.Length
> 0)
74 AddProperty (Beagle
.Property
.New ("fixme:title", tag
.Title
));
76 if (tag
.Comment
.Length
> 0)
77 AddProperty (Beagle
.Property
.New ("fixme:comment", tag
.Comment
));
79 if (tag
.Track
.Length
> 0)
80 AddProperty (Beagle
.Property
.NewKeyword ("fixme:tracknumber", tag
.Track
));
82 if (tag
.Year
.Length
> 0)
83 AddProperty (Beagle
.Property
.NewKeyword ("fixme:year", tag
.Year
));
85 if (tag
.Genre
.Length
> 0)
86 AddProperty (Beagle
.Property
.NewKeyword ("fixme:genre", tag
.Genre
));
90 - AddProperty (Beagle.Property.NewBool ("fixme:haspicture", true));