style fixes

This commit is contained in:
Jon Maddox 2015-09-11 23:49:43 -04:00
parent 6d9b618f1c
commit b9f5ec9e2c

View File

@ -22,16 +22,17 @@ The name of the device.
url url
*Required *Required
The URL of your set up and running version of iTunes-API. Example: http://192.168.1.50:8181 URL of your running version of iTunes-API. Example: http://192.168.1.50:8181
""" """
import logging import logging
from homeassistant.components.media_player import ( from homeassistant.components.media_player import (
MediaPlayerDevice, MEDIA_TYPE_MUSIC, SUPPORT_PAUSE, SUPPORT_SEEK, SUPPORT_VOLUME_SET, MediaPlayerDevice, MEDIA_TYPE_MUSIC, SUPPORT_PAUSE, SUPPORT_SEEK,
SUPPORT_VOLUME_MUTE, SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK) SUPPORT_VOLUME_SET, SUPPORT_VOLUME_MUTE, SUPPORT_PREVIOUS_TRACK,
SUPPORT_NEXT_TRACK)
from homeassistant.const import ( from homeassistant.const import (
STATE_IDLE, STATE_PLAYING, STATE_PAUSED, STATE_OFF) STATE_IDLE, STATE_PLAYING, STATE_PAUSED)
try: try:
import requests import requests
@ -43,6 +44,7 @@ _LOGGER = logging.getLogger(__name__)
SUPPORT_ITUNES = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \ SUPPORT_ITUNES = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | SUPPORT_SEEK SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | SUPPORT_SEEK
class Itunes(object): class Itunes(object):
def __init__(self, host, port): def __init__(self, host, port):
@ -103,6 +105,7 @@ class Itunes(object):
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the itunes platform. """ """ Sets up the itunes platform. """
add_devices([ add_devices([
ItunesDevice( ItunesDevice(
config.get('name', 'iTunes'), config.get('name', 'iTunes'),
@ -111,6 +114,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
) )
]) ])
class ItunesDevice(MediaPlayerDevice): class ItunesDevice(MediaPlayerDevice):
""" Represents a iTunes-API instance. """ """ Represents a iTunes-API instance. """
@ -155,7 +159,7 @@ class ItunesDevice(MediaPlayerDevice):
def state(self): def state(self):
""" Returns the state of the device. """ """ Returns the state of the device. """
if self.player_state == 'offline' or self.player_state == None: if self.player_state == 'offline' or self.player_state is None:
return 'offline' return 'offline'
if self.player_state == 'error': if self.player_state == 'error':
@ -196,10 +200,14 @@ class ItunesDevice(MediaPlayerDevice):
def media_image_url(self): def media_image_url(self):
""" Image url of current playing media. """ """ Image url of current playing media. """
if (self.player_state == STATE_PLAYING or self.player_state == STATE_IDLE or self.player_state == STATE_PAUSED) and self.current_title != None: if (self.player_state == STATE_PLAYING or
self.player_state == STATE_IDLE or
self.player_state == STATE_PAUSED) and
self.current_title is not None:
return self.client.artwork_url() return self.client.artwork_url()
else: else:
return "https://cloud.githubusercontent.com/assets/260/9829355/33fab972-58cf-11e5-8ea2-2ca74bdaae40.png" return 'https://cloud.githubusercontent.com/assets/260/9829355'
'/33fab972-58cf-11e5-8ea2-2ca74bdaae40.png'
@property @property
def media_title(self): def media_title(self):