~jwiltshire/pogo/debian

« back to all changes in this revision

Viewing changes to src/media/format/wavpack.py

  • Committer: Jonathan Wiltshire
  • Date: 2010-12-20 23:52:57 UTC
  • Revision ID: git-v1:e24ab7d692aa9fecd89514fbd769b83b9db2dd55
Tags: upstream/0.3
Imported Upstream version 0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#
 
3
# Author: Ingelrest François (Francois.Ingelrest@gmail.com)
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU Library General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
18
 
 
19
from media.format import createFileTrack
 
20
 
 
21
 
 
22
def getTrack(filename):
 
23
    """ Return a Track created from a WavPack file """
 
24
    from mutagen.wavpack import WavPack
 
25
 
 
26
    wvFile = WavPack(filename)
 
27
 
 
28
    length     = int(round(wvFile.info.length))
 
29
    samplerate = int(wvFile.info.sample_rate)
 
30
 
 
31
    try:    title = str(wvFile['Title'][0])
 
32
    except: title = None
 
33
 
 
34
    try:    album = str(wvFile['Album'][0])
 
35
    except: album = None
 
36
 
 
37
    try:    artist = str(wvFile['Artist'][0])
 
38
    except: artist = None
 
39
 
 
40
    try:    albumArtist = str(wvFile['Album Artist'][0])
 
41
    except: albumArtist = None
 
42
 
 
43
    try:    genre = str(wvFile['genre'][0])
 
44
    except: genre = None
 
45
 
 
46
    try:    trackNumber = str(wvFile['Track'][0])
 
47
    except: trackNumber = None
 
48
 
 
49
    try:    discNumber = str(wvFile['Disc'][0])
 
50
    except: discNumber = None
 
51
 
 
52
    try:    date = str(wvFile['Year'][0])
 
53
    except: date = None
 
54
 
 
55
    return createFileTrack(filename, -1, length, samplerate, False, title, album, artist, albumArtist,
 
56
                None, genre, trackNumber, date, discNumber)