Skip to content

Commit 7a7c098

Browse files
authored
Updated FLAC info (#540)
1 parent 9cd1e89 commit 7a7c098

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

nemo-audio-tab/nemo-extension/nemo-audio-tab.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# for id3 support
1212
from mutagen.easyid3 import EasyID3
1313
from mutagen.mp3 import MP3
14-
from mutagen.flac import FLAC, StreamInfo
14+
from mutagen.flac import FLAC
1515

1616
# Import the gettext function and alias it as _
1717
from gettext import gettext as _
@@ -162,14 +162,15 @@ def get_property_pages(self, files):
162162

163163
# try to read the FLAC information (length, samplerate)
164164
try:
165-
fcinfo = StreamInfo(filename)
166-
167-
file.add_string_attribute('samplerate', str(fcinfo.sample_rate) + " Hz")
168-
165+
166+
file.add_string_attribute('samplerate', (mutaFile.info.sample_rate) + " Hz")
167+
169168
# [SabreWolfy] added consistent formatting of times in format hh:mm:ss
170169
flaclength = "%02i:%02i:%02i" % ((int(mutaFile.info.length/3600)), (int(mutaFile.info.length/60%60)), (int(mutaFile.info.length%60)))
171170
file.add_string_attribute('length', flaclength)
172-
file.add_string_attribute('bitrate', no_info) # flac doesn't really have a bitrate
171+
flacbitrate0 = (mutaFile.info.bitrate) / 1000
172+
flacbitrate = f"{flacbitrate0:.3f} kbps"
173+
file.add_string_attribute('bitrate', flacbitrate)
173174
except:
174175
file.add_string_attribute('bitrate', no_info)
175176
file.add_string_attribute('length', no_info)

0 commit comments

Comments
 (0)