Class: Getvideo::Sohu
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
Instance Method Details
#cover ⇒ Object
35
36
37
|
# File 'lib/getvideo/sohu.rb', line 35
def cover
response["data"]["coverImg"]
end
|
#flash ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/getvideo/sohu.rb', line 39
def flash
if url =~ /(my\.tv)/
"http://share.vrs.sohu.com/my/v.swf&topBar=1&id=#{id}&autoplay=false"
else
"http://share.vrs.sohu.com/#{id}/v.swf&autoplay=false"
end
end
|
#html_url ⇒ Object
13
14
15
|
# File 'lib/getvideo/sohu.rb', line 13
def html_url
response["url"]
end
|
#id ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/getvideo/sohu.rb', line 17
def id
if url =~ /my\.tv.+\/(?:pl|us)\/(?:[^\D]+)\/([^\D]+)/
u = url.scan(/my\.tv.+\/(?:pl|us)\/(?:[^\D]+)\/([^\D]+)/)[0][0]
elsif url =~ /(\.shtml|my\.tv.+\/user\/detail)/
parse_vid[1]
elsif url =~ /v\.swf/
url.scan(/(sohu\.com\/([^\D]+)\/v.swf|id=([^\D]+))/)[0].compact[1]
elsif url =~ /\|my/
url.split("|")[0]
else
url
end
end
|
#m3u8 ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/getvideo/sohu.rb', line 47
def m3u8
if url =~ /(my\.tv)/
"http://my.tv.sohu.com/ipad/#{id}.m3u8"
else
"http://hot.vrs.sohu.com/ipad#{id}.m3u8"
end
end
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/getvideo/sohu.rb', line 55
def media
host = response["allot"]
prot = response["prot"]
clips = response["data"]["clipsURL"]
new = response["data"]["su"]
clips_len = clips.length
new_len = new.length
video_list = {}
video_list["mp4"] = []
clips.zip(new).each do | c, n |
h, _, _, key = Net::HTTP.get(URI.parse("http://#{host}?prot=#{prot}&file=#{c}&new=#{n}")).split("|")
video_list["mp4"] << "#{h}#{n}?key=#{key}"
end
return video_list
end
|
#parse_vid ⇒ Object
71
72
73
74
75
|
# File 'lib/getvideo/sohu.rb', line 71
def parse_vid
conn = Faraday.new
page_res = conn.get(url)
page_res.body.match(/vid[\s]*=[\s]*["|']?(\d+)["|']?/)
end
|
#title ⇒ Object
31
32
33
|
# File 'lib/getvideo/sohu.rb', line 31
def title
response["data"]["tvName"]
end
|