Class: Ayadn::NowPlaying
- Inherits:
-
Object
- Object
- Ayadn::NowPlaying
- Defined in:
- lib/ayadn/nowplaying.rb
Instance Method Summary collapse
-
#initialize(api, view, workers) ⇒ NowPlaying
constructor
A new instance of NowPlaying.
- #itunes(options) ⇒ Object
- #lastfm(options) ⇒ Object
Constructor Details
#initialize(api, view, workers) ⇒ NowPlaying
Returns a new instance of NowPlaying.
8 9 10 11 12 |
# File 'lib/ayadn/nowplaying.rb', line 8 def initialize api, view, workers @api = api @view = view @workers = workers end |
Instance Method Details
#itunes(options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ayadn/nowplaying.rb', line 29 def itunes begin abort(Status.error_only_osx) unless Settings.config[:platform] =~ /darwin/ puts Status.fetching_from('iTunes') itunes = get_itunes_track_infos() itunes.each {|el| abort(Status.empty_fields) if el.length == 0} puts Status.itunes_store store = itunes_istore_request(itunes) unless ['no_url'] text_to_post = "#nowplaying\n \nTitle: ‘#{itunes.track}’\nArtist: #{itunes.artist}\nfrom ‘#{itunes.album}’" (text_to_post, store, ) rescue => e puts Status.wtf Errors.global_error({error: e, caller: caller, data: [itunes, store, ]}) end end |
#lastfm(options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ayadn/nowplaying.rb', line 14 def lastfm begin user = Settings.[:nowplaying][:lastfm] || create_lastfm_user() puts Status.fetching_from('Last.fm') artist, track = get_lastfm_track_infos(user) puts Status.itunes_store store = lastfm_istore_request(artist, track) unless ['no_url'] text_to_post = "#nowplaying\n \nTitle: ‘#{track}’\nArtist: #{artist}" (text_to_post, store, ) rescue => e puts Status.wtf Errors.global_error({error: e, caller: caller, data: [store, ]}) end end |