class VideoInfo::Providers::Dailymotion

Public Class Methods

usable?(url) click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 4
def self.usable?(url)
  url.match?(/(dai(?:\.ly|lymotion\.com))/)
end

Public Instance Methods

author() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 20
def author
  data["owner.screenname"]
end
author_thumbnail() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 28
def author_thumbnail
  data["owner.avatar_60_url"]
end
author_url() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 24
def author_url
  data["owner.url"]
end
date() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 40
def date
  Time.at(data["created_time"]).utc
end
embed_url() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 36
def embed_url
  "//www.dailymotion.com/embed/video/#{video_id}"
end
keywords() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 32
def keywords
  data["tags"]
end
provider() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 8
def provider
  "Dailymotion"
end
stats() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 60
def stats
  {
    "views_total" => view_count,
    "likes_total" => data["likes_total"].to_i
  }
end
thumbnail_large() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 52
def thumbnail_large
  data["thumbnail_720_url"]
end
thumbnail_medium() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 48
def thumbnail_medium
  data["thumbnail_240_url"]
end
thumbnail_small() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 44
def thumbnail_small
  data["thumbnail_60_url"]
end
view_count() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 56
def view_count
  data["views_total"].to_i
end

Private Instance Methods

_api_base() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 81
def _api_base
  "api.dailymotion.com"
end
_api_path() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 85
def _api_path
  "/video/#{video_id}"
end
_api_url() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 89
def _api_url
  "https://#{_api_base}#{_api_path}?" \
  "fields=id,title,description,duration,created_time," \
  "url,views_total,tags,thumbnail_url,thumbnail_720_url," \
  "owner.url,owner.screenname,owner.avatar_60_url," \
  "thumbnail_240_url,thumbnail_60_url,likes_total"
end
_default_iframe_attributes() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 97
def _default_iframe_attributes
  {}
end
_default_url_attributes() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 101
def _default_url_attributes
  {autoplay: 0}
end
_response_code() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 69
def _response_code
  response = nil
  Net::HTTP.start(_api_base, 443, use_ssl: true) do |http|
    response = http.get(_api_path)
  end
  response.code
end
_url_regex() click to toggle source
# File lib/video_info/providers/dailymotion.rb, line 77
def _url_regex
  %r{dai(?:\.ly|lymotion\.com/(?:embed/)?video)/([a-zA-Z0-9]*)}
end