hallon 0.18.0 → 0.18.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.
Files changed (65) hide show
  1. data/.rspec +1 -1
  2. data/CHANGELOG.md +12 -1
  3. data/README.markdown +13 -5
  4. data/Rakefile +23 -74
  5. data/examples/example_support.rb +2 -0
  6. data/hallon.gemspec +1 -1
  7. data/lib/hallon.rb +1 -6
  8. data/lib/hallon/album.rb +4 -4
  9. data/lib/hallon/album_browse.rb +6 -6
  10. data/lib/hallon/artist.rb +3 -3
  11. data/lib/hallon/artist_browse.rb +9 -9
  12. data/lib/hallon/audio_queue.rb +2 -1
  13. data/lib/hallon/base.rb +10 -10
  14. data/lib/hallon/enumerator.rb +3 -3
  15. data/lib/hallon/ext/spotify.rb +1 -47
  16. data/lib/hallon/image.rb +4 -4
  17. data/lib/hallon/link.rb +4 -4
  18. data/lib/hallon/linkable.rb +10 -10
  19. data/lib/hallon/observable/playlist.rb +2 -3
  20. data/lib/hallon/observable/playlist_container.rb +3 -12
  21. data/lib/hallon/player.rb +2 -2
  22. data/lib/hallon/playlist.rb +6 -6
  23. data/lib/hallon/playlist_container.rb +8 -8
  24. data/lib/hallon/scrobbler.rb +4 -4
  25. data/lib/hallon/search.rb +20 -5
  26. data/lib/hallon/session.rb +18 -17
  27. data/lib/hallon/toplist.rb +4 -4
  28. data/lib/hallon/track.rb +5 -5
  29. data/lib/hallon/user.rb +7 -7
  30. data/lib/hallon/version.rb +1 -1
  31. data/spec/hallon/album_browse_spec.rb +1 -1
  32. data/spec/hallon/artist_browse_spec.rb +1 -1
  33. data/spec/hallon/base_spec.rb +6 -3
  34. data/spec/hallon/enumerator_spec.rb +2 -2
  35. data/spec/hallon/hallon_spec.rb +0 -4
  36. data/spec/hallon/link_spec.rb +1 -1
  37. data/spec/hallon/linkable_spec.rb +4 -4
  38. data/spec/hallon/observable/playlist_container_spec.rb +3 -3
  39. data/spec/hallon/observable/playlist_spec.rb +1 -1
  40. data/spec/hallon/player_spec.rb +9 -9
  41. data/spec/hallon/playlist_container_spec.rb +2 -2
  42. data/spec/hallon/playlist_spec.rb +8 -8
  43. data/spec/hallon/scrobbler_spec.rb +8 -7
  44. data/spec/hallon/search_spec.rb +3 -3
  45. data/spec/hallon/session_spec.rb +10 -10
  46. data/spec/hallon/toplist_spec.rb +4 -4
  47. data/spec/hallon/track_spec.rb +6 -6
  48. data/spec/hallon/user_post_spec.rb +1 -1
  49. data/spec/hallon/user_spec.rb +1 -1
  50. data/spec/mockspotify.rb +36 -42
  51. data/spec/mockspotify/mockspotify_spec.rb +15 -15
  52. data/spec/spec_helper.rb +25 -21
  53. data/spec/support/album_mocks.rb +4 -4
  54. data/spec/support/artist_mocks.rb +5 -5
  55. data/spec/support/image_mocks.rb +4 -4
  56. data/spec/support/playlist_container_mocks.rb +4 -4
  57. data/spec/support/playlist_mocks.rb +6 -6
  58. data/spec/support/search_mocks.rb +2 -2
  59. data/spec/support/session_mocks.rb +1 -1
  60. data/spec/support/shared_for_callbacks.rb +1 -1
  61. data/spec/support/shared_for_linkable_objects.rb +3 -2
  62. data/spec/support/toplist_mocks.rb +2 -2
  63. data/spec/support/track_mocks.rb +4 -4
  64. data/spec/support/user_mocks.rb +2 -2
  65. metadata +5 -5
@@ -8,7 +8,7 @@ module Hallon
8
8
  class Enumerator
9
9
  include Enumerable
10
10
 
11
- # @return [Spotify::Pointer]
11
+ # @return [Spotify::ManagedPointer]
12
12
  attr_reader :pointer
13
13
 
14
14
  # @macro [attach] size
@@ -26,7 +26,7 @@ module Hallon
26
26
  end
27
27
 
28
28
  # @example modifying result with a block
