Class: YoukuVideoUtility

Inherits:
Object
  • Object
show all
Defined in:
lib/youku_video_utility.rb

Constant Summary collapse

CONTENT_TYPE_VIDEO =
'video'
CONTENT_TYPE_SHOW =
'show'
HOST =
'10.103.88.54'

Class Method Summary collapse

Class Method Details

.get_encoded_show_id_from_integer(integer) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/youku_video_utility.rb', line 20

def self.get_encoded_show_id_from_integer integer
  shifted_integer = Integer(integer) << 2 rescue ''
  encoded_show_id = Base64.encode64 "#{shifted_integer}"
  if encoded_show_id != ''
    result = encoded_show_id.chomp
  else
    result = "INVALID: #{integer}"
  end
  result
end

.get_encoded_video_id_from_integer(integer) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/youku_video_utility.rb', line 10

def self.get_encoded_video_id_from_integer integer
  shifted_integer = Integer(integer) << 2 rescue ''
  encoded_video_id = Base64.encode64 "#{shifted_integer}"
  if encoded_video_id != ''
    result = "X#{encoded_video_id}".chomp
  else
    result = "INVALID: #{integer}"
  end
  result
end

.update_extra_information(video_object, options = {}) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/youku_video_utility.rb', line 31

def self.update_extra_information(video_object, options = {})
  options = {:content_id_attribute => :show_id}.merge(options)
  content_id = video_object.send options[:content_id_attribute]
  content_type = get_content_type_from_content_id content_id
  json = send "get_extra_information_for_#{content_type}", content_id
  send "set_extra_information_for_#{content_type}", json, video_object.extra_information
  video_object.extra_information.save
end