module GoogleMusicApi::Station

Public Instance Methods

create_station() click to toggle source
# File lib/google_music_api/station.rb, line 55
def create_station
  throw NotImplementedError.new
end
delete_station() click to toggle source
# File lib/google_music_api/station.rb, line 59
def delete_station
  throw NotImplementedError.new
end
get_all_stations() click to toggle source

Gets all radio stations It seems to be tied to what the user @return [Array] of radios stations

# File lib/google_music_api/station.rb, line 19
def get_all_stations
  url = 'radio/station'
  options = {query: {'alt': 'json', 'tier': 'aa', 'hl': 'en_US'}}

  make_post_request(url, options)
end
get_im_feeling_lucky_tracks(number_of_tracks = 25, recently_played = []) click to toggle source

Gets I'm feeling lucky station tracks

@param [integer] number_of_tracks
@param [Array] recently_played track ids
@return [Array] of tracks
# File lib/google_music_api/station.rb, line 51
def get_im_feeling_lucky_tracks(number_of_tracks = 25, recently_played = [])
  get_station_tracks 'IFL', number_of_tracks, recently_played
end
get_listen_now_situations() click to toggle source

Gets the current listen now situations and their associated stations

@return [Array] of situations and their respected stations
# File lib/google_music_api/station.rb, line 6
def get_listen_now_situations
  url = 'listennow/situations'
  options = {query: {'alt': 'json', 'tier': 'aa', 'hl': 'en_US'}}

  body = {'requestSignals': {'timeZoneOffsetSecs': Time.now.gmt_offset}}.to_json

  options[:body] = body
  make_post_request(url, options)['situations']
end
get_station_tracks(station_id, number_of_tracks = 25, recently_played = []) click to toggle source

Gets a station's tracks @param [string] station_id @param [integer] number_of_tracks @param [Array] recently_played track ids @return [Array] of tracks

# File lib/google_music_api/station.rb, line 31
def get_station_tracks(station_id, number_of_tracks = 25, recently_played = [])
  url = 'radio/stationfeed'
  options = {query: {'alt': 'json', 'include-tracks': 'true', 'tier': 'aa', 'hl': 'en_US'}}

  options[:body] = {'contentFilter': 1,
                    'stations': [
                        {
                            'numEntries': number_of_tracks,
                            'radioId': station_id,
                            'recentlyPlayed': recently_played.map { |rec| add_track_type rec }
                        }
                    ]}.to_json

  make_post_request(url, options)['data']['stations']
end