29
- # item :playlist_track! do |track|
29
+ # item :playlist_track do |track|
30
30
  # Track.from(track)
31
31
  # end
32
32
  #
@@ -35,7 +35,7 @@ module Hallon
35
35
  # @yield [item, index, pointer] item from calling Spotify#item_method
36
36
  # @yieldparam item
37
37
  # @yieldparam [Integer] index
38
- # @yieldparam [Spotify::Pointer] pointer
38
+ # @yieldparam [Spotify::ManagedPointer] pointer
39
39
  #
40
40
  # @macro [attach] item
41
41
  # @method at(index)
@@ -2,54 +2,8 @@
2
2
 
3
3
  # Extensions to the Spotify gem.
4
4
  #
5
- # @see https://github.com/Burgestrand/libspotify-ruby
5
+ # @see https://github.com/Burgestrand/spotify
6
6
  module Spotify
7
- # Extensions to SessionConfig, allowing more sensible configuration names.
8
- SessionConfig.class_eval do
9
- [:cache_location, :settings_location, :user_agent, :device_id, :proxy, :proxy_username, :proxy_password, :tracefile].each do |field|
10
- method = field.to_s.gsub('location', 'path')
11
-
12
- define_method(:"#{method}") { self[field].read_string }
13
- define_method(:"#{method}=") do |string|
14
- string &&= FFI::MemoryPointer.from_string(string)
15
- self[field] = string
16
- end
17
- end
18
-
19
- # @note Also sets application_key_size.
20
- # @param [#to_s]
21
- def application_key=(appkey)
22
- self[:application_key] = FFI::MemoryPointer.from_string(appkey)
23
- self[:application_key_size] = appkey.bytesize
24
- end
25
-
26
- # Allows setting compress_playlists using a boolean.
27
- #
28
- # @param [Boolean]
29
- # @return [Boolean]
30
- def compress_playlists=(bool)
31
- self[:compress_playlists] = !! bool
32
- end
33
-
34
- # Allows setting initially_unload_playlists using a boolean.
35
- #
36
- # @note Set to the inverse of the requested value.
37
- # @param [Boolean]
38
- # @return [Boolean]
39
- def load_playlists=(bool)
40
- self[:initially_unload_playlists] = ! bool
41
- end
42
-
43
- # Allows setting dont_save_metadata_for_playlists using a boolean.
44
- #
45
- # @note Set to the inverse of the requested value.
46
- # @param [Boolean]
47
- # @return [Boolean]
48
- def cache_playlist_metadata=(bool)
49
- self[:dont_save_metadata_for_playlists] = ! bool
50
- end
51
- end
52
-
53
7
  # Makes it easier binding callbacks safely to callback structs.
54
8
  #
55
9
  # @see add
@@ -7,7 +7,7 @@ module Hallon
7
7
  include Linkable
8
8
 
9
9
  from_link :as_image do |link|
10
- Spotify.image_create_from_link!(session.pointer, link)
10
+ Spotify.image_create_from_link(session.pointer, link)
11
11
  end
12
12
 
13
13
  to_link :from_image
@@ -31,14 +31,14 @@ module Hallon
31
31
  # @example from an image id
32
32
  # image = Hallon::Image.new("3ad93423add99766e02d563605c6e76ed2b0e450")
33
33
  #
34
- # @param [String, Link, Spotify::Pointer] link link or image id
34
+ # @param [String, Link, Spotify::Image] link link or image id
35
35
  def initialize(link)
36
36
  if link.respond_to?(:=~) and link =~ %r~(?:image[:/]|\A)([a-fA-F0-9]{40})\z~
37
37
  link = to_id($1)
38
38
  end
39
39
 
40
- @pointer = to_pointer(link, :image) do
41
- Spotify.image_create!(session.pointer, link)
40
+ @pointer = to_pointer(link, Spotify::Image) do
41
+ Spotify.image_create(session.pointer, link)
42
42
  end
43
43
 
44
44
  subscribe_for_callbacks do |callbacks|
@@ -19,7 +19,7 @@ module Hallon
19
19
  return false
20
20
  end
21
21
 
22
- link = Spotify.link_create_from_string!(spotify_uri.to_s)
22
+ link = Spotify.link_create_from_string(spotify_uri.to_s)
23
23
  not link.null?
24
24
  end
25
25
 
@@ -38,8 +38,8 @@ module Hallon
38
38
  uri = uri.to_link.pointer
39
39
  end
40
40
 
