Skip to content

Commit

Permalink
Merge pull request #1056 from PRX/feat/aac_mpa_support
Browse files Browse the repository at this point in the history
aac m4a support
  • Loading branch information
kookster authored Jul 18, 2024
2 parents 2388551 + df4485e commit 8782012
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/helpers/feeds_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def display_bitrate(feed)
end

def display_bitdepth(feed)
%w[wav flac].include?(feed.try(:audio_format).try(:[], :f)) ? "" : "d-none"
%w[wav flac m4a].include?(feed.try(:audio_format).try(:[], :f)) ? "" : "d-none"
end

def display_audio_format(feed)
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/feed_audio_format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def audio_bitrate=(bitrate)
end

def audio_bitdepth
audio_format.try(:[], :b) if %w[wav flac].include?(audio_format.try(:[], :f))
audio_format.try(:[], :b) if %w[wav flac m4a].include?(audio_format.try(:[], :f))
end

def audio_bitdepth=(bitdepth)
return unless audio_format.present?
return unless %w[wav flac].include?(audio_format.try(:[], :f))
return unless %w[wav flac m4a].include?(audio_format.try(:[], :f))

audio_format[:b] = bitdepth.to_i
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/enclosure_url_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def podcast_episode_expansions(podcast, episode, feed)
ex = File.extname(base[:path].to_s)

# extensions matter for audio, so default to .mp3 if not wav or flac
if media.try(:audio?) && !%w[.wav .flac].include?(ex)
if media.try(:audio?) && !%w[.wav .flac .m4a].include?(ex)
ex = ".mp3"
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/validators/audio_format_validator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AudioFormatValidator < ActiveModel::EachValidator
FORMATS = %w[mp3 wav flac].freeze
FORMATS = %w[mp3 wav flac m4a].freeze
BIT_RATES = [96, 112, 128, 160, 192, 224, 256, 320].freeze
BIT_DEPTHS = [16, 24, 32].freeze
CHANNELS = [1, 2].freeze
Expand All @@ -14,7 +14,7 @@ def validate_each(record, attribute, value)
end

# https://github.com/PRX/dovetail-cdn-arranger#inputs
unless %w[mp3 wav flac].include?(value["f"])
unless FORMATS.include?(value["f"])
return record.errors.add attribute, "unknown audio format: #{value["f"]}"
end

Expand Down
6 changes: 3 additions & 3 deletions app/views/feeds/_form_audio_format.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@
</div>
</div>

<div class="col-3 <%= display_bitdepth(feed) %>" data-toggle-field-target="field" field="wav flac">
<div class="col-3 <%= display_bitdepth(feed) %>" data-toggle-field-target="field" field="wav flac m4a">
<div class="form-floating input-group">
<%= form.select :audio_bitdepth, audio_bitdepth_options %>
<%= form.label :audio_bitdepth %>
</div>
</div>

<div class="col-3 <%= display_audio_format(feed) %>" data-toggle-field-target="field" field="mp3 wav flac">
<div class="col-3 <%= display_audio_format(feed) %>" data-toggle-field-target="field" field="mp3 wav flac m4a">
<div class="form-floating input-group">
<%= form.select :audio_channel, audio_channel_options %>
<%= form.label :audio_channel %>
</div>
</div>

<div class="col-3 <%= display_audio_format(feed) %>" data-toggle-field-target="field" field="mp3 wav flac">
<div class="col-3 <%= display_audio_format(feed) %>" data-toggle-field-target="field" field="mp3 wav flac m4a">
<div class="form-floating input-group">
<%= form.select :audio_sample, audio_sample_options %>
<%= form.label :audio_sample %>
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ en:
mp3: MP3
flac: FLAC
wav: WAV
m4a: AAC
audio_bitrate_options:
"96": 96 kbps
"112": 112 kbps
Expand Down

0 comments on commit 8782012

Please sign in to comment.