~andrewsomething/exaile/karmic

« back to all changes in this revision

Viewing changes to xl/metadata/wav.py

  • Committer: Aren Olson
  • Date: 2009-09-12 00:36:59 UTC
  • Revision ID: reacocard@gmail.com-20090912003659-w373sg0n04uoa8op
remove useless files, add soem of the fixes from lp bug 420019

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2009 Adam Olsen
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2, or (at your option)
6
 
# any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
 
 
17
 
from xl.metadata import BaseFormat
18
 
import wave, sunau, aifc, sndhdr
19
 
 
20
 
type_map = {
21
 
        "aifc": aifc,
22
 
        "aiff": aifc,
23
 
        "au"  : sunau,
24
 
        "wav" : wave,
25
 
        }
26
 
 
27
 
class WavFormat(BaseFormat):
28
 
    def load(self):
29
 
        try:
30
 
            opener = type_map[sndhdr.what(self.loc)]
31
 
            f = opener.open(self.loc, "rb")
32
 
            length = f.getnframes() / f.getframerate()
33
 
            self.mutagen = {'__bitrate': -1, '__length': length}
34
 
        except (IOError, KeyError):
35
 
            self.mutagen = {'__bitrate': -1, '__length': -1}
36
 
 
37
 
 
38
 
        
39