41
- @pointer = to_pointer(uri, :link) do
42
- Spotify.link_create_from_string!(uri.to_str)
41
+ @pointer = to_pointer(uri, Spotify::Link) do
42
+ Spotify.link_create_from_string(uri.to_str)
43
43
  end
44
44
  end
45
45
 
@@ -87,7 +87,7 @@ module Hallon
87
87
  end
88
88
 
89
89
  # @param [Symbol] expected_type if given, makes sure the link is of this type
90
- # @return [Spotify::Pointer] the underlying Spotify::Pointer.
90
+ # @return [Spotify::ManagedPointer] the underlying Spotify::ManagedPointer.
91
91
  # @raise ArgumentError if `type` is given and does not match link {#type}
92
92
  def pointer(expected_type = nil)
93
93
  unless type == expected_type or (expected_type == :playlist and type == :starred)
@@ -26,11 +26,11 @@ module Hallon
26
26
  # from_link :as_album # => Spotify.link_as_album(pointer, *args)
27
27
  # # ^ is roughly equivalent to:
28
28
  # def from_link(link, *args)
29
- # unless Spotify::Pointer.typechecks?(link, :link)
29
+ # unless link.is_a?(Spotify::Link)
30
30
  # link = Link.new(link).pointer(:album)
31
31
  # end
32
32
  #
33
- # Spotify.link_as_album!(link)
33
+ # Spotify.link_as_album(link)
34
34
  # end
35
35
  # end
36
36
  #
@@ -46,30 +46,30 @@ module Hallon
46
46
  # include Linkable
47
47
  #
48
48
  # from_link :profile do |pointer|
49
- # Spotify.link_as_user!(pointer)
49
+ # Spotify.link_as_user(pointer)
50
50
  # end
51
51
  # # ^ is roughly equivalent to:
52
52
  # def from_link(link, *args)
53
- # unless Spotify::Pointer.typechecks?(link, :link)
53
+ # unless link.is_a?(Spotify::Link)
54
54
  # link = Link.new(link).pointer(:profile)
55
55
  # end
56
56
  #
57
- # Spotify.link_as_user!(link)
57
+ # Spotify.link_as_user(link)
58
58
  # end
59
59
  # end
60
60
  #
61
61
  # @param [#to_s] type link type
62
62
  # @yield [link, *args] called when conversion is needed from Link pointer
63
- # @yieldparam [Spotify::Pointer] link
63
+ # @yieldparam [Spotify::Link] link
64
64
  # @yieldparam *args any extra arguments given to `#from_link`
65
65
  #
66
66
  # @note Private API. You probably do not need to care about this method.
67
67
  def from_link(as_object, &block)
68
- block ||= Spotify.method(:"link_#{as_object}!")
68
+ block ||= Spotify.method(:"link_#{as_object}")
69
69
  type = as_object.to_s[/^(as_)?([^_]+)/, 2].to_sym
70
70
 
71
71
  define_method(:from_link) do |link, *args|
72
- unless Spotify::Pointer.typechecks?(link, :link)
72
+ unless link.is_a?(Spotify::Link)
73
73
  link = Link.new(link).pointer(type)
74
74
  end
75
75
 
@@ -88,7 +88,7 @@ module Hallon
88
88
  # to_link :from_artist
89
89
  # # ^ is the same as:
90
90
  # def to_link(*args)
91
- # link = Spotify.link_create_from_artist!(pointer, *args)
91
+ # link = Spotify.link_create_from_artist(pointer, *args)
92
92
  # Link.new(link)
93
93
  # end
94
94
  # end
@@ -97,7 +97,7 @@ module Hallon
97
97
  # @return [Link, nil]
98
98
  def to_link(cmethod)
99
99
  define_method(:to_link) do |*args|
100
- link = Spotify.__send__(:"link_create_#{cmethod}!", pointer, *args)
100
+ link = Spotify.__send__(:"link_create_#{cmethod}", pointer, *args)
101
101
  Link.from(link)
102
102
  end
103
103
  end
@@ -27,7 +27,7 @@ module Hallon::Observable
27
27
  # @yieldparam [Integer] position
28
28
  def tracks_added_callback(pointer, tracks, num_tracks, position, userdata)
29
29
  tracks_ary = tracks.read_array_of_pointer(num_tracks).map do |track|
30
- ptr = Spotify::Pointer.new(track, :track, true)
30
+ ptr = Spotify::Track.retaining_class.new(track)
31
31
  Hallon::Track.new(ptr)
32
32
  end
33
33
 
