musixmatch 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 319b03408f7749b40d77452a7727a1fdd43fbef9d99a6b1f8219340a7abc2f0a
4
+ data.tar.gz: 95025ac4a5b52580fd70d23b6948da41f9ba1a470f325a43faf054acfe7f4bd2
5
+ SHA512:
6
+ metadata.gz: c8c9c9790d82ee52ea0adf939f3b7643ea817ee3da4c68731b6a53e1c2ba174004865650e749f4f7e7b2d56a2596172cd9b19085073c0006df6ec38e1fd49990
7
+ data.tar.gz: ad4cef3a7a3a27c5bcae4f11b44e1d493b53f84c3c1bf73419e674d7ab8fab79559d922ee0157e237a69e2f4abb3cb8a6cff7e66c60eaa30463ddb5917b9823a
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ vendor/
10
+ Gemfile.lock
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,42 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ Exclude:
4
+ - spec/**/*
5
+ Style/Documentation:
6
+ Enabled: false
7
+
8
+ Style/AccessModifierDeclarations:
9
+ EnforcedStyle: inline
10
+
11
+ Layout/EmptyLinesAroundAttributeAccessor:
12
+ Enabled: true
13
+
14
+ Layout/SpaceAroundMethodCallOperator:
15
+ Enabled: true
16
+
17
+ Lint/DeprecatedOpenSSLConstant:
18
+ Enabled: true
19
+
20
+ Lint/RaiseException:
21
+ Enabled: true
22
+
23
+ Lint/StructNewOverride:
24
+ Enabled: true
25
+
26
+ Style/ExponentialNotation:
27
+ Enabled: true
28
+
29
+ Style/HashEachMethods:
30
+ Enabled: true
31
+
32
+ Style/HashTransformKeys:
33
+ Enabled: true
34
+
35
+ Style/HashTransformValues:
36
+ Enabled: true
37
+
38
+ Style/SlicingWithRange:
39
+ Enabled: true
40
+
41
+ Metrics/MethodLength:
42
+ Max: 15
@@ -0,0 +1,8 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.5
6
+ - 2.6
7
+ - 2.7
8
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in musixmatch.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Hondallica
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,83 @@
1
+ # Musixmatch
2
+
3
+ musiXmatch API client library.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'musixmatch'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install musixmatch
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ require 'musixmatch'
27
+ ```
28
+
29
+ ### Setting API key
30
+ You must set the API key.
31
+
32
+ Please refer to the [official API documentation](https://developer.musixmatch.com/documentation) on how to get API key.
33
+
34
+ ```ruby
35
+ musixmatch = Musixmatch.new('your_api_key')
36
+ ```
37
+
38
+ If environment variable MUSIXMATCH_API_KEY is set in .bash_profile etc, no argument is necessary.
39
+
40
+ export MUSIXMATCH_API_KEY=your_api_key
41
+
42
+ ```ruby
43
+ musixmatch = Musixmatch.new
44
+ ```
45
+
46
+ ### change API key
47
+
48
+ ```ruby
49
+ musixmatch.api_key = 'new_api_key'
50
+ ```
51
+
52
+ ### API Resources
53
+ It supports resources of musiXmatch API version 1.1.
54
+ Please refer to the [official API documentation](https://developer.musixmatch.com/documentation) for available parameters etc.
55
+
56
+ ```ruby
57
+ res = musixmatch.chart_artists_get({ chart_name: 'top', page: 1, page_size: 5, country: 'it', f_has_lyrics: 1 })
58
+ res = musixmatch.chart_tracks_get({ chart_name: 'top', page: 1, page_size: 5, country: 'it', f_has_lyrics: 1 })
59
+ res = musixmatch.track_search({ q_artist: 'justin bieber', page_size: 3, page: 1, s_track_rating: 'desc' })
60
+ res = musixmatch.track_get({ commontrack_id: 5920049 })
61
+ res = musixmatch.track_lyrics_get({ track_id: 15953433 })
62
+ res = musixmatch.track_snippet_get({ track_id: 16860631 })
63
+ res = musixmatch.track_subtitle_get({ commontrack_id: 10074988 })
64
+ res = musixmatch.track_richsync_get({ track_id: 114837357 })
65
+ res = musixmatch.track_lyrics_translation_get({ commontrack_id: 10074988, selected_language: 'it' })
66
+ res = musixmatch.track_subtitle_translation_get({ commontrack_id: 10074988, selected_language: 'it' })
67
+ res = musixmatch.music_genres_get
68
+ res = musixmatch.matcher_lyrics_get({ q_track: 'sexy and i know it', q_artist: 'lmfao' })
69
+ res = musixmatch.matcher_track_get({ q_artist: 'eminem', q_track: 'lose yourself (soundtrack)' })
70
+ res = musixmatch.matcher_subtitle_get({ q_track: 'sexy and i know it', q_artist: 'lmfao', f_subtitle_length: 200, f_subtitle_length_max_deviation: 3 })
71
+ res = musixmatch.artist_get({ artist_id: 118 })
72
+ res = musixmatch.artist_search({ q_artist: 'prodigy', page_size:5 })
73
+ res = musixmatch.artist_albums_get({ artist_id: 1039, s_release_date: 'desc', g_album_name: 1 })
74
+ res = musixmatch.artist_related_get({ artist_id: 56, page_size: 2, page: 1 })
75
+ res = musixmatch.album_get({ album_id: 14250417 })
76
+ res = musixmatch.album_tracks_get({ album_id: 13750844, page: 1, page_size: 2 })
77
+ res = musixmatch.tracking_url_get({ domain: 'www.mylyricswebsite.com' })
78
+ res = musixmatch.catalogue_dump_get
79
+ ```
80
+
81
+ ## License
82
+
83
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'musixmatch'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ require 'pry'
12
+ Pry.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'musixmatch/version'
4
+ require 'musixmatch/request'
5
+ require 'musixmatch/api_method'
6
+
7
+ class Musixmatch
8
+ include Version
9
+ include Request
10
+ include APIMethod
11
+ attr_accessor :api_key, :url, :version, :api_version
12
+
13
+ def initialize(api_key = ENV['MUSIXMATCH_API_KEY'])
14
+ raise 'API key is required' unless api_key
15
+
16
+ @version = Version.version
17
+ @api_version = Version.api_version
18
+ @api_key = api_key
19
+ @url = Request.base_url
20
+ end
21
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module APIMethod
4
+ def chart_artists_get(params = {})
5
+ http.get("/ws/#{api_version}/chart.artists.get", _params(params))
6
+ end
7
+
8
+ def chart_tracks_get(params = {})
9
+ http.get("/ws/#{api_version}/chart.tracks.get", _params(params))
10
+ end
11
+
12
+ def track_search(params = {})
13
+ http.get("/ws/#{api_version}/track.search", _params(params))
14
+ end
15
+
16
+ def track_get(params = {})
17
+ http.get("/ws/#{api_version}/track.get", _params(params))
18
+ end
19
+
20
+ def track_lyrics_get(params = {})
21
+ http.get("/ws/#{api_version}/track.lyrics.get", _params(params))
22
+ end
23
+
24
+ def track_snippet_get(params = {})
25
+ http.get("/ws/#{api_version}/track.snippet.get", _params(params))
26
+ end
27
+
28
+ def track_subtitle_get(params = {})
29
+ http.get("/ws/#{api_version}/track.subtitle.get", _params(params))
30
+ end
31
+
32
+ def track_richsync_get(params = {})
33
+ http.get("/ws/#{api_version}/track.richsync.get", _params(params))
34
+ end
35
+
36
+ def track_lyrics_translation_get(params = {})
37
+ http.get("/ws/#{api_version}/track.lyrics.translation.get", _params(params))
38
+ end
39
+
40
+ def track_subtitle_translation_get(params = {})
41
+ http.get("/ws/#{api_version}/track.subtitle.translation.get", _params(params))
42
+ end
43
+
44
+ def music_genres_get(params = {})
45
+ http.get("/ws/#{api_version}/music.genres.get", _params(params))
46
+ end
47
+
48
+ def matcher_lyrics_get(params = {})
49
+ http.get("/ws/#{api_version}/matcher.lyrics.get", _params(params))
50
+ end
51
+
52
+ def matcher_track_get(params = {})
53
+ http.get("/ws/#{api_version}/matcher.track.get", _params(params))
54
+ end
55
+
56
+ def matcher_subtitle_get(params = {})
57
+ http.get("/ws/#{api_version}/matcher.subtitle.get", _params(params))
58
+ end
59
+
60
+ def artist_get(params = {})
61
+ http.get("/ws/#{api_version}/artist.get", _params(params))
62
+ end
63
+
64
+ def artist_search(params = {})
65
+ http.get("/ws/#{api_version}/artist.search", _params(params))
66
+ end
67
+
68
+ def artist_albums_get(params = {})
69
+ http.get("/ws/#{api_version}/artist.albums.get", _params(params))
70
+ end
71
+
72
+ def artist_related_get(params = {})
73
+ http.get("/ws/#{api_version}/artist.related.get", _params(params))
74
+ end
75
+
76
+ def album_get(params = {})
77
+ http.get("/ws/#{api_version}/album.get", _params(params))
78
+ end
79
+
80
+ def album_tracks_get(params = {})
81
+ http.get("/ws/#{api_version}/album.tracks.get", _params(params))
82
+ end
83
+
84
+ def tracking_url_get(params = {})
85
+ http.get("/ws/#{api_version}/tracking.url.get", _params(params))
86
+ end
87
+
88
+ def catalogue_dump_get(params = {})
89
+ http.get("/ws/#{api_version}/catalogue.dump.get", _params(params))
90
+ end
91
+
92
+ def _params(params)
93
+ params['apikey'] = @api_key
94
+ params['format'] = 'json'
95
+ params
96
+ end
97
+ private :_params
98
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+ require 'faraday_middleware'
5
+
6
+ module Request
7
+ def base_url(url = 'https://api.musixmatch.com')
8
+ url
9
+ end
10
+
11
+ def http
12
+ Faraday.new(url: base_url) do |f|
13
+ f.response :mashify
14
+ f.response :json
15
+ f.request :url_encoded
16
+ f.request :retry, max: 5, interval: 1.0
17
+ f.options[:open_timeout] = 2
18
+ f.options[:timeout] = 5
19
+ f.headers['Accept'] = 'application/json'
20
+ f.headers['User-Agent'] = "ruby-musixmatch/#{version}"
21
+ f.adapter :net_http
22
+ end
23
+ end
24
+
25
+ module_function :base_url
26
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Version
4
+ def version
5
+ '0.1.0'
6
+ end
7
+
8
+ def api_version(api_version = '1.1')
9
+ api_version
10
+ end
11
+
12
+ module_function :version, :api_version
13
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/musixmatch/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'musixmatch'
7
+ spec.version = Version.version
8
+ spec.authors = ['Hondallica']
9
+ spec.email = ['hondallica@gmail.com']
10
+
11
+ spec.summary = 'musiXmatch API client library'
12
+ spec.homepage = 'https://github.com/hondallica/ruby-musixmatch'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = spec.homepage
18
+
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.add_dependency 'faraday', '~> 1.0.1'
27
+ spec.add_dependency 'faraday_middleware', '~> 1.0.0'
28
+ spec.add_dependency 'hashie', '~> 4.1.0'
29
+
30
+ spec.add_development_dependency 'bundler', '~>2.1.4'
31
+ spec.add_development_dependency 'pry', '~> 0.13.1'
32
+ spec.add_development_dependency 'rake', '~> 13.0.1'
33
+ spec.add_development_dependency 'rspec', '~> 3.9.0'
34
+ spec.add_development_dependency 'rubocop', '~> 0.84.0'
35
+ spec.add_development_dependency 'webmock', '~> 3.8.3'
36
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: musixmatch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hondallica
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 4.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.1.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.1.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.13.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.13.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 13.0.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 13.0.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 3.9.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.9.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.84.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.84.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 3.8.3
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 3.8.3
139
+ description:
140
+ email:
141
+ - hondallica@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".rubocop.yml"
149
+ - ".travis.yml"
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - bin/console
155
+ - bin/setup
156
+ - lib/musixmatch.rb
157
+ - lib/musixmatch/api_method.rb
158
+ - lib/musixmatch/request.rb
159
+ - lib/musixmatch/version.rb
160
+ - musixmatch.gemspec
161
+ homepage: https://github.com/hondallica/ruby-musixmatch
162
+ licenses:
163
+ - MIT
164
+ metadata:
165
+ homepage_uri: https://github.com/hondallica/ruby-musixmatch
166
+ source_code_uri: https://github.com/hondallica/ruby-musixmatch
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: 2.5.0
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubygems_version: 3.1.2
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: musiXmatch API client library
186
+ test_files: []