-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroc.rb
35 lines (31 loc) · 778 Bytes
/
roc.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
require 'sinatra'
require_relative 'ipport'
def add_to_list(url)
File.open('videolist.vl', 'a') { |f|
f.puts url
}
end
get '/' do
# "at the sound of the gong, the time will be #{Time.now}."
#erb :index, :locals => {:vid_src => 'http://www.youtube.com/embed/QBNIvqXmdKk'}
#@vid_src = 'http://www.youtube.com/embed/QBNIvqXmdKk'
#@vid_src = params[:url] if params[:url]
erb :index
end
post '/' do
url = params[:url]
m = url.match(/watch\?v=(?<id>.+)/)
#puts m[:id]
@@id = m[:id]
@vidurl = 'http://www.youtube.com/embed/' + @@id
erb :confirm
end
post '/confirm' do
#@id = params[:id]
if @@id
add_to_list(@@id)
'Your video was added to the queue'
else
'No video to add'
end
end