-
Notifications
You must be signed in to change notification settings - Fork 0
/
ruby_suits.rb
executable file
·53 lines (46 loc) · 1.13 KB
/
ruby_suits.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env ruby
#Copyright DSK 2013
require "uri"
require "cgi"
require "open-uri"
require "nokogiri"
@cgi = CGI.new("html4") # create CGI object
url = @cgi["v"] # uri argument "v"
ng_obj = Nokogiri::HTML(open(url))
# build list of vid_sites from iframes
vid_sites = []
ng_obj.css("iframe").each do |iframe|
vid_sites << iframe["src"]
end
@links = []
vid_sites.each do |link|
begin
response = open(link).read
# scan finds all matches in the string ending in mp4
# [^etc] character class exclusion list,
# +? non-greedy (stops at first .mp4)
@links << response.scan(/http:\/\/[^&;"]+?\.mp4/s)
rescue
# puts "Error:\t#{link}"
end
end
@body = "" # will hold html code for resulting page
@links.each do |vidsite|
vidsite.each do |mp4link|
@body << @cgi.a("#{mp4link}") {"#{mp4link}"} +
@cgi.br + @cgi.br # add links and separate by BR tags
end
end
@cgi.out { # cgi generated html output
@cgi.html {
CGI.pretty( # pretty print html
@cgi.head { @cgi.title{"Beaming..."} } +
@cgi.body {
"""
<div style='font-size:2.5em'>
#{@body}
</div>
"""
})
}
}