Class: RSpotify::Episode

Inherits:
Base
  • Object
show all
Defined in:
lib/rspotify/episode.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#external_urls, #id, #type, #uri

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#complete!, #embed, #method_missing, #respond_to?

Constructor Details

#initialize(options = {}) ⇒ Episode

Returns a new instance of Episode.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rspotify/episode.rb', line 58

def initialize(options = {})
  @audio_preview_url = options['audio_preview_url']
  @description       = options['description']
  @duration_ms       = options['duration_ms']
  @explicit          = options['explicit']
  @href              = options['href']
  @html_description  = options['html_description']
  @images            = options['images']
  @is_externally_hosted = options['is_externally_hosted']
  @is_playable       = options['is_playable']
  @language          = options['language']
  @languages         = options['languages']
  @name              = options['name']
  @release_date      = options['release_date']
  @release_date_precision = options['release_date_precision']
  @restrictions      = options['restrictions'] || {}
  @resume_point      = options['resume_point'] || {}
  @uri               = options['uri']

  @show = if options['show']
    Show.new options['show']
  end

  super(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RSpotify::Base

Instance Attribute Details

#audio_preview_urlString

A URL to a 30 second preview (MP3 format) of the episode. null if not available.

Returns:

  • (String)

    the current value of audio_preview_url



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def audio_preview_url
  @audio_preview_url
end

#descriptionString

A description of the episode. HTML tags are stripped away from this field, use html_description field in case HTML tags are needed.

Returns:

  • (String)

    the current value of description



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def description
  @description
end

#duration_msInteger

The episode length in milliseconds.

Returns:

  • (Integer)

    the current value of duration_ms



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def duration_ms
  @duration_ms
end

#explicitBoolean

Whether or not the episode has explicit content (true = yes it does; false = no it does not OR unknown).

Returns:

  • (Boolean)

    the current value of explicit



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def explicit
  @explicit
end

#hrefString

A link to the Web API endpoint providing full details of the episode.

Returns:

  • (String)

    the current value of href



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def href
  @href
end

#html_descriptionString

A description of the episode. This field may contain HTML tags.

Returns:

  • (String)

    the current value of html_description



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def html_description
  @html_description
end

#imagesArray<Hash>

The cover art for the episode in various sizes, widest first.

Returns:

  • (Array<Hash>)

    the current value of images



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def images
  @images
end

#is_externally_hostedBoolean

True if the episode is hosted outside of Spotify’s CDN.

Returns:

  • (Boolean)

    the current value of is_externally_hosted



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def is_externally_hosted
  @is_externally_hosted
end

#is_playableBoolean

True if the episode is playable in the given market. Otherwise false.

Returns:

  • (Boolean)

    the current value of is_playable



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def is_playable
  @is_playable
end

#languageString

The language used in the episode, identified by a ISO 639 code. This field is deprecated and might be removed in the future. Please use the languages field instead.

Returns:

  • (String)

    the current value of language



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def language
  @language
end

#languagesArray<String>

A list of the languages used in the episode, identified by their ISO 639-1 code.

Returns:

  • (Array<String>)

    the current value of languages



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def languages
  @languages
end

#nameString

The name of the episode.

Returns:

  • (String)

    the current value of name



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def name
  @name
end

#release_dateString

The date the episode was first released, for example “1981-12-15”. Depending on the precision, it might be shown as “1981” or “1981-12”.

Returns:

  • (String)

    the current value of release_date



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def release_date
  @release_date
end

#release_date_precisionString

The precision with which release_date value is known.

Returns:

  • (String)

    the current value of release_date_precision



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def release_date_precision
  @release_date_precision
end

#restrictionsHash

Included in the response when a content restriction is applied.

Returns:

  • (Hash)

    the current value of restrictions



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def restrictions
  @restrictions
end

#resume_pointHash

The user’s most recent position in the episode. Set if the supplied access token is a user token and has the scope ‘user-read-playback-position’.

Returns:

  • (Hash)

    the current value of resume_point



19
20
21
# File 'lib/rspotify/episode.rb', line 19

def resume_point
  @resume_point
end

Class Method Details

.find(ids, market: nil) ⇒ Episode+

Returns Episode object(s) with id(s) provided

Examples:

episode = RSpotify::Episode.find('512ojhOuo1ktJprKbVcKyQ')
episode.class #=> RSpotify::Episode
episode.name  #=> "Do I Wanna Know?"

ids = %w(512ojhOuo1ktJprKbVcKyQ 15tHEpY9pwbKC0QjpYCRB1)
episodes = RSpotify::Base.find(ids, 'episode')
episodes.class       #=> Array
episodes.first.class #=> RSpotify::Episode

Parameters:

Returns:



36
37
38
# File 'lib/rspotify/episode.rb', line 36

def self.find(ids, market: nil)
  super(ids, 'episode', market: market)
end

.search(query, limit: 20, offset: 0, market: nil) ⇒ Array<Episode>

Returns array of Episode objects matching the query. It’s also possible to find the total number of search results for the query

Examples:

episodes = RSpotify::Episode.search('Vetenskapsradion Historia')
episodes = RSpotify::Episode.search('Vetenskapsradion Historia', limit: 10, market: 'US')
episodes = RSpotify::Episode.search('Vetenskapsradion Historia', market: { from: user })

RSpotify::Episode.search('Vetenskapsradion Historia').total #=> 711

Parameters:

  • query (String)

    The search query’s keywords. For details access here and look for the q parameter description.

  • limit (Integer) (defaults to: 20)

    Maximum number of episodes to return. Maximum: 50. Default: 20.

  • offset (Integer) (defaults to: 0)

    The index of the first episode to return. Use with limit to get the next set of episodes. Default: 0.

  • market (String, Hash) (defaults to: nil)

    Optional. An ISO 3166-1 alpha-2 country code or the hash { from: user }, where user is a RSpotify user authenticated using OAuth with scope user-read-private. This will take the user’s country as the market value. For details access here and look for the market parameter description.

Returns:



54
55
56
# File 'lib/rspotify/episode.rb', line 54

def self.search(query, limit: 20, offset: 0, market: nil )
  super(query, 'episode', limit: limit, offset: offset, market: market)
end