1# Copyright 2017 Christoph Reiter
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 of the License, or
6# (at your option) any later version.
7
8try:
9    from mutagen.dsf import DSF
10except ImportError:
11    DSF = None
12
13from ._id3 import ID3File
14
15
16class DSFFile(ID3File):
17    format = "DSF"
18
19    mimes = ["audio/dsf"]
20    Kind = DSF
21
22    def _parse_info(self, info):
23        self["~#length"] = info.length
24        self["~#bitrate"] = int(info.bitrate / 1000)
25        self["~#channels"] = info.channels
26        self["~#samplerate"] = info.sample_rate
27        self["~#bitdepth"] = info.bits_per_sample
28
29loader = DSFFile
30types = [DSFFile]
31
32if DSF:
33    extensions = [".dsf"]
34else:
35    extensions = []
36