Class: Getvideo::Youku

Inherits:
Video
  • Object
show all
Defined in:
lib/getvideo/youku.rb

Instance Attribute Summary

Attributes inherited from Video

#url

Instance Method Summary collapse

Methods inherited from Video

#connection, get_api_uri, #initialize, #json, #play_media, #response, set_api_uri

Constructor Details

This class inherits a constructor from Getvideo::Video

Instance Method Details

#coverObject



25
26
27
28
29
# File 'lib/getvideo/youku.rb', line 25

def cover
  if data = response["data"]
    data[0]["logo"]
  end
end

#flashObject



31
32
33
# File 'lib/getvideo/youku.rb', line 31

def flash
  "http://player.youku.com/player.php/sid/#{id}/v.swf"
end

#html_urlObject



15
16
17
# File 'lib/getvideo/youku.rb', line 15

def html_url
  "http://v.youku.com/v_show/id_#{id}.html"
end

#idObject



7
8
9
10
11
12
13
# File 'lib/getvideo/youku.rb', line 7

def id
  if url =~ /\.html/
    url.scan(/id_([^.]+)/)[0][0]
  elsif url =~ /\.swf/
    url.scan(/sid\/([^\/]+)\/v.swf/)[0][0]
  end
end

#m3u8Object



35
36
37
# File 'lib/getvideo/youku.rb', line 35

def m3u8
  "http://v.youku.com/player/getM3U8/vid/#{videoid}/type/flv/ts/v.m3u8" 
end

#media(type = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/getvideo/youku.rb', line 39

def media(type = nil)
  video_list = {}
  if data = response["data"]
    data[0]["streamfileids"].each_key do |type|
      stream = parse_stream(type)
      video_list[type] = []
      segs(type).each do |s|
        video_list[type] << "http://f.youku.com/player/getFlvPath/sid/" + sid + "/st/#{type}/fileid/#{stream[0..8]+s["no"].to_i.to_s(16)+stream[10..-1]}_0#{s["no"].to_i.to_s(16)}?K="+s["k"] if s["k"] != -1
      end
    end
  end
  return video_list
end

#titleObject



19
20
21
22
23
# File 'lib/getvideo/youku.rb', line 19

def title
  if data = response["data"]
    data[0]["title"]
  end
end