noesya/osuny

View on GitHub
app/services/video/provider.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class Video::Provider
  PROVIDERS = [
    Vimeo,
    Youtube,
    Dailymotion,
    Peertube # Comes last because detection is less reliable
  ]

  def self.find(video_url)
    PROVIDERS.each do |provider_class|
      provider = provider_class.new(video_url)
      return provider if provider.correct?
    end
    Default.new(video_url)
  end
end