-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
47 lines (38 loc) · 770 Bytes
/
app.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
require 'sinatra'
require 'sinatra/reloader' if development?
require 'better_errors'
require 'dotenv'
require_relative 'rtl'
Dotenv.load
DEFAULT_URL = ENV['DEFAULT_URL'] || 'https://www.rtl.lu/news/national/a/1372563.html'
configure :development do
use BetterErrors::Middleware
BetterErrors.application_root = __dir__
end
configure { set :server, :puma }
set :public_folder, 'public'
get '/' do
erb :home
end
post '/' do
url = params[:url]
options = {
quality: params[:quality],
verbose: false,
target: './public'
}
video = RTL.parse(url, options)
erb :videos, locals: {
videos: [video],
}
end
get '/robots.txt' do
status 200
body "User-agent: *\nDisallow: /"
end
get '/*' do
redirect '/'
end
error do
redirect '/'
end