rapgenius 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -166
- data/lib/rapgenius.rb +4 -2
- data/lib/rapgenius/client.rb +4 -0
- data/lib/rapgenius/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 948d4a8303cf6824595a9c8378c24b369a09f103
|
4
|
+
data.tar.gz: dc5132b71f8204305ef54997f80cb2e95e607e36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 225e3399061dac6944a445d612a6960fcbb8f6816b353e4effcf1a0fd5a73d472a296734c94e527736bc1caf99b12c7602aa03e91ebaefed1510f83c27e1d864
|
7
|
+
data.tar.gz: 9a53001c32c6b8cf2014403df23c587aa33c8ff2de0fe2edb9b2f459261b1a1e6e4502da86ae87f27e20775250004b6ea723f25fb9a24315f70e48ecf109f8cb
|
data/README.md
CHANGED
@@ -1,169 +1,7 @@
|
|
1
|
-
|
1
|
+
## `rapgenius` has been replaced with `genius`
|
2
2
|
|
3
|
-
|
3
|
+
This gem is now deprecated in favour of the new [`genius` gem](https://github.com/timrogers/genius) which works with Genius's [new public API](https://docs.genius.com/).
|
4
4
|
|
5
|
-
|
5
|
+
For more details and help getting started, head to <https://github.com/timrogers/genius>.
|
6
6
|
|
7
|
-
|
8
|
-
[Genius](http://genius.com).
|
9
|
-
|
10
|
-
## Installation
|
11
|
-
|
12
|
-
Install the gem, and you're ready to go. Simply add the following to your
|
13
|
-
Gemfile:
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
gem "rapgenius", "~> 1.1.1"
|
17
|
-
```
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
The best way to get a decent idea of the attributes available on `Song` and
|
22
|
-
the other objects is by checking out the API documentation at:
|
23
|
-
https://docs.genius.com
|
24
|
-
|
25
|
-
### Authenticating
|
26
|
-
|
27
|
-
You can create a client and grab an access token from
|
28
|
-
<http://genius.com/api-clients>.
|
29
|
-
|
30
|
-
From there, you can also generate a client access token and use it like so:
|
31
|
-
|
32
|
-
``` ruby
|
33
|
-
RapGenius::Client.access_token = 'your-access-token'
|
34
|
-
```
|
35
|
-
|
36
|
-
You'll need to have set your token in order to be able to make requests.
|
37
|
-
|
38
|
-
### Searching
|
39
|
-
|
40
|
-
You can search for songs by various fields. All of these
|
41
|
-
methods return an array of `Song` objects...:
|
42
|
-
|
43
|
-
```ruby
|
44
|
-
RapGenius.search("Versace")
|
45
|
-
RapGenius.search_by_title("Versace")
|
46
|
-
RapGenius.search_by_artist("Migos")
|
47
|
-
RapGenius.search_by_lyrics("medusa")
|
48
|
-
```
|
49
|
-
|
50
|
-
If more than 20 results are returned, you won't be able to get access to
|
51
|
-
records beyond the 20th. There doesn't appear to be any pagination support
|
52
|
-
in the API.
|
53
|
-
|
54
|
-
### Songs
|
55
|
-
|
56
|
-
Songs on Genius have unique identifiers. They're not especially
|
57
|
-
easy to find, but if you hover over the "pyong" button near the top of the page,
|
58
|
-
you'll see the song's ID in the URL. Once you have an ID, you can load a
|
59
|
-
song via the API:
|
60
|
-
|
61
|
-
```ruby
|
62
|
-
require 'rapgenius'
|
63
|
-
|
64
|
-
song = RapGenius::Song.find(176872)
|
65
|
-
song.title # => "Versace"
|
66
|
-
song.artists.map(&:name) # => ["Migos", "Drake", "Zaytoven"]
|
67
|
-
```
|
68
|
-
|
69
|
-
Once you've found the song you're seeking, there's plenty of other useful
|
70
|
-
details you can access:
|
71
|
-
|
72
|
-
```ruby
|
73
|
-
song.title
|
74
|
-
# => "Versace"
|
75
|
-
|
76
|
-
song.url
|
77
|
-
# => "http://rapgenius.com/Migos-versace-lyrics""
|
78
|
-
|
79
|
-
song.pyongs
|
80
|
-
# => 22
|
81
|
-
|
82
|
-
song.description
|
83
|
-
# => "Released in June 2013, not only did they take the beat from Soulja Boy’s OMG part 2 but they absolutely killed it."
|
84
|
-
```
|
85
|
-
|
86
|
-
### Lines
|
87
|
-
|
88
|
-
Once you've got a song, you can then go through its "lines", which includes
|
89
|
-
annotated and unannotated parts of the content.
|
90
|
-
|
91
|
-
```ruby
|
92
|
-
line = song.lines[1]
|
93
|
-
|
94
|
-
line.lyric
|
95
|
-
# => Versace, Versace, Medusa head on me like I'm 'luminati
|
96
|
-
|
97
|
-
line.annotations
|
98
|
-
# => ["Read about how this collaboration came to pass here..."]
|
99
|
-
|
100
|
-
line.song
|
101
|
-
# => #<RapGenius::Song:0x007fccdba50a50 @id=176872...
|
102
|
-
```
|
103
|
-
|
104
|
-
### Media
|
105
|
-
|
106
|
-
Rap Genius provides great access to media like MP3s on Soundcloud or videos
|
107
|
-
on YouTube direct from songs.
|
108
|
-
|
109
|
-
```ruby
|
110
|
-
media = song.media.first
|
111
|
-
|
112
|
-
media.type
|
113
|
-
# => "audio"
|
114
|
-
|
115
|
-
media.provider
|
116
|
-
# => "soundcloud"
|
117
|
-
|
118
|
-
media.url
|
119
|
-
# => "https://soundcloud.com/mixtapemechaniks/migos-ft-drake-versace-remix"
|
120
|
-
```
|
121
|
-
|
122
|
-
### Artist
|
123
|
-
|
124
|
-
You can navigate from a song to its artist, and then to other songs by that
|
125
|
-
artist. Magic, huh?!
|
126
|
-
|
127
|
-
```ruby
|
128
|
-
artist = song.artist # or song.artists, song.featured_artists or song.producer_artists
|
129
|
-
|
130
|
-
artist.name
|
131
|
-
# => "Migos"
|
132
|
-
|
133
|
-
artist.type
|
134
|
-
# => :primary
|
135
|
-
|
136
|
-
artist.url
|
137
|
-
# => "http://rapgenius.com/artists/Migos"
|
138
|
-
|
139
|
-
artist.description
|
140
|
-
# => "Migos are an American hip-hop group from Atlanta, Georgia..."
|
141
|
-
|
142
|
-
artist.songs
|
143
|
-
# => [#<RapGenius::Song:0x007fccdb884398...]
|
144
|
-
|
145
|
-
# Songs for an artist load in pages of 25
|
146
|
-
artist.songs(page: 2)
|
147
|
-
# => [#<RapGenius::Song:0x007fccdb884398...]
|
148
|
-
```
|
149
|
-
|
150
|
-
## Examples
|
151
|
-
|
152
|
-
I've built a game called "Guess The Track" using the gem - find out more, grab
|
153
|
-
the source or play for yourself [here](https://github.com/timrogers/rapgenius/blob/master/examples/guess_the_track.md).
|
154
|
-
|
155
|
-
## Contributing
|
156
|
-
|
157
|
-
If you'd like to contribute anything else, go ahead or better still, make an issue and we can talk it over and spec it out! A few quick tips:
|
158
|
-
|
159
|
-
* Don't update the version numbers before your pull request - I'll sort that part out for you.
|
160
|
-
* Make sure you write specs, then run them with `$ bundle exec rake`
|
161
|
-
* Update this README.md file so I, and users, know how your changes work
|
162
|
-
|
163
|
-
## Copyright
|
164
|
-
|
165
|
-
Copyright (c) 2013-2015 Tim Rogers. See LICENSE for details.
|
166
|
-
|
167
|
-
## Get in touch
|
168
|
-
|
169
|
-
Any questions, thoughts or comments? Email me at <me@timrogers.co.uk> or create an issue.
|
7
|
+
If you're *really* sure you want to look at the README and not migrate to the new and much-improved gem, you can access the previous version [here](https://github.com/timrogers/rapgenius/blob/5fcb03cf307078c4aaafc3d564dbda990eb0d155/README.md).
|
data/lib/rapgenius.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
warn "[rapgenius] The RapGenius gem is now deprecated in favour of the more powerful " \
|
2
|
+
"and more robust Genius gem. See https://github.com/timrogers/genius for more " \
|
3
|
+
"details."
|
4
|
+
|
1
5
|
require 'rapgenius/version'
|
2
6
|
require 'rapgenius/client'
|
3
7
|
require 'rapgenius/line'
|
@@ -12,8 +16,6 @@ module RapGenius
|
|
12
16
|
def self.search(query, options = {})
|
13
17
|
response = fetch(build_api_url("/search"), { q: query }.merge(options))
|
14
18
|
|
15
|
-
|
16
|
-
|
17
19
|
response["response"]["hits"].map do |song|
|
18
20
|
result = song["result"]
|
19
21
|
|
data/lib/rapgenius/client.rb
CHANGED
@@ -32,6 +32,10 @@ module RapGenius
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def fetch(url, params = {})
|
35
|
+
warn "[rapgenius] The RapGenius gem is now deprecated in favour of the more " \
|
36
|
+
"powerful and more robust Genius gem. See https://github.com/timrogers/" \
|
37
|
+
"genius for more details."
|
38
|
+
|
35
39
|
unless RapGenius::Client.access_token
|
36
40
|
raise MissingAccessTokenError, "You must specify an access token by setting " \
|
37
41
|
"RapGenius::Client.access_token"
|
data/lib/rapgenius/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rapgenius
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Rogers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|