]> git.r.bdr.sh - rbdr/lyricli.rb/blame - lib/lyricli/sources/itunes.rb
Integrates iTunes source
[rbdr/lyricli.rb] / lib / lyricli / sources / itunes.rb
CommitLineData
6f33706c
BB
1module Lyricli
2 module Sources
3 class Itunes
4
5 class << self
6 attr_accessor :name
7 end
8
9 @name = "itunes"
10
11 # The enable method should run all of the tasks needed to validate
12 # the source. In the case of Rdio it has to authenticate with OAuth.
13 def self.enable
14 # Nothing to do
15 end
16
17 # Instantiates everything it needs to run.
18 def initialize
19 @config = Configuration.instance
20 @script = "current_song.scpt"
21 end
22
23 # The current_track method should return the name of the current
24 # artist and song.
25 # @return [Hash] A hash containing the current `:song` and `:artist`.
26 def current_track
27 path_root = File.expand_path(File.dirname(__FILE__))
28 path = File.join(path_root, @script)
29 current = `osascript #{path}`
30 current = current.split("<-SEP->")
31 {artist: current[0], song: current[1]}
32 end
33
34 # The reset method resets any configurations it may have
35 def self.reset
36 # Nothing to do
37 end
38 end
39 end
40end