LyricFind 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fdf2f4d062693f196d6dbbad0d79b7afdc64305
4
- data.tar.gz: a4aa878c290fdd3daf7960fcff95422e8faf85b6
3
+ metadata.gz: 6f1ebd78a0d5206fc86f6c7c5eef54af3ca92677
4
+ data.tar.gz: 416561a039b43edcc0c7ce1029ee2ef282fe8427
5
5
  SHA512:
6
- metadata.gz: f33aa6c38e308eee978a5576b54c70b41df4a99433c78410d8fbc6a7283b05148911db9b8dc503d8b7b7ee265dca9df17718e2126ef3fd7c17ba44e79ddad766
7
- data.tar.gz: 90e9574edb1d97200de4db64eb04e70902988b93106d2f1cf28709586c6c86b00e10ffd3778b86aff60c1e1b9f601b9a9a996cc12aaceafbda91abcc03b8608b
6
+ metadata.gz: b426119dc6dbb268e2807e14de22d70ed88e5c0db087e946435111e587f64e95b28bc8b3c77b17e879bdee3864bf20fd53ba955efc1d5712297c1153ecdc9874
7
+ data.tar.gz: 97995d024e3053a31743365ebb39f06e945de31400d2e3168297bc3cf9e85e564a824772263a520664f722f2281c5ae164c9be3dbf255c7767d19462ba6c4b1b
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/Gemfile CHANGED
@@ -4,4 +4,4 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'bundler'
7
- gem 'vcr'
7
+
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ LyricFind (0.1.4)
5
+ nokogiri (~> 1.6)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.3.8)
11
+ builder (3.2.2)
12
+ crack (0.4.2)
13
+ safe_yaml (~> 1.0.0)
14
+ cucumber (2.0.0)
15
+ builder (>= 2.1.2)
16
+ cucumber-core (~> 1.1.3)
17
+ diff-lcs (>= 1.1.3)
18
+ gherkin (~> 2.12)
19
+ multi_json (>= 1.7.5, < 2.0)
20
+ multi_test (>= 0.1.2)
21
+ cucumber-core (1.1.3)
22
+ gherkin (~> 2.12.0)
23
+ diff-lcs (1.2.5)
24
+ gherkin (2.12.2)
25
+ multi_json (~> 1.3)
26
+ mini_portile (0.6.2)
27
+ multi_json (1.11.2)
28
+ multi_test (0.1.2)
29
+ nokogiri (1.6.6.2)
30
+ mini_portile (~> 0.6.0)
31
+ rake (10.4.2)
32
+ rspec (3.3.0)
33
+ rspec-core (~> 3.3.0)
34
+ rspec-expectations (~> 3.3.0)
35
+ rspec-mocks (~> 3.3.0)
36
+ rspec-core (3.3.1)
37
+ rspec-support (~> 3.3.0)
38
+ rspec-expectations (3.3.0)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.3.0)
41
+ rspec-mocks (3.3.1)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.3.0)
44
+ rspec-support (3.3.0)
45
+ safe_yaml (1.0.4)
46
+ vcr (2.9.3)
47
+ webmock (1.21.0)
48
+ addressable (>= 2.3.6)
49
+ crack (>= 0.3.2)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ LyricFind!
56
+ bundler
57
+ cucumber (~> 2.0)
58
+ rake (~> 10.0)
59
+ rspec (~> 3.0)
60
+ vcr (~> 2.9)
61
+ webmock (~> 1.21)
data/README.md CHANGED
@@ -53,3 +53,7 @@ puts lf.get_lyrics_by_song_name 'u2', 'one'
53
53
  ## License
54
54
 
55
55
  [MIT](https://github.com/ihassin/lyricfind/blob/master/LICENSE.txt).
56
+
57
+ ## Other efforts
58
+
59
+ Look [here](https://github.com/pilu/lyricfind) if you're looking for am impementation in Go
@@ -1,2 +1,3 @@
1
1
  require "lyricfind/version"
2
2
  require "lyricfind/get_lyrics_by_song_name"
3
+ require "lyricfind/instrumental"
@@ -9,21 +9,10 @@ module LyricFind
9
9
  end
10
10
 
11
11
  def get_lyrics_by_song_name artist, song_name
12
- return nil if artist.nil? or artist.length == 0
13
- return nil if song_name.nil? or song_name.length == 0
14
-
15
- artist = URI.escape artist
16
- song_name = URI.escape song_name
12
+ doc = get_search_api_response artist, song_name
13
+ return if doc == nil
17
14
 
18
15
  begin
19
- query_url = URI.escape "http://api.lyricfind.com/search.do?apikey=#{@search_key}&reqtype=default&searchtype=track&artist=#{artist}&track=#{song_name}"
20
- response = open(query_url).read
21
- doc = Nokogiri::HTML(response)
22
- doc.encoding = 'utf-8'
23
-
24
- return nil if !(check_success doc, 100)
25
- tracks = doc.xpath('//tracks')[0]['totalresults'].to_i
26
- return nil if tracks == 0
27
16
 
28
17
  track = doc.xpath('//tracks/track')[0]['amg']
29
18
 
@@ -37,7 +26,29 @@ module LyricFind
37
26
 
38
27
  lyrics = doc.xpath('//lyrics')
39
28
  lyrics[0].content
40
- rescue
29
+ rescue Exception => ex
30
+ nil
31
+ end
32
+ end
33
+
34
+ def get_search_api_response artist, song_name
35
+ return nil if artist.nil? or artist.length == 0
36
+ return nil if song_name.nil? or song_name.length == 0
37
+
38
+ artist = URI.escape artist
39
+ song_name = URI.escape song_name
40
+
41
+ begin
42
+ query_url = URI.escape "http://api.lyricfind.com/search.do?apikey=#{@search_key}&reqtype=default&searchtype=track&artist=#{artist}&track=#{song_name}"
43
+ response = open(query_url).read
44
+ doc = Nokogiri::HTML(response)
45
+ doc.encoding = 'utf-8'
46
+
47
+ return nil if !(check_success doc, 100)
48
+ tracks = doc.xpath('//tracks')[0]['totalresults'].to_i
49
+ return nil if tracks == 0
50
+ doc
51
+ rescue Exception => ex
41
52
  nil
42
53
  end
43
54
  end
@@ -0,0 +1,13 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+
4
+ module LyricFind
5
+ class API
6
+ def instrumental? artist, song_name
7
+ doc = get_search_api_response artist, song_name
8
+ return nil if doc.nil?
9
+
10
+ return doc.xpath('//tracks/track')[0]['instrumental'] == 'true'
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module LyricFind
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: LyricFind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Itamar Hassin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-24 00:00:00.000000000 Z
11
+ date: 2015-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -117,9 +117,9 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - ".gitignore"
119
119
  - ".rspec"
120
- - ".travis.yml"
121
120
  - CODE_OF_CONDUCT.md
122
121
  - Gemfile
122
+ - Gemfile.lock
123
123
  - LICENSE.txt
124
124
  - README.md
125
125
  - Rakefile
@@ -127,6 +127,7 @@ files:
127
127
  - bin/setup
128
128
  - lib/lyricfind.rb
129
129
  - lib/lyricfind/get_lyrics_by_song_name.rb
130
+ - lib/lyricfind/instrumental.rb
130
131
  - lib/lyricfind/version.rb
131
132
  - lyricfind.gemspec
132
133
  - vendor/cache/addressable-2.3.8.gem
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.1
4
- sudo: required