@@ -109,8 +109,7 @@ module Hallon::Observable
109
109
  # @yieldparam [User] user
110
110
  # @yieldparam [Time] created_at
111
111
  def track_created_changed_callback(pointer, position, user, created_at, userdata)
112
- user = Spotify::Pointer.new(user, :user, true)
113
- trigger(pointer, :track_created_changed, position, Hallon::User.new(user), Time.at(created_at))
112
+ trigger(pointer, :track_created_changed, position, Hallon::User.from(user), Time.at(created_at))
114
113
  end
115
114
 
116
115
  # @example listening to this event
@@ -26,7 +26,7 @@ module Hallon::Observable
26
26
  # @yieldparam [Playlist] playlist
27
27
  # @yieldparam [Integer] position
28
28
  def playlist_added_callback(pointer, playlist, position, userdata)
29
- trigger(pointer, :playlist_added, playlist_from(playlist), position)
29
+ trigger(pointer, :playlist_added, Hallon::Playlist.from(playlist), position)
30
30
  end
31
31
 
32
32
  # @example listening to this event
@@ -38,7 +38,7 @@ module Hallon::Observable
38
38
  # @yieldparam [Playlist] playlist
39
39
  # @yieldparam [Integer] position
40
40
  def playlist_removed_callback(pointer, playlist, position, userdata)
41
- trigger(pointer, :playlist_removed, playlist_from(playlist), position)
41
+ trigger(pointer, :playlist_removed, Hallon::Playlist.from(playlist), position)
42
42
  end
43
43
 
44
44
  # @example listening to this event
@@ -51,7 +51,7 @@ module Hallon::Observable
51
51
  # @yieldparam [Integer] position
52
52
  # @yieldparam [Integer] new_position
53
53
  def playlist_moved_callback(pointer, playlist, position, new_position, userdata)
54
- trigger(pointer, :playlist_moved, playlist_from(playlist), position, new_position)
54
+ trigger(pointer, :playlist_moved, Hallon::Playlist.from(playlist), position, new_position)
55
55
  end
56
56
 
57
57
  # @example listening to this event
@@ -63,14 +63,5 @@ module Hallon::Observable
63
63
  def container_loaded_callback(pointer, userdata)
64
64
  trigger(pointer, :container_loaded)
65
65
  end
66
-
67
- protected
68
-
69
- # @param [Spotify::Pointer] playlist
70
- # @return [Hallon::Playlist] a playlist for the given pointer.
71
- def playlist_from(playlist)
72
- pointer = Spotify::Pointer.new(playlist, :playlist, true)
73
- Hallon::Playlist.new(pointer)
74
- end
75
66
  end
76
67
  end
@@ -10,7 +10,7 @@ module Hallon
10
10
  # meep?
11
11
  extend Observable::Player
12
12
 
13
- # @return [Spotify::Pointer<Session>] session pointer
13
+ # @return [Spotify::Session] session pointer
14
14
  attr_reader :pointer
15
15
 
16
16
  # @return [Symbol] one of :playing, :paused, :stopped
@@ -208,7 +208,7 @@ module Hallon
208
208
  # @raise [Spotify::Error] if libspotify does not accept the given bitrate
209
209
  # @param [Symbol] bitrate one of :96k, :160k, :320k
210
210
  def bitrate=(bitrate)
211
- Spotify.session_preferred_bitrate!(pointer, bitrate)
211
+ Spotify.try(:session_preferred_bitrate, pointer, bitrate)
212
212
  end
213
213
 
214
214
  # Loads a Track for playing.
@@ -11,7 +11,7 @@ module Hallon
11
11
  size :playlist_num_tracks
12
12
 
13
13
  # @return [Track, nil]
14
- item :playlist_track! do |track, index, pointer|
14
+ item :playlist_track do |track, index, pointer|
15
15
  Playlist::Track.from(track, pointer, index)
16
16
  end
17
17
  end
@@ -33,12 +33,12 @@ module Hallon
33
33
  @seen = Spotify.playlist_track_seen(playlist_ptr, index)
34
34
  @added_at = Time.at(Spotify.playlist_track_create_time(playlist_ptr, index)).utc
35
35
  @adder = begin
36
- creator = Spotify.playlist_track_creator!(playlist_ptr, index)
36
+ creator = Spotify.playlist_track_creator(playlist_ptr, index)
37
37
  User.from(creator)
38
38
  end
39
39
  end
40
40
 
