
from termcolor import colored
from appscript import *
from track import Track


def main():
    print(get_song())


def get_song():
    itunes_open = bool(app('System Events').processes[its.name == 'iTunes'].count())
    if itunes_open:  # check if application open
        itunes = app('iTunes')
        if itunes.player_state.get() == k.playing:  # check if song playing
            track = Track(itunes.current_track.get())
            return track

if __name__ == '__main__':
    main()

from termcolor import colored
from appscript import *
from track import Track


def main():
    print(get_song())


def get_song():
    itunes_open = bool(app('System Events').processes[its.name == 'iTunes'].count())
    if itunes_open:  # check if application open
        itunes = app('iTunes')
        if itunes.player_state.get() == k.playing:  # check if song playing
            track = Track(itunes.current_track.get())
            return track
        else:
            return colored('No song currently playing.', 'red')
    else:
        return colored('iTunes not open.', 'red')

if __name__ == '__main__':
    main()
Update error output for app not open/song not playing
Update error output for app not open/song not playing

  
  from termcolor import colored
  from appscript import *
  from track import Track
  
  
  def main():
      print(get_song())
  
  
  def get_song():
      itunes_open = bool(app('System Events').processes[its.name == 'iTunes'].count())
      if itunes_open:  # check if application open
          itunes = app('iTunes')
          if itunes.player_state.get() == k.playing:  # check if song playing
              track = Track(itunes.current_track.get())
              return track
+         else:
+             return colored('No song currently playing.', 'red')
+     else:
+         return colored('iTunes not open.', 'red')
  
  if __name__ == '__main__':
      main()
Update error output for app not open/song not playing
## Code Before:

from termcolor import colored
from appscript import *
from track import Track


def main():
    print(get_song())


def get_song():
    itunes_open = bool(app('System Events').processes[its.name == 'iTunes'].count())
    if itunes_open:  # check if application open
        itunes = app('iTunes')
        if itunes.player_state.get() == k.playing:  # check if song playing
            track = Track(itunes.current_track.get())
            return track

if __name__ == '__main__':
    main()
## Instruction:
Update error output for app not open/song not playing
## Code After:

from termcolor import colored
from appscript import *
from track import Track


def main():
    print(get_song())


def get_song():
    itunes_open = bool(app('System Events').processes[its.name == 'iTunes'].count())
    if itunes_open:  # check if application open
        itunes = app('iTunes')
        if itunes.player_state.get() == k.playing:  # check if song playing
            track = Track(itunes.current_track.get())
            return track
        else:
            return colored('No song currently playing.', 'red')
    else:
        return colored('iTunes not open.', 'red')

if __name__ == '__main__':
    main()