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

26 lines
787 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 thumbnail_url(width = 300)
"https://image.mux.com/#{asset_playback_uid}/thumbnail.jpg?width=#{width}"
end
end