shoutcast-api-client 0.0.1
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +8 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +14 -0
- data/CONTRIBUTING.md +24 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +60 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/shoutcast/api.rb +8 -0
- data/lib/shoutcast/api/client.rb +31 -0
- data/lib/shoutcast/api/station.rb +39 -0
- data/lib/shoutcast/api/version.rb +5 -0
- data/shoutcast-api-client.gemspec +45 -0
- metadata +202 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 047b193a31dcd4eefe97edc0a15b9a46b93d249f
|
4
|
+
data.tar.gz: f86bd2588fb027bc6f521ee849c5fe76d6bd5923
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: da627a4b652f19fc276c5a382303fd38ecec1816746a9187f7c54130f0ba836b29d35d02a023c65b68b9ee746e69ab3b0fcacefc4a62221af3e700b942584829
|
7
|
+
data.tar.gz: e6b65f76c9631c4deafed6f8ce99c606bdda7d1145c8a69fdd042bafad65a9578dce29149f014f6b08d1d6046c384d60e8f93b4a383e7cf55e5777f813770105
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Unreleased ([Changelog](https://github.com/colszowka/simplecov/compare/v0.0.1...master))
|
2
|
+
==========
|
3
|
+
## Features
|
4
|
+
|
5
|
+
## Enhancements
|
6
|
+
|
7
|
+
## Bugfixes
|
8
|
+
|
9
|
+
0.0.1 ([Changelog](https://github.com/marcferna/shoutcast-api-client/compare/25b8f34...v0.0.1))
|
10
|
+
=================
|
11
|
+
## Features
|
12
|
+
|
13
|
+
* Added Top 500 API interface.
|
14
|
+
* Stations XML Parsing into Ruby objects.
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
## Reporting Issues
|
2
|
+
|
3
|
+
You can report issues at https://github.com/marcferna/shoutcast-api-client/issues
|
4
|
+
|
5
|
+
Before submitting a new issue, search to see if someone else already reported it.
|
6
|
+
If that is not the case and you create a new issue, please include:
|
7
|
+
* Version of the `shoutcast-api-client` you are running.
|
8
|
+
* Full backtrace of the issue if applicable.
|
9
|
+
* Sample code if possible.
|
10
|
+
|
11
|
+
Thanks!
|
12
|
+
|
13
|
+
## Making Contributions
|
14
|
+
|
15
|
+
If you want to contribute, please:
|
16
|
+
|
17
|
+
* Fork the project.
|
18
|
+
* Make your feature addition or bug fix.
|
19
|
+
* Add specs for it.
|
20
|
+
* Make sure to run `rubocop` and that there are no complaints/warnings.
|
21
|
+
* Update the `CHANGELOG.md` if applicable.
|
22
|
+
* Send me a pull request on Github.
|
23
|
+
|
24
|
+
Thanks!
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Marc Fernandez
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# SHOUTcast API Client
|
2
|
+
[](https://travis-ci.org/marcferna/shoutcast-api-client) [](https://codeclimate.com/github/marcferna/shoutcast-api-client) [](https://codeclimate.com/github/marcferna/shoutcast-api-client/coverage) [](https://gemnasium.com/github.com/marcferna/shoutcast-api-client)
|
3
|
+
|
4
|
+
:exclamation:**Important - You will need a SHOUTcast API key for this gem to work. You can request one from their [developer website](https://www.shoutcast.com/Developer)**
|
5
|
+
|
6
|
+
:warning: *Note - This gem is an early alpha and is still in development. Use at your own risk.* :warning:
|
7
|
+
|
8
|
+
## Description
|
9
|
+
This gem provides a nice interface to interact with SHOUTcast’s API and also parses the XML response into Ruby objects.
|
10
|
+
You can find the full API documentation in [SHOUTcast’s official documentation page](http://wiki.winamp.com/wiki/SHOUTcast_Radio_Directory_API).
|
11
|
+
|
12
|
+
## Progress
|
13
|
+
This gem is an early alpha and is still in development. To see a more detailed
|
14
|
+
progress description you can check the [CHANGELOG.md](CHANGELOG.md)
|
15
|
+
|
16
|
+
### Stations
|
17
|
+
|
18
|
+
- [x] Top 500 (Passing parameters not implemented yet)
|
19
|
+
- [ ] Keyword Search
|
20
|
+
- [ ] Stations by Genre
|
21
|
+
- [ ] Stations by Now Playing Info
|
22
|
+
- [ ] Stations by Bitrate or Codec Type or Genre ID
|
23
|
+
- [ ] Random Stations
|
24
|
+
|
25
|
+
### Genres
|
26
|
+
|
27
|
+
- [ ] All Genres
|
28
|
+
- [ ] Primary Genres
|
29
|
+
- [ ] Secondary Genres
|
30
|
+
- [ ] Genres Details by Passing Genreid
|
31
|
+
- [ ] Genres Based on Availability of Sub-Genres
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
|
35
|
+
Add this line to your application’s Gemfile:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
gem 'shoutcast-api-client'
|
39
|
+
```
|
40
|
+
|
41
|
+
And then execute:
|
42
|
+
|
43
|
+
$ bundle
|
44
|
+
|
45
|
+
Or install it yourself as:
|
46
|
+
|
47
|
+
$ gem install shoutcast-api-client
|
48
|
+
|
49
|
+
## Usage
|
50
|
+
|
51
|
+
TODO: Write usage instructions here
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
See [CONTRIBUTING](CONTRIBUTING.md)
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
60
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'shoutcast/api'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require 'pry'
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Shoutcast
|
2
|
+
module Api
|
3
|
+
class Client
|
4
|
+
require 'rest-client'
|
5
|
+
require 'nori'
|
6
|
+
|
7
|
+
def initialize(key:)
|
8
|
+
@key = key
|
9
|
+
end
|
10
|
+
|
11
|
+
def top_500
|
12
|
+
response = RestClient.get url('/legacy/Top500')
|
13
|
+
Nori.new.parse(response)['stationlist']['station'].map do |attributes|
|
14
|
+
Shoutcast::Api::Station.parse(attributes)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_accessor :key
|
21
|
+
|
22
|
+
def base_url
|
23
|
+
'http://api.shoutcast.com'
|
24
|
+
end
|
25
|
+
|
26
|
+
def url(path)
|
27
|
+
"#{base_url}#{path}?k=#{key}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Shoutcast
|
2
|
+
module Api
|
3
|
+
class Station
|
4
|
+
attr_accessor :id, :name, :mt, :br, :genres, :ct, :lc, :logo
|
5
|
+
alias media_type mt
|
6
|
+
alias bitrate br
|
7
|
+
alias current_track ct
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def parse(attributes)
|
11
|
+
station = new
|
12
|
+
station.id = attributes['@id']
|
13
|
+
station.name = attributes['@name']
|
14
|
+
station.mt = attributes['@mt']
|
15
|
+
station.br = attributes['@br']
|
16
|
+
station.genres = parse_genres(attributes)
|
17
|
+
station.ct = attributes['@ct']
|
18
|
+
station.lc = attributes['@lc']
|
19
|
+
station.logo = attributes['@logo']
|
20
|
+
station
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def parse_genres(attributes)
|
26
|
+
genres = []
|
27
|
+
current_genre = attributes['@genre']
|
28
|
+
genre_index = 1
|
29
|
+
until current_genre.nil?
|
30
|
+
genres << current_genre
|
31
|
+
genre_index += 1
|
32
|
+
current_genre = attributes["@genre#{genre_index}"]
|
33
|
+
end
|
34
|
+
genres
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'shoutcast/api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'shoutcast-api-client'
|
8
|
+
spec.version = Shoutcast::Api::VERSION
|
9
|
+
spec.authors = ['Marc Fernandez']
|
10
|
+
spec.email = ['marc.fernandezg@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'SHOUTcast API wrapper.'
|
13
|
+
spec.description = 'Wrapper for the SHOUTcast API.'
|
14
|
+
spec.homepage = 'https://github.com/marcferna/shoutcast-api-client'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the
|
18
|
+
# 'allowed_push_host' to allow pushing to a single host or delete this section
|
19
|
+
# to allow pushing to any host.
|
20
|
+
if spec.respond_to?(:metadata)
|
21
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
22
|
+
else
|
23
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem '\
|
24
|
+
'pushes.'
|
25
|
+
end
|
26
|
+
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
28
|
+
f.match(%r{^(test|spec|features)/})
|
29
|
+
end
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ['lib']
|
33
|
+
|
34
|
+
spec.add_dependency 'rest-client', '~> 2.0'
|
35
|
+
spec.add_dependency 'nori', '~> 2.6'
|
36
|
+
spec.add_dependency 'nokogiri', '~> 1.6'
|
37
|
+
|
38
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
39
|
+
spec.add_development_dependency 'rake', '~> 11.2'
|
40
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
41
|
+
spec.add_development_dependency 'rubocop', '~> 0.42'
|
42
|
+
spec.add_development_dependency 'simplecov'
|
43
|
+
spec.add_development_dependency 'simplecov-json'
|
44
|
+
spec.add_development_dependency 'codeclimate-test-reporter'
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shoutcast-api-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marc Fernandez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nori
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '11.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '11.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.42'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.42'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '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'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov-json
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: codeclimate-test-reporter
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: Wrapper for the SHOUTcast API.
|
154
|
+
email:
|
155
|
+
- marc.fernandezg@gmail.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".gitignore"
|
161
|
+
- ".rspec"
|
162
|
+
- ".rubocop.yml"
|
163
|
+
- ".travis.yml"
|
164
|
+
- CHANGELOG.md
|
165
|
+
- CONTRIBUTING.md
|
166
|
+
- Gemfile
|
167
|
+
- LICENSE.txt
|
168
|
+
- README.md
|
169
|
+
- Rakefile
|
170
|
+
- bin/console
|
171
|
+
- bin/setup
|
172
|
+
- lib/shoutcast/api.rb
|
173
|
+
- lib/shoutcast/api/client.rb
|
174
|
+
- lib/shoutcast/api/station.rb
|
175
|
+
- lib/shoutcast/api/version.rb
|
176
|
+
- shoutcast-api-client.gemspec
|
177
|
+
homepage: https://github.com/marcferna/shoutcast-api-client
|
178
|
+
licenses:
|
179
|
+
- MIT
|
180
|
+
metadata:
|
181
|
+
allowed_push_host: https://rubygems.org
|
182
|
+
post_install_message:
|
183
|
+
rdoc_options: []
|
184
|
+
require_paths:
|
185
|
+
- lib
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
requirements: []
|
197
|
+
rubyforge_project:
|
198
|
+
rubygems_version: 2.5.1
|
199
|
+
signing_key:
|
200
|
+
specification_version: 4
|
201
|
+
summary: SHOUTcast API wrapper.
|
202
|
+
test_files: []
|