41
- # @return [Spotify::Pointer<Playlist>] playlist pointer this track was created from.
41
+ # @return [Spotify::Playlist] playlist pointer this track was created from.
42
42
  attr_reader :playlist_ptr
43
43
  private :playlist_ptr
44
44
 
@@ -99,7 +99,7 @@ module Hallon
99
99
  extend Observable::Playlist
100
100
 
101
101
  from_link :playlist do |pointer|
102
- Spotify.playlist_create!(session.pointer, pointer)
102
+ Spotify.playlist_create(session.pointer, pointer)
103
103
  end
104
104
 
105
105
  to_link :from_playlist
@@ -126,7 +126,7 @@ module Hallon
126
126
  #
127
127
  # @param [String, Link, FFI::Pointer] link
128
128
  def initialize(link)
129
- @pointer = to_pointer(link, :playlist)
129
+ @pointer = to_pointer(link, Spotify::Playlist)
130
130
 
131
131
  subscribe_for_callbacks do |callbacks|
132
132
  Spotify.playlist_remove_callbacks(pointer, callbacks, nil)
@@ -227,7 +227,7 @@ module Hallon
227
227
 
228
228
  # @return [User, nil]
229
229
  def owner
230
- user = Spotify.playlist_owner!(pointer)
230
+ user = Spotify.playlist_owner(pointer)
231
231
  User.from(user)
232
232
  end
233
233
 
@@ -16,7 +16,7 @@ module Hallon
16
16
  item :playlistcontainer_playlist_type do |type, index, pointer|
17
17
  case type
18
18
  when :playlist
19
- playlist = Spotify.playlistcontainer_playlist!(pointer, index)
19
+ playlist = Spotify.playlistcontainer_playlist(pointer, index)
20
20
  Playlist.from(playlist)
21
21
  when :start_folder, :end_folder
22
22
  Folder.new(pointer, folder_range(index, type))
@@ -72,7 +72,7 @@ module Hallon
72
72
  # @return [String]
73
73
  attr_reader :name
74
74
 
75
- # @return [Spotify::Pointer<Container>]
75
+ # @return [Spotify::Container]
76
76
  attr_reader :container_ptr
77
77
  private :container_ptr
78
78
 
@@ -138,9 +138,9 @@ module Hallon
138
138
 
139
139
  # Wrap an existing PlaylistContainer pointer in an object.
140
140
  #
141
- # @param [Spotify::Pointer] pointer
141
+ # @param [Spotify::PlaylistContainer] pointer
142
142
  def initialize(pointer)
143
- @pointer = to_pointer(pointer, :playlistcontainer)
143
+ @pointer = to_pointer(pointer, Spotify::PlaylistContainer)
144
144
 
145
145
  subscribe_for_callbacks do |callbacks|
146
146
  Spotify.playlistcontainer_remove_callbacks(pointer, callbacks, nil)
@@ -155,7 +155,7 @@ module Hallon
155
155
 
156
156
  # @return [User, nil] owner of the container (nil if unknown or no owner).
157
157
  def owner
158
- owner = Spotify.playlistcontainer_owner!(pointer)
158
+ owner = Spotify.playlistcontainer_owner(pointer)
159
159
  User.from(owner)
160
160
  end
161
161
 
@@ -196,13 +196,13 @@ module Hallon
196
196
  def add(playlist, force_create = false)
197
197
  resource = if force_create or not Link.valid?(playlist) and playlist.is_a?(String)
198
198
  unless error = Playlist.invalid_name?(playlist)
199
- Spotify.playlistcontainer_add_new_playlist!(pointer, playlist)
199
+ Spotify.playlistcontainer_add_new_playlist(pointer, playlist)
200
200
  else
201
201
  raise ArgumentError, error
202
202
  end
203
203
  else
204
204
  link = Link.new(playlist)
205
- Spotify.playlistcontainer_add_playlist!(pointer, link.pointer)
205
+ Spotify.playlistcontainer_add_playlist(pointer, link.pointer)
206
206
  end
207
207
 
208
208
  Playlist.from(resource)
@@ -310,7 +310,7 @@ module Hallon
310
310
  real_count = Spotify.playlistcontainer_get_unseen_tracks(pointer, playlist.pointer, tracks_ary, count)
311
311
  raise OperationFailedError if real_count < 0
312
312
  tracks_ary.read_array_of_pointer([real_count, count].min).map do |track|
313
- track_pointer = Spotify::Pointer.new(track, :track, true)
313
+ track_pointer = Spotify::Track.retaining_class.new(track)
314
314
  Hallon::Track.new(track_pointer)
315
315
  end
