Class: Dm::DailyMotionResource

Inherits:
Object
  • Object
show all
Includes:
Readable, Requestable, ServerTokens
Defined in:
lib/dm/youtube_resource.rb

Overview

Provides read-only access to a DailyMotion resource (a channel or a video).

Note that this class does not require the user to authenticate.

Examples:

Get the description of the video “Tongue” by R.E.M.:


resource = Dm::DailyMotionResource.new url: 'youtu.be/Kd5M17e7Wek'
resource.description # => "© 2006 WMG\nTongue (Video)"

Get the description of the R.E.M. channel:


resource = Dm::DailyMotionResource.new url: 'dailymotion.com/remhq'
resource.description # => "R.E.M.'s Official DailyMotion Channel"

Instance Method Summary collapse

Methods included from ServerTokens

#server_key, server_key=

Methods included from Readable

#description, #id, #kind, #thumbnail_url, #title

Methods included from Requestable

#request!

Constructor Details

#initialize(attrs = {}) ⇒ DailyMotionResource

Initialize a resource by URL

Parameters:

  • attrs (Hash) (defaults to: {})

Options Hash (attrs):

  • :url (String)

    The URL of the DailyMotion channel or video



28
29
30
# File 'lib/dm/youtube_resource.rb', line 28

def initialize(attrs = {})
  @url = attrs[:url]
end

Instance Method Details

#infoHash

Return the profile info of a DailyMotion account/channel.

Returns:

  • (Hash)
    • :id [String] The ID that DailyMotion uses to uniquely identify the channel.

    • :etag [String] The Etag of this resource.

    • :kind [String] The value will be dailymotion#channel.

    • :snippet [Hash]

      • :title [String] The channel’s title.

      • :description [String] The channel’s description.

      • :publishedAt [String] The date and time that the channel was created. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.

      • :thumbnails [Hash] + :default [Hash] Default thumbnail URL (88px x 88px) + :medium [Hash] Medium thumbnail URL (88px x 88px) + :high [Hash] High thumbnail URL (88px x 88px)

See Also:



48
49
50
51
52
53
54
# File 'lib/dm/youtube_resource.rb', line 48

def info
  @info ||= request! method: :get,
    host: 'https://www.googleapis.com',
    path: "/dailymotion/v3/#{info_path}",
    valid_if: -> resp, body {resp.code == '200' && body['items'].any?},
    extract: -> body {body['items'].first}
end