Class: GoogleVideo::Video

Inherits:
Record
  • Object
show all
Defined in:
lib/google-video.rb

Overview

Describes a single video file available for viewing on Google Video. Parameters are specified via a hash passed to the object on construction mapping attribute names to their respective values.

Constant Summary collapse

DEFAULT_WIDTH =

the default width in pixels for the video embed html.

400
DEFAULT_HEIGHT =

the default height in pixels for the video embed html.

326

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Video

Constructs a Video with the supplied hash mapping attribute names to their respective values.



161
162
163
164
165
166
167
168
169
# File 'lib/google-video.rb', line 161

def initialize (params)
  super(params)

  # pull the doc id out of the page url if we've got one
  if (@page_url)
    @page_url =~ /docid=([^&]+)/
    @doc_id = $1.to_i
  end
end

Instance Attribute Details

#descriptionObject (readonly)

the prose text describing the video contents.



63
64
65
# File 'lib/google-video.rb', line 63

def description
  @description
end

#doc_idObject (readonly)

the google unique identifier.



66
67
68
# File 'lib/google-video.rb', line 66

def doc_id
  @doc_id
end

#durationObject (readonly)

the duration of the video in prose, e.g. “1hr 49min” or “3min”.



69
70
71
# File 'lib/google-video.rb', line 69

def duration
  @duration
end

#page_urlObject (readonly)

the full url at which the video is available for viewing.



72
73
74
# File 'lib/google-video.rb', line 72

def page_url
  @page_url
end

#playlist_entriesObject (readonly)

only available via a details request: a list of PlaylistEntry objects detailed in the “Playlist” of next-up videos displayed on the video detail page.



77
78
79
# File 'lib/google-video.rb', line 77

def playlist_entries
  @playlist_entries
end

#rankObject (readonly)

only available via a details request: the current rank of this video on the site.



81
82
83
# File 'lib/google-video.rb', line 81

def rank
  @rank
end

#rank_emailObject (readonly)

only available via a details request: the current rank of this video on the site based on email metrics.



89
90
91
# File 'lib/google-video.rb', line 89

def rank_email
  @rank_email
end

#rank_embedObject (readonly)

only available via a details request: the current rank of this video on the site based on embedded html metrics.



93
94
95
# File 'lib/google-video.rb', line 93

def rank_embed
  @rank_embed
end

#rank_yesterdayObject (readonly)

only available via a details request: the rank of this video on the site yesterday.



85
86
87
# File 'lib/google-video.rb', line 85

def rank_yesterday
  @rank_yesterday
end

#rating_countObject (readonly)

the number of ratings this video has received.



96
97
98
# File 'lib/google-video.rb', line 96

def rating_count
  @rating_count
end

#star_countObject (readonly)

the number of stars all of the video ratings currently average out to, e.g. 4.5.



100
101
102
# File 'lib/google-video.rb', line 100

def star_count
  @star_count
end

#thumbnail_image_urlObject (readonly)

the full url to the video thumbnail image.



103
104
105
# File 'lib/google-video.rb', line 103

def thumbnail_image_url
  @thumbnail_image_url
end

#titleObject (readonly)

the title text describing the video.



106
107
108
# File 'lib/google-video.rb', line 106

def title
  @title
end

#upload_dateObject (readonly)

the date at which the video was uploaded.



109
110
111
# File 'lib/google-video.rb', line 109

def upload_date
  @upload_date
end

#upload_domainObject (readonly)

only available via a details request, and then only for some videos: the domain provided by the user who uploaded the video.



116
117
118
# File 'lib/google-video.rb', line 116

def upload_domain
  @upload_domain
end

#upload_userObject (readonly)

the name of the user who uploaded the video; not always available.



112
113
114
# File 'lib/google-video.rb', line 112

def upload_user
  @upload_user
end

#upload_user_urlObject (readonly)

only available via a details request, and then only for some videos: the redirect url through Google Video through which you may reach the uploading user’s website.



121
122
123
# File 'lib/google-video.rb', line 121

def upload_user_url
  @upload_user_url
end

#video_file_urlObject (readonly)

only available via a details request: the url to the video’s .gvp format video file. see en.wikipedia.org/wiki/Google_Video#Google_Video_Player for more information on file formats and the like.



127
128
129
# File 'lib/google-video.rb', line 127

def video_file_url
  @video_file_url
end

#video_frame_thumbnailsObject (readonly)

only available via a details request: a list of VideoFrameThumbnail objects describing zero or more individual frame stills within the video.



132
133
134
# File 'lib/google-video.rb', line 132

def video_frame_thumbnails
  @video_frame_thumbnails
end

#view_countObject (readonly)

only available via a details request: the total number of views this video has received to date.



136
137
138
# File 'lib/google-video.rb', line 136

def view_count
  @view_count
end

#view_count_emailObject (readonly)

only available via a details request: the number of views this video has received based on email metrics.



147
148
149
# File 'lib/google-video.rb', line 147

def view_count_email
  @view_count_email
end

#view_count_embedObject (readonly)

only available via a details request: the number of views this video has received based on embedded html metrics.



151
152
153
# File 'lib/google-video.rb', line 151

def view_count_embed
  @view_count_embed
end

#view_count_yesterdayObject (readonly) Also known as: yesterday_view_count

only available via a details request: the number of views this video received yesterday.



140
141
142
# File 'lib/google-video.rb', line 140

def view_count_yesterday
  @view_count_yesterday
end

Instance Method Details

#embed_html(width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT) ⇒ Object

Returns HTML suitable for embedding this video in a web page with the video occupying the specified dimensions. The generated html matches that which is provided by the Google Video web site embed instructions.



174
175
176
177
178
179
# File 'lib/google-video.rb', line 174

def embed_html (width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT)
  <<edoc
<embed style="width:#{width}px; height:#{height}px;" id="VideoPlayback" type="application/x-shockwave-flash" 
 src="http://video.google.com/googleplayer.swf?docId=#{@doc_id}&hl=en" flashvars=""> </embed>
edoc
end

#rank_deltaObject

only available via a details request: the change in rank this video has seen since yesterday’s rank: if positive, a move up, if negative, a move down.



184
185
186
# File 'lib/google-video.rb', line 184

def rank_delta
  (@rank_yesterday - @rank)
end