316
316
  end
@@ -44,7 +44,7 @@ module Hallon
44
44
  true
45
45
  else
46
46
  FFI::Buffer.alloc_out(:bool) do |buffer|
47
- Spotify.session_is_scrobbling_possible!(session.pointer, provider, buffer)
47
+ Spotify.try(:session_is_scrobbling_possible, session.pointer, provider, buffer)
48
48
  return ! buffer.read_uchar.zero?
49
49
  end
50
50
  end
@@ -58,7 +58,7 @@ module Hallon
58
58
  # @param [Array<Username, Password>] credentials
59
59
  def credentials=(credentials)
60
60
  username, password = Array(credentials)
61
- Spotify.session_set_social_credentials!(session.pointer, provider, username, password)
61
+ Spotify.try(:session_set_social_credentials, session.pointer, provider, username, password)
62
62
  end
63
63
 
64
64
  # Enables or disables the local scrobbling setting.
@@ -66,7 +66,7 @@ module Hallon
66
66
  # @param [Boolean] scrobble true if you want scrobbling to be enabled
67
67
  def enabled=(scrobble)
68
68
  state = scrobble ? :local_enabled : :local_disabled
69
- Spotify.session_set_scrobbling!(session.pointer, provider, state)
69
+ Spotify.try(:session_set_scrobbling, session.pointer, provider, state)
70
70
  end
71
71
 
72
72
  # @return [Boolean] true if scrobbling (global or local) is enabled.
@@ -82,7 +82,7 @@ module Hallon
82
82
  #
83
83
  # @return [Scrobbler]
84
84
  def reset
85
- tap { Spotify.session_set_scrobbling!(session.pointer, provider, :use_global_setting) }
85
+ tap { Spotify.try(:session_set_scrobbling, session.pointer, provider, :use_global_setting) }
86
86
  end
87
87
 
88
88
  protected
@@ -12,7 +12,7 @@ module Hallon
12
12
  size :search_num_tracks
13
13
 
14
14
  # @return [Track, nil]
15
- item :search_track! do |track|
15
+ item :search_track do |track|
16
16
  Track.from(track)
17
17
  end
18
18
 
@@ -27,7 +27,7 @@ module Hallon
27
27
  size :search_num_albums
28
28
 
29
29
  # @return [Album, nil]
30
- item :search_album! do |album|
30
+ item :search_album do |album|
31
31
  Album.from(album)
32
32
  end
33
33
 
@@ -42,7 +42,7 @@ module Hallon
42
42
  size :search_num_artists
43
43
 
44
44
  # @return [Artist, nil]
45
- item :search_artist! do |artist|
45
+ item :search_artist do |artist|
46
46
  Artist.from(artist)
47
47
  end
48
48
 
@@ -125,6 +125,21 @@ module Hallon
125
125
 
126
126
  # Construct a new search with given query.
127
127
  #
128
+ # Given enough results for a given query, all searches are paginated by libspotify.
129
+ # If the current number of results (say `search.tracks.size`) is less than the total
130
+ # number of results (`search.tracks.total`), there are more results available. To
131
+ # retrieve the additional tracks, you’ll need to do the same search query again, but
132
+ # with a higher `tracks_offset`.
133
+ #
134
+ # @example searching tracks by offset
135
+ # search = Hallon::Search.new("genre:rock", tracks: 10, tracks_offset: 0).load
136
+ # search.tracks.size # => 10
137
+ # search.tracks.total # => 17
138
+ #
139
+ # again = Hallon::Search.new("genre:rock", tracks: 10, tracks_offset: 10).load
140
+ # again.tracks.size # => 7
141
+ # again.tracks.total # => 17
142
+ #
128
143
  # @param [String, Link] search search query or spotify URI
129
144
  # @param [Hash] options additional search options
130
145
  # @option options [Symbol] :type (:standard) search type, either standard or suggest
@@ -144,10 +159,10 @@ module Hallon
144
159
  search = from_link(search) if Link.valid?(search)
145
160
 
146
161
  subscribe_for_callbacks do |callback|
147
- @pointer = if Spotify::Pointer.typechecks?(search, :search)
162
+ @pointer = if search.is_a?(Spotify::Search)
148
163
  search
149
164
  else
150
- Spotify.search_create!(session.pointer, search, *opts, type, callback, nil)
165
+ Spotify.search_create(session.pointer, search, *opts, type, callback, nil)
151
166
  end
152
167
 
153
168
  raise ArgumentError, "search with #{search} failed" if @pointer.null?