Class: Getvideo::Wole

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

Instance Attribute Summary

Attributes inherited from Video

#url

Instance Method Summary collapse

Methods inherited from Video

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

Constructor Details

This class inherits a constructor from Getvideo::Video

Instance Method Details

#coverObject



26
27
28
# File 'lib/getvideo/56.rb', line 26

def cover
  response["info"]["bimg"] if response
end

#flashObject



34
35
36
# File 'lib/getvideo/56.rb', line 34

def flash
  "http://player.56.com/v_#{id}.swf"
end

#html_urlObject



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

def html_url
  if url =~ /v_([^.]+).html/
    url
  else
    "http://www.56.com/u/v_#{id}.html"
  end
end

#idObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/getvideo/56.rb', line 15

def id
  if url =~ /v_([^.]+).[html|swf]/
    url.scan(/v_([^.]+)\.[html|swf]/)[0][0]
  elsif url =~ /w.+\/play_album.+_vid-([^.]+)\.html/
    ids = url.scan /w.+\/play_album.+_vid-([^.]+)\.html/
    ids[0][0]
  else
    url
  end
end

#m3u8Object



38
39
40
# File 'lib/getvideo/56.rb', line 38

def m3u8
  "http://vxml.56.com/m3u8/#{response["info"]["vid"]}/" if response
end

#mediaObject



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/getvideo/56.rb', line 42

def media
  video_list = {}
  response["info"]["rfiles"].each do |f|
    f_type = f["url"].scan(/\.(flv|mp4|m3u8)\?/)[0][0]
    if video_list[f_type].nil?
      video_list[f_type] = []
      video_list[f_type] << f["url"] 
    else
      video_list[f_type] << f["url"]
    end
  end
  return video_list
end

#play_mediaObject



56
57
58
# File 'lib/getvideo/56.rb', line 56

def play_media
  media["mp4"][0] if media["mp4"]
end

#titleObject



30
31
32
# File 'lib/getvideo/56.rb', line 30

def title
  response["info"]["Subject"] if response
end