hallon 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -0
- data/{CHANGELOG → CHANGELOG.md} +82 -27
- data/Gemfile +1 -0
- data/README.markdown +1 -1
- data/Rakefile +8 -6
- data/examples/adding_tracks_to_playlist.rb +3 -0
- data/examples/logging_in.rb +3 -0
- data/examples/playing_audio.rb +130 -0
- data/examples/printing_link_information.rb +3 -0
- data/examples/show_published_playlists_of_user.rb +5 -13
- data/hallon.gemspec +2 -2
- data/lib/hallon.rb +15 -0
- data/lib/hallon/album.rb +1 -1
- data/lib/hallon/album_browse.rb +4 -3
- data/lib/hallon/artist.rb +1 -1
- data/lib/hallon/artist_browse.rb +5 -4
- data/lib/hallon/base.rb +7 -2
- data/lib/hallon/error.rb +1 -1
- data/lib/hallon/ext/spotify.rb +26 -42
- data/lib/hallon/image.rb +7 -8
- data/lib/hallon/observable.rb +134 -62
- data/lib/hallon/observable/album_browse.rb +30 -0
- data/lib/hallon/observable/artist_browse.rb +31 -0
- data/lib/hallon/observable/image.rb +31 -0
- data/lib/hallon/observable/player.rb +13 -0
- data/lib/hallon/observable/playlist.rb +194 -0
- data/lib/hallon/observable/playlist_container.rb +74 -0
- data/lib/hallon/observable/post.rb +30 -0
- data/lib/hallon/observable/search.rb +29 -0
- data/lib/hallon/observable/session.rb +236 -0
- data/lib/hallon/observable/toplist.rb +30 -0
- data/lib/hallon/player.rb +8 -17
- data/lib/hallon/playlist.rb +11 -7
- data/lib/hallon/playlist_container.rb +11 -4
- data/lib/hallon/queue.rb +71 -0
- data/lib/hallon/search.rb +10 -7
- data/lib/hallon/session.rb +18 -21
- data/lib/hallon/toplist.rb +4 -3
- data/lib/hallon/user.rb +5 -5
- data/lib/hallon/version.rb +1 -1
- data/spec/hallon/album_browse_spec.rb +4 -0
- data/spec/hallon/artist_browse_spec.rb +4 -0
- data/spec/hallon/base_spec.rb +26 -9
- data/spec/hallon/hallon_spec.rb +0 -18
- data/spec/hallon/image_spec.rb +0 -1
- data/spec/hallon/link_spec.rb +14 -0
- data/spec/hallon/observable/album_browse_spec.rb +7 -0
- data/spec/hallon/observable/artist_browse_spec.rb +7 -0
- data/spec/hallon/observable/image_spec.rb +8 -0
- data/spec/hallon/observable/playlist_container_spec.rb +21 -0
- data/spec/hallon/observable/playlist_spec.rb +85 -0
- data/spec/hallon/observable/post_spec.rb +8 -0
- data/spec/hallon/observable/search_spec.rb +7 -0
- data/spec/hallon/observable/session_spec.rb +143 -0
- data/spec/hallon/observable/toplist_spec.rb +7 -0
- data/spec/hallon/observable_spec.rb +134 -65
- data/spec/hallon/playlist_container_spec.rb +24 -18
- data/spec/hallon/playlist_spec.rb +2 -0
- data/spec/hallon/queue_spec.rb +35 -0
- data/spec/hallon/session_spec.rb +4 -4
- data/spec/hallon/spotify_spec.rb +35 -9
- data/spec/mockspotify.rb +2 -3
- data/spec/spec_helper.rb +0 -1
- data/spec/support/common_objects.rb +27 -15
- data/spec/support/enumerable_comparison.rb +9 -0
- data/spec/support/shared_for_callbacks.rb +60 -0
- data/spec/support/shared_for_linkable_objects.rb +1 -1
- metadata +56 -20
data/.yardopts
CHANGED
data/{CHANGELOG → CHANGELOG.md}
RENAMED
@@ -1,22 +1,49 @@
|
|
1
1
|
Hallon’s Changelog
|
2
2
|
==================
|
3
3
|
|
4
|
-
v0.
|
4
|
+
[v0.12.0][]
|
5
5
|
------------------
|
6
|
-
|
6
|
+
|
7
|
+
__Added__
|
8
|
+
|
9
|
+
- New system of handling callbacks (with documentation)
|
10
|
+
- Hallon::Queue (useful for music_delivery callback)
|
11
|
+
- PlaylistContainer::Folder#contents
|
12
|
+
|
13
|
+
__Changed__
|
14
|
+
|
15
|
+
- Rewrote the callback system (5f74ed8)
|
16
|
+
- Thread.abort_on_exception = true
|
17
|
+
- Upgraded to Spotify v10.3.0
|
18
|
+
|
19
|
+
__Fixed__
|
20
|
+
|
21
|
+
- Hallon::Error.maybe_raise(:is_loading) will not raise now
|
22
|
+
- UTF8 strings in applicable places for output/input
|
23
|
+
- Playlist#name= validation issue (allowing too long names)
|
24
|
+
|
25
|
+
[v0.11.0][]
|
26
|
+
------------------
|
27
|
+
|
28
|
+
__Added__
|
29
|
+
|
7
30
|
- Playlist#can_move?
|
8
31
|
- Base.from(pointer)
|
9
32
|
|
10
|
-
|
33
|
+
__Changed__
|
34
|
+
|
11
35
|
- Playlist#move no longer takes a dry_run parameter
|
12
36
|
|
13
|
-
|
37
|
+
__Fixed__
|
38
|
+
|
14
39
|
- Player#music_delivery callback ignoring consumed frames
|
15
40
|
- Session#wait_for minimum timeout time from 0 to 10 ms
|
16
41
|
|
17
|
-
v0.10.1 (actually v0.10.0)
|
42
|
+
[v0.10.1][] (actually v0.10.0)
|
18
43
|
------------------
|
19
|
-
|
44
|
+
|
45
|
+
__Added__
|
46
|
+
|
20
47
|
- Add PlaylistContainer::Folder#rename
|
21
48
|
- Add PlaylistContainer#insert_folder
|
22
49
|
- Add PlaylistContainer#move (do see #57)
|
@@ -27,33 +54,39 @@ v0.10.1 (actually v0.10.0)
|
|
27
54
|
- Playlist::Track#moved?
|
28
55
|
- PlaylistContainer callback support (to be changed, see #56)
|
29
56
|
|
30
|
-
|
57
|
+
__Fixed__
|
58
|
+
|
31
59
|
- A lot of random deadlocks (updated spotify gem dependency)
|
32
60
|
|
33
|
-
v0.9.1
|
61
|
+
[v0.9.1][]
|
34
62
|
------------------
|
35
|
-
|
63
|
+
|
64
|
+
__Added__
|
65
|
+
|
36
66
|
- PlaylistContainer#size
|
37
67
|
- User#published
|
38
68
|
- PlaylistContainer#contents (only for playlists)
|
39
69
|
- PlaylistContainer#add (existing playlist, new playlist)
|
40
70
|
|
41
|
-
|
71
|
+
__Changed__
|
72
|
+
|
42
73
|
- Playlist#seen now moved to Playlist::Track#seen=
|
43
74
|
|
44
|
-
|
75
|
+
__Fixed__
|
76
|
+
|
45
77
|
- Album#cover null pointer issue (https://github.com/Burgestrand/Hallon/issues/53)
|
46
78
|
- Various possible null pointer bugs
|
47
79
|
|
48
|
-
|
49
|
-
v0.9.0
|
80
|
+
[v0.9.0][]
|
50
81
|
------------------
|
82
|
+
|
51
83
|
- Upgraded to libspotify *v10*
|
52
84
|
- Improve documentation consistency
|
53
85
|
- Link.new now raises an error if there’s no session
|
54
86
|
- Minimal PlaylistContainer support (more to come next version)
|
55
87
|
|
56
|
-
|
88
|
+
__Added__
|
89
|
+
|
57
90
|
- Playlist subsystem support
|
58
91
|
- Toplist#request_duration
|
59
92
|
- AlbumBrowse#request_duration
|
@@ -75,23 +108,27 @@ v0.9.0
|
|
75
108
|
- Track#unwrap
|
76
109
|
- type parameter to Artist#browse
|
77
110
|
|
78
|
-
|
111
|
+
__Fixed__
|
112
|
+
|
79
113
|
- Moved from using FFI::Pointers to Spotify::Pointers
|
80
114
|
- Spotify::Pointer garbage collection
|
81
115
|
- Link#valid? using exceptions for flow control
|
82
116
|
- Session#connection_rules= now raises an error when given invalid rule
|
83
117
|
- Search.radio now raises an error when given invalid genres
|
84
118
|
|
85
|
-
|
119
|
+
__Changed__
|
120
|
+
|
86
121
|
- Playlist::Track#seen= removed in favor of Playlist#seen(index, yesno)
|
87
122
|
- Object#error -> Object#status (AlbumBrowse, ArtistBrowse, Search, Toplist, User)
|
88
123
|
- Album#year renamed to Album#release_year
|
89
124
|
- Linkable.from_link/to_link and resulting #from_link are now private
|
90
125
|
|
91
126
|
|
92
|
-
v0.8.0
|
127
|
+
[v0.8.0][]
|
93
128
|
------------------
|
94
|
-
|
129
|
+
|
130
|
+
__Added__
|
131
|
+
|
95
132
|
- Add example for listing track information in playlists
|
96
133
|
- Updated to (lib)Spotify v9
|
97
134
|
- Full Track subsystem support
|
@@ -112,7 +149,8 @@ v0.8.0
|
|
112
149
|
- Allow Image.new to accept an image id
|
113
150
|
- Add Hallon::API_BUILD
|
114
151
|
|
115
|
-
|
152
|
+
__Fixed__
|
153
|
+
|
116
154
|
- Improve speed of Session#wait_for for already-loaded cases
|
117
155
|
- Error.maybe_raise no longer errors out on timeout
|
118
156
|
- from_link now checks for null pointers
|
@@ -120,33 +158,38 @@ v0.8.0
|
|
120
158
|
- Cleaned up specs to use same mocks everywhere
|
121
159
|
- Make Hallon::URI match image URIs
|
122
160
|
|
123
|
-
|
124
|
-
- Ignore Ruby v1.8.x compatibility
|
161
|
+
__Broke__
|
125
162
|
|
163
|
+
- Ignore Ruby v1.8.x compatibility
|
126
164
|
|
127
|
-
v0.3.0
|
165
|
+
[v0.3.0][]
|
128
166
|
------------------
|
167
|
+
|
129
168
|
- Don’t use bundler for :spec and :test rake tasks
|
130
169
|
- Add Error.table
|
131
170
|
- Add Track subsystem
|
132
171
|
- Fix spec:cov and spotify:coverage rake tasks
|
133
172
|
|
134
|
-
v0.2.1
|
173
|
+
[v0.2.1][]
|
135
174
|
------------------
|
175
|
+
|
136
176
|
- Fix compatibility with v1.8
|
137
177
|
|
138
|
-
v0.2.0
|
178
|
+
[v0.2.0][]
|
139
179
|
------------------
|
180
|
+
|
140
181
|
- Alias Session#process_events_on to Session#wait_until
|
141
182
|
- Have Error.maybe_raise return error code
|
142
183
|
- Use mockspotify gem (https://rubygems.org/gems/mockspotify) for testing
|
143
184
|
|
144
|
-
v0.1.1
|
185
|
+
[v0.1.1][]
|
145
186
|
------------------
|
146
|
-
Don’t show the README in the gem description.
|
147
187
|
|
148
|
-
|
188
|
+
- Don’t show the README in the gem description.
|
189
|
+
|
190
|
+
[v0.1.0][]
|
149
191
|
------------------
|
192
|
+
|
150
193
|
Initial, first, release! This version is merely made to
|
151
194
|
have a starting point, a point of reference, for future
|
152
195
|
releases soon to come.
|
@@ -162,3 +205,15 @@ releases soon to come.
|
|
162
205
|
The API is still very young, and I expect a lot of changes to
|
163
206
|
happen to it, to make the asynchronous nature of libspotify
|
164
207
|
easier to handle.
|
208
|
+
|
209
|
+
[v0.1.0]: https://github.com/Burgestrand/Hallon/compare/5f2e118...v0.1.0
|
210
|
+
[v0.1.1]: https://github.com/Burgestrand/Hallon/compare/v0.1.0...v0.1.1
|
211
|
+
[v0.2.0]: https://github.com/Burgestrand/Hallon/compare/v0.1.1...v0.2.0
|
212
|
+
[v0.2.1]: https://github.com/Burgestrand/Hallon/compare/v0.2.0...v0.2.1
|
213
|
+
[v0.3.0]: https://github.com/Burgestrand/Hallon/compare/v0.2.1...v0.3.0
|
214
|
+
[v0.8.0]: https://github.com/Burgestrand/Hallon/compare/v0.3.0...v0.8.0
|
215
|
+
[v0.9.0]: https://github.com/Burgestrand/Hallon/compare/v0.8.0...v0.9.0
|
216
|
+
[v0.9.1]: https://github.com/Burgestrand/Hallon/compare/v0.9.0...v0.9.1
|
217
|
+
[v0.10.1]: https://github.com/Burgestrand/Hallon/compare/v0.9.1...v0.10.1
|
218
|
+
[v0.11.0]: https://github.com/Burgestrand/Hallon/compare/v0.10.1...v0.11.0
|
219
|
+
[v0.12.0]: https://github.com/Burgestrand/Hallon/compare/v0.11.0...v0.12.0
|
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -53,7 +53,7 @@ Versioning policy
|
|
53
53
|
-----------------
|
54
54
|
Hallon uses [semantic versioning](http://semver.org) as of v0.0.0. As long
|
55
55
|
as Hallon stays at major version 0, no guarantees of backwards-compatibility
|
56
|
-
are made. CHANGELOG will be kept up to date with the different versions.
|
56
|
+
are made. `CHANGELOG.md` will be kept up to date with the different versions.
|
57
57
|
|
58
58
|
License
|
59
59
|
-------
|
data/Rakefile
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require 'rake'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
begin
|
5
|
+
require 'bundler'
|
6
|
+
Bundler::GemHelper.install_tasks
|
7
|
+
rescue LoadError
|
8
|
+
# not everybody needs these
|
9
|
+
end
|
6
10
|
|
7
11
|
require 'yard'
|
8
12
|
YARD::Rake::YardocTask.new
|
@@ -68,9 +72,6 @@ task 'spotify:coverage' do
|
|
68
72
|
'wrap_function', # not a spotify function
|
69
73
|
'lookup_return_value', # custom method
|
70
74
|
'define_singleton_method', # overloaded by us
|
71
|
-
'image_remove_load_callback', # cleared when Image is GCd
|
72
|
-
'playlist_remove_callbacks', # cleared when Playlist is GCd
|
73
|
-
'playlistcontainer_remove_callbacks', # cleared when Playlist is GCd
|
74
75
|
]
|
75
76
|
|
76
77
|
covered -= ignored
|
@@ -113,7 +114,8 @@ task 'spotify:coverage' do
|
|
113
114
|
FileList['lib/**/*.rb'].each do |file|
|
114
115
|
begin
|
115
116
|
$file = file
|
116
|
-
|
117
|
+
klass = defined?(Ruby19Parser)? Ruby19Parser : RubyParser
|
118
|
+
ast = klass.new.parse File.read(file)
|
117
119
|
ast.each_of_type(:call) do |_, recv, meth, args, *rest|
|
118
120
|
name = handlers[recv][meth].call(recv, meth, args)
|
119
121
|
covered.subtract Array(name).map(&:to_s)
|
data/examples/logging_in.rb
CHANGED
@@ -0,0 +1,130 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
|
4
|
+
|
5
|
+
require 'hallon'
|
6
|
+
require_relative '../spec/support/config'
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'coreaudio'
|
10
|
+
rescue LoadError
|
11
|
+
abort <<-ERROR
|
12
|
+
This example requires the ruby-coreaudio gem.
|
13
|
+
|
14
|
+
See: http://rubygems.org/gems/coreaudio
|
15
|
+
ERROR
|
16
|
+
end
|
17
|
+
|
18
|
+
# Utility
|
19
|
+
def say(string)
|
20
|
+
system('say', string)
|
21
|
+
end
|
22
|
+
|
23
|
+
def tell(string)
|
24
|
+
puts(string)
|
25
|
+
say(string)
|
26
|
+
end
|
27
|
+
|
28
|
+
def prompt(string)
|
29
|
+
print(string + ': ')
|
30
|
+
$stdout.flush
|
31
|
+
say(string)
|
32
|
+
gets.chomp
|
33
|
+
end
|
34
|
+
|
35
|
+
# Hallon set-up.
|
36
|
+
|
37
|
+
sample_rate = 44100 # 44100 samples / second
|
38
|
+
device = CoreAudio.default_output_device
|
39
|
+
output = device.output_buffer(sample_rate * 3)
|
40
|
+
audio_queue = Hallon::Queue.new(sample_rate)
|
41
|
+
|
42
|
+
session = Hallon::Session.initialize IO.read(ENV['HALLON_APPKEY']) do
|
43
|
+
on(:log_message) do |message|
|
44
|
+
puts "[LOG] #{message}"
|
45
|
+
end
|
46
|
+
|
47
|
+
on(:connection_error) do |error|
|
48
|
+
Hallon::Error.maybe_raise(error)
|
49
|
+
end
|
50
|
+
|
51
|
+
on(:logged_out) do
|
52
|
+
abort "[FAIL] Logged out!"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end_of_track = false
|
57
|
+
player = Hallon::Player.new(session) do
|
58
|
+
on(:music_delivery) do |format, frames|
|
59
|
+
audio_queue.push(frames)
|
60
|
+
end
|
61
|
+
|
62
|
+
on(:start_playback) do
|
63
|
+
puts "(start playback)"
|
64
|
+
output.start
|
65
|
+
end
|
66
|
+
|
67
|
+
on(:stop_playback) do
|
68
|
+
puts "(stop playback)"
|
69
|
+
output.stop
|
70
|
+
end
|
71
|
+
|
72
|
+
on(:get_audio_buffer_stats) do
|
73
|
+
[audio_queue.size, 0]
|
74
|
+
end
|
75
|
+
|
76
|
+
on(:end_of_track) do
|
77
|
+
puts "End of track!"
|
78
|
+
end_of_track = true
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Program flow.
|
83
|
+
|
84
|
+
session.login!(ENV['HALLON_USERNAME'], ENV['HALLON_PASSWORD'])
|
85
|
+
|
86
|
+
search = loop do
|
87
|
+
query = prompt("Enter a search term for a track you’d like to play")
|
88
|
+
search = Hallon::Search.new(query)
|
89
|
+
|
90
|
+
tell "Searching for “#{search.query}”…"
|
91
|
+
session.wait_for do
|
92
|
+
search.loaded? or Hallon::Error.maybe_raise(search.status)
|
93
|
+
end
|
94
|
+
|
95
|
+
if search.tracks.size.zero?
|
96
|
+
tell "No results for “#{search.query}”."
|
97
|
+
next
|
98
|
+
else
|
99
|
+
break search
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
tracks = search.tracks[0...10]
|
104
|
+
session.wait_for { tracks.all?(&:loaded?) }
|
105
|
+
|
106
|
+
tell "Results for “#{search.query}”: "
|
107
|
+
tracks.each_with_index do |track, index|
|
108
|
+
puts " [#{index + 1}] #{track.name} — #{track.artist.name} (#{track.to_link.to_str})"
|
109
|
+
end
|
110
|
+
puts
|
111
|
+
|
112
|
+
track = loop do
|
113
|
+
index = prompt("Choose a track to play (between 1 and #{tracks.size})").to_i
|
114
|
+
|
115
|
+
if track = tracks[index - 1]
|
116
|
+
break track
|
117
|
+
else
|
118
|
+
tell "No such track."
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
player.play(track)
|
123
|
+
|
124
|
+
tell "Alright! Playing “#{track.name}” by “#{track.artist.name}”."
|
125
|
+
|
126
|
+
until end_of_track
|
127
|
+
output << audio_queue.pop(sample_rate)
|
128
|
+
end
|
129
|
+
|
130
|
+
tell "Done! This was “#{track.name}” by “#{track.artist.name}”. Bye bye!"
|
@@ -1,21 +1,13 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
#
|
3
3
|
# DISCLAIMER:
|
4
|
-
# This file was written without extensive testing, and is merely
|
5
|
-
#
|
4
|
+
# This file was written without extensive testing, and is merely an
|
5
|
+
# example. Before using this yourself, I advice you to look through
|
6
6
|
# the code carefully.
|
7
7
|
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# Hallon API in this file is only used for:
|
12
|
-
# - logging in
|
13
|
-
# - querying track information
|
14
|
-
#
|
15
|
-
# Raw Spotify FFI API is used for:
|
16
|
-
# - fetching playlist container
|
17
|
-
# - fetching playlists
|
18
|
-
# - fetching tracks from playlists
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
|
10
|
+
|
19
11
|
require 'hallon'
|
20
12
|
require './spec/support/config'
|
21
13
|
|