module Streams class CoverSlatePaths def self.slates_custom_root ENV.fetch("MEDIAMTX_SLATES_CUSTOM_DIR", "/slates/custom") end def self.filename_for(record) return nil unless record.cover_slate.attached? digest = record.cover_slate.blob.checksum prefix = record.class.name.underscore "#{prefix}-#{record.id}-#{digest}.mp4" end def self.expected_path(record) name = filename_for(record) return nil if name.blank? File.join(slates_custom_root, name) end def self.local_path_for(record) path = expected_path(record) return nil if path.blank? return path if File.exist?(path) nil end end end