-
-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathformat.py
More file actions
37 lines (34 loc) · 1.25 KB
/
format.py
File metadata and controls
37 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from librespot.proto import Metadata_pb2 as Metadata
import enum
class SuperAudioFormat(enum.Enum):
MP3 = 0x00
VORBIS = 0x01
AAC = 0x02
FLAC = 0x03
@staticmethod
def get(audio_format: Metadata.AudioFile.Format):
if audio_format in [
Metadata.AudioFile.Format.OGG_VORBIS_96,
Metadata.AudioFile.Format.OGG_VORBIS_160,
Metadata.AudioFile.Format.OGG_VORBIS_320,
]:
return SuperAudioFormat.VORBIS
if audio_format in [
Metadata.AudioFile.Format.MP3_256,
Metadata.AudioFile.Format.MP3_320,
Metadata.AudioFile.Format.MP3_160,
Metadata.AudioFile.Format.MP3_96,
Metadata.AudioFile.Format.MP3_160_ENC,
]:
return SuperAudioFormat.MP3
if audio_format in [
Metadata.AudioFile.Format.AAC_24,
Metadata.AudioFile.Format.AAC_48,
]:
return SuperAudioFormat.AAC
if audio_format in [
Metadata.AudioFile.Format.FLAC_FLAC,
Metadata.AudioFile.Format.FLAC_FLAC_24BIT,
]:
return SuperAudioFormat.FLAC
raise RuntimeError("Unknown audio format: {}".format(audio_format))