Files
old-holivud2/app/models/broadcast_recording.rb
2020-08-26 14:35:56 +03:00

26 lines
714 B
Ruby

class BroadcastRecording < ApplicationRecord
belongs_to :broadcast
delegate :name, to: :broadcast, prefix: :broadcast
validates :asset_uid, uniqueness: true
scope :visible, -> { where(hidden: false) }
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.in_time_zone(broadcast.shoot_location_time_zone).strftime("%Y-%m-%d")}_Time_#{created_at.in_time_zone(broadcast.shoot_location_time_zone).strftime("%T")}".parameterize
end
def toggle_star
toggle! :starred
end
end