Class: GoogleVideo::Video

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

Overview

Describes a single video file available for viewing on Google Video.

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.



146
147
148
149
150
151
152
153
154
# File 'lib/google-video.rb', line 146

def initialize (params)
  params.each { |key, value| instance_variable_set('@' + key.to_s, value) }

  # 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.



48
49
50
# File 'lib/google-video.rb', line 48

def description
  @description
end

#doc_idObject (readonly)

the google unique identifier.



51
52
53
# File 'lib/google-video.rb', line 51

def doc_id
  @doc_id
end

#durationObject (readonly)

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



54
55
56
# File 'lib/google-video.rb', line 54

def duration
  @duration
end

#page_urlObject (readonly)

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



57
58
59
# File 'lib/google-video.rb', line 57

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.



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

def playlist_entries
  @playlist_entries
end

#rankObject (readonly)

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



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

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.



74
75
76
# File 'lib/google-video.rb', line 74

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.



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

def rank_embed
  @rank_embed
end

#rank_yesterdayObject (readonly)

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



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

def rank_yesterday
  @rank_yesterday
end

#rating_countObject (readonly)

the number of ratings this video has received.



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

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.



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

def star_count
  @star_count
end

#thumbnail_image_urlObject (readonly)

the full url to the video thumbnail image.



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

def thumbnail_image_url
  @thumbnail_image_url
end

#titleObject (readonly)

the title text describing the video.



91
92
93
# File 'lib/google-video.rb', line 91

def title
  @title
end

#upload_dateObject (readonly)

the date at which the video was uploaded.



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

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.



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

def upload_domain
  @upload_domain
end

#upload_userObject (readonly)

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



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



125
126
127
# File 'lib/google-video.rb', line 125

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.



159
160
161
162
163
164
# File 'lib/google-video.rb', line 159

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



169
170
171
# File 'lib/google-video.rb', line 169

def rank_delta
  (@rank_yesterday - @rank)
end