# pylint: disable=C0111,R0903

"""Displays information about the current song in Google Play music player.

Requires the following executable:
    * gpmdp-remote
"""

import bumblebee.util
import bumblebee.input
import bumblebee.output
import bumblebee.engine

class Module(bumblebee.engine.Module):
    def __init__(self, engine, config):
        widgets = [
            bumblebee.output.Widget(name='gpmdp.prev'),
            bumblebee.output.Widget(name='gpmdp.main', full_text=self.description),
            bumblebee.output.Widget(name='gpmdp.next'),
        ]
        super(Module, self).__init__(engine, config, widgets)

        engine.input.register_callback(widgets[0], button=bumblebee.input.LEFT_MOUSE,
            cmd='playerctl previous')
        engine.input.register_callback(widgets[1], button=bumblebee.input.LEFT_MOUSE,
             cmd='playerctl play-pause')
        engine.input.register_callback(widgets[2], button=bumblebee.input.LEFT_MOUSE,
             cmd='playerctl next')

        self._status = None
        self._tags = None

    def description(self, widget):
        return self._tags if self._tags else 'n/a'

    def update(self, widgets):
        self._load_song()

    def state(self, widget):
        if widget.name == 'gpmdp.prev':
            return 'prev'
        if widget.name == 'gpmdp.next':
            return 'next'
        return self._status

    def _load_song(self):
        info = ''
        try:
            info = bumblebee.util.execute('gpmdp-remote current')
            status = bumblebee.util.execute('gpmdp-remote status')
        except RuntimeError:
            pass
        self._status = status.split('\n')[0].lower()
        self._tags = info.split('\n')[0]

# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

@@ -171,123 +171,98 @@
 ort 
-bumblebee.util%0Aimport bumblebee.input%0Aimport bumblebee.out
+core.module%0Aimport core.widget%0Aimport core.in
 put%0A
+%0A
 import 
-bumblebee.engine%0A%0Aclass Module(bumblebee.engin
+util.cli%0A%0Aclass Module(core.modul
 e.Mo
@@ -294,16 +294,8 @@
 elf,
- engine,
  con
@@ -328,39 +328,34 @@
             
-bumblebee.outpu
+core.widge
 t.Widget(nam
@@ -379,39 +379,34 @@
             
-bumblebee.outpu
+core.widge
 t.Widget(nam
@@ -466,23 +466,18 @@
     
-bumblebee.outpu
+core.widge
 t.Wi
@@ -529,20 +529,8 @@
 per(
-Module, self
 ).__
@@ -540,16 +540,8 @@
 t__(
-engine, 
 conf
@@ -554,37 +554,35 @@
 dgets)%0A%0A        
-engin
+cor
 e.input.register
@@ -577,33 +577,24 @@
 put.register
-_callback
 (widgets%5B0%5D,
@@ -597,32 +597,27 @@
 %5B0%5D, button=
-bumblebe
+cor
 e.input.LEFT
@@ -662,37 +662,35 @@
 vious')%0A        
-engin
+cor
 e.input.register
@@ -685,33 +685,24 @@
 put.register
-_callback
 (widgets%5B1%5D,
@@ -705,32 +705,27 @@
 %5B1%5D, button=
-bumblebe
+cor
 e.input.LEFT
@@ -785,13 +785,11 @@
     
-engin
+cor
 e.in
@@ -804,17 +804,8 @@
 ster
-_callback
 (wid
@@ -820,24 +820,19 @@
  button=
-bumblebe
+cor
 e.input.
@@ -885,32 +885,33 @@
 %0A%0A        self._
+_
 status = None%0A  
@@ -918,24 +918,25 @@
       self._
+_
 tags = None%0A
@@ -988,24 +988,25 @@
 eturn self._
+_
 tags if self
@@ -1003,24 +1003,25 @@
 gs if self._
+_
 tags else 'n
@@ -1044,25 +1044,16 @@
 ate(self
-, widgets
 ):%0A     
@@ -1061,16 +1061,17 @@
   self._
+_
 load_son
@@ -1118,32 +1118,34 @@
   if widget.name
+()
  == 'gpmdp.prev'
@@ -1194,16 +1194,18 @@
 get.name
+()
  == 'gpm
@@ -1257,24 +1257,25 @@
 eturn self._
+_
 status%0A%0A    
@@ -1278,16 +1278,17 @@
     def 
+_
 _load_so
@@ -1316,57 +1316,16 @@
 o = 
-''%0A        try:%0A            info = bumblebee.
 util
+.cli
 .exe
@@ -1351,22 +1351,38 @@
 current'
-)%0A    
+, ignore_errors=True)%0A
         
@@ -1394,22 +1394,16 @@
 s = 
-bumblebee.
 util
+.cli
 .exe
@@ -1432,55 +1432,29 @@
 tus'
-)%0A        except RuntimeError:%0A            pass
+, ignore_errors=True)
 %0A   
@@ -1464,16 +1464,17 @@
   self._
+_
 status =
@@ -1518,16 +1518,17 @@
   self._
+_
 tags = i

Update to latest API