jinglemansweep/PyLMS

Server.get_player() finds device if not the full name is given

Opened this issue · 0 comments

Assume we have two SqueezeBoxes named 'Kids Bedroom' &
'Parents Bedroom'.

What steps will reproduce the problem?

  1. Server.get_player("rent")
  2. Server.get_player("Bedroom")

What is the expected output? What do you see instead?

  1. Should return None, but returns the player 'Parents Bedroom'
  2. Should return None or False, but returns the first found
    player with 'Bedroom' in its name.

What version of the product are you using? On what operating system?

r51 (Aug 14, 2011)

Please provide any additional information below.

Add an option to get_player() to search strictly or loosely.
=>>
def get_player(self, ref=None, strictly=False):
ref = str(ref).lower()
if ref:
for player in self.players:
player_name = str(player.name).lower()
player_ref = str(player.ref).lower()
if ref == player_ref or
(not strictly and ref in player_name) or
(strictly and ref == player_name):
return player