Skip to content

Commit

Permalink
replaygain2: replace extension based type detection with type check
Browse files Browse the repository at this point in the history
Fixes OGG Vorbis files not being detected as supported
  • Loading branch information
phw committed May 11, 2023
1 parent 04f5568 commit 08247c0
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions plugins/replaygain2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,21 @@
from PyQt5.QtWidgets import QFileDialog

from picard import log
from picard.formats.vorbis import OggOpusFile
from picard.formats import (
AiffFile,
ASFFile,
FLACFile,
MonkeysAudioFile,
MP3File,
MP4File,
OggFLACFile,
OggOpusFile,
OggSpeexFile,
OggTheoraFile,
OggVorbisFile,
WAVFile,
WavPackFile,
)
from picard.album import Album
from picard.track import Track, NonAlbumTrack
from picard.util import thread
Expand All @@ -52,6 +66,7 @@
register_album_action)
from picard.plugins.replaygain2.ui_options_replaygain2 import Ui_ReplayGain2OptionsPage


CLIP_MODE_DISABLED = 0
CLIP_MODE_POSITIVE = 1
CLIP_MODE_ALWAYS = 2
Expand All @@ -65,20 +80,20 @@
OPUS_MODE_STANDARD = 0
OPUS_MODE_R128 = 1

SUPPORTED_EXTS = (
".mp2",
".mp3",
".flac",
".ogg",
".oga",
".spx",
".opus",
".m4a",
".wv",
".ape",
".wma",
".wav",
".aiff"
SUPPORTED_FORMATS = (
AiffFile,
ASFFile,
FLACFile,
MonkeysAudioFile,
MP3File,
MP4File,
OggFLACFile,
OggOpusFile,
OggSpeexFile,
OggTheoraFile,
OggVorbisFile,
WAVFile,
WavPackFile,
)

TABLE_HEADER = (
Expand Down Expand Up @@ -174,7 +189,7 @@ def calculate_replaygain(tracks, options):
if not track.files:
continue
file = track.files[0]
if not file.EXTENSIONS or file.EXTENSIONS[0] not in SUPPORTED_EXTS:
if not type(file) in SUPPORTED_FORMATS:
raise Exception(f"ReplayGain 2.0: File '{file.filename}' is of unsupported format")
files.append(file.filename)
valid_tracks.append(track)
Expand Down

0 comments on commit 08247c0

Please sign in to comment.