class BroadcastRecording < ApplicationRecord
  belongs_to :broadcast

  delegate :name, to: :broadcast, prefix: :broadcast

  validates :asset_uid, uniqueness: true

  def download_url
    "https://stream.mux.com/#{asset_playback_uid}/#{file_name}?download=#{download_file_name}"
  end

  def playback_url
    "https://stream.mux.com/#{asset_playback_uid}/#{file_name}"
  end

  def download_file_name
    "#{broadcast_name}_Date_#{created_at.strftime("%Y-%m-%d")}_Time_#{created_at.strftime("%T")}".parameterize
  end
end
