-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
88 lines (72 loc) · 2.12 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require 'json'
require 'sinatra'
APPLE_MUSIC_SONGS = JSON.parse(File.read("data/apple_music_songs.json")).freeze
APPLE_MUSIC_TSA_SONGS = JSON.parse(File.read("data/apple_music_tsa_songs.json")).freeze
SPOTIFY_SONGS = JSON.parse(File.read("data/spotify_songs.json")).freeze
SPOTIFY_TSA_SONGS = JSON.parse(File.read("data/spotify_tsa_songs.json")).freeze
YOUTUBE_MUSIC_SONGS = JSON.parse(File.read("data/youtube_music_songs.json")).freeze
YOUTUBE_MUSIC_TSA_SONGS = JSON.parse(File.read("data/youtube_music_tsa_songs.json")).freeze
LINE_MUSIC_SONGS = JSON.parse(File.read("data/line_music_songs.json")).freeze
LINE_MUSIC_TSA_SONGS = JSON.parse(File.read("data/line_music_tsa_songs.json")).freeze
AMAZON_MUSIC_SONGS = JSON.parse(File.read("data/amazon_music_songs.json")).freeze
set :bind, '0.0.0.0'
get ['/', '/apple_music'] do
song = APPLE_MUSIC_SONGS.sample
logger.info song
redirect song["url"]
end
get '/apple_music/songs_count' do
"#{APPLE_MUSIC_SONGS.size}曲"
end
get '/apple_music/team_shanghai_alice' do
song = APPLE_MUSIC_TSA_SONGS.sample
logger.info song
redirect song["url"]
end
get '/spotify' do
song = SPOTIFY_SONGS.sample
logger.info song
redirect song["url"]
end
get '/spotify/songs_count' do
"#{SPOTIFY_SONGS.size}曲"
end
get '/spotify/team_shanghai_alice' do
song = SPOTIFY_TSA_SONGS.sample
logger.info song
redirect song["url"]
end
get '/youtube_music' do
song = YOUTUBE_MUSIC_SONGS.sample
logger.info song
redirect song["url"]
end
get '/youtube_music/songs_count' do
"#{YOUTUBE_MUSIC_SONGS.size}曲"
end
get '/youtube_music/team_shanghai_alice' do
song = YOUTUBE_MUSIC_TSA_SONGS.sample
logger.info song
redirect song["url"]
end
get '/line_music' do
song = LINE_MUSIC_SONGS.sample
logger.info song
redirect song["url"]
end
get '/line_music/songs_count' do
"#{LINE_MUSIC_SONGS.size}曲"
end
get '/line_music/team_shanghai_alice' do
song = LINE_MUSIC_TSA_SONGS.sample
logger.info song
redirect song["url"]
end
get '/amazon_music' do
song = AMAZON_MUSIC_SONGS.sample
logger.info song
redirect song["url"]
end
get '/amazon_music/songs_count' do
"#{AMAZON_MUSIC_SONGS.size}曲"
end