-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.rb
69 lines (55 loc) · 1.34 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
require 'rapgenius'
require 'pp'
require 'json'
require 'soundcloud'
require 'sinatra'
def search_by_lyrics(query, number)
strings = RapGenius.search_by_lyrics(query)[0..3].collect do | song |
song.title + " - " + song.artist.name
end
strings.join("\n")
end
def search_by_title(query, number)
songs = RapGenius.search_by_title(query)[0..10].collect do | song |
puts song
end
puts songs
end
def parse_song_list(songsCollection){
songsCollection.each { |song| puts #{}song. }
}
def rap_genius_from_name(query, number)
rapgenius_object_id = RapGenius.search_by_lyrics(query)[0]["id"]
"genius.com/songs/" + id
end
bas
def getLyrics(songId)
puts song.title
iterate_lines(song)
end
def iterate_lines(song)
output=""
current_lines = song.lines
current_lines.each{|current| concat_lines(output,current)}
puts result_lyrics
end
def concat_lines(buffer,current)
if(current.lyric[0] == ",")
buffer << "\n\n"
else
buffer << "\n"+current.lyric.to_s
end
end
get '/' do
'Genius-As-A-Service\n------------------\n\n
Choose your poison mane
\n\n
Seriously though.\n
Currently we\'re offering querying service only.\n
You could query by song, by lyrics or by artist'
end
#Print name of artist, name of song, release year, album
get '/:songId/' do
current = params['songId']
"#{print_details(current)}"
end