Giter Club home page Giter Club logo

pylms's Introduction

Flattr this git repo

Installation

Now available on PyPI and can be installed using easy_install. The package for Debian/Ubuntu is python-setuptools. Use your package manager to install this.

Now, type the following. You may need to prefix this with sudo if you want a system wide (not a virtualenv) installation.

easy_install pylms

Command Line Script

If installed through "easy_install" or via the setup script, there is a new command called "pylms" that can be used in scripts to control your devices.

pylms --host 192.168.1.10 --device 00:00:00:00:00:00 play

For more current help:

pylms --help

Documentation

Class documentation, and soon to be usage instructions are now available. View Documentation.

Features

The following functions are supported:

  • Retrieval of all configured players
  • Retrieval of all properties of configured players
  • Retrieval of Volume, Mode, Play Status, Power Status, IR Status, Volume, Bass, Treble, Pitch etc.
  • Playlist Control (Play, Add, Insert, Delete, Move etc.)
  • Player Control (Play, Stop, Pause, Volume, Muting, Power, IR Remote, Volume, Bass, Treble, Pitch etc.)

Example:

#!/usr/bin/env python

from pylms.server import Server
from pylms.player import Player

sc = Server(hostname="192.168.1.1", port=9090, username="user", password="password")
sc.connect()

print "Logged in: %s" % sc.logged_in
print "Version: %s" % sc.get_version()

sq = sc.get_player("00:11:22:33:44:55")

print "Name: %s | Mode: %s | Time: %s | Connected: %s | WiFi: %s" % (sq.get_name(), sq.get_mode(), sq.get_time_elapsed(), sq.is_connected, sq.get_wifi_signal_strength())

print sq.get_track_title()
print sq.get_time_remaining()

Links

pylms's People

Contributors

decibyte avatar jinglemansweep avatar kaze3 avatar klstanie avatar kstaniek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pylms's Issues

AttributeError: 'NoneType' object has no attribute 'lower'

diff --git a/pylms/server.py b/pylms/server.py
index 3fe1a3e..e20583e 100644
--- a/pylms/server.py
+++ b/pylms/server.py
@@ -171,8 +171,8 @@ class Server(object):
         """
         if isinstance(ref, str):
             ref = self.__decode(ref)
-        ref = ref.lower()
         if ref:
+            ref = ref.lower()
             for player in self.players:
                 player_name = player.name.lower()
                 player_ref = player.ref.lower()

How search artist and construct an item object?

Hi,

I had two questions

  1. How retriver artist and albums

With http method no problem

requete = {"id":1,"method":"slim.request","params":["-",["artists",0,10000,"tags:lya" ]]} r = requests.post('http://'+LMSIP+':'+str(LMSPORTWEB)+'/jsonrpc.js',data=json.dumps(requete)) result = r.json()['result']['artists_loop']

But with pyLMS i try :

print sc.search('pink floyd', mode='artist')

but i get a 'None' in result

  1. How play a song

I must give an item object but how i construct them ?

sq.playlist_play(??)

Thank you, sorry for my ugly english

Get the number of the current track

I've no idea how to commit a change, but here is an addition to player.py:

def playlist_current_track_index(self):
    """Get the number of the current track"""
    return int(self.request('playlist index ?'))+1

ASCII encoding and wacky artist names

I've got a very simple script that prints the currently playing artist to stdout. It's failing when trying to return "Janelle Monáe" (failing on the á, I assume) with the error:

Traceback (most recent call last):
  File "scripts/now_playing.py", line 29, in <module>
    artist = sq.get_track_artist()
  File "build/bdist.macosx-10.8-intel/egg/pylms/player.py", line 266, in get_track_artist
UnicodeEncodeError: 'ascii' codec can't encode characters in position 11-12: ordinal not in range(128)

Forgive me if this is a basic question not having to do with your script (I'm not a python developer), but I do seem to be able to handle unicode in the script (print u"\u03A9" outputs Ω correctly, for example).

Thanks!

server.request() truncates results at left

What steps will reproduce the problem?
1.s = server.Server()
2.s.connect()
3a.s.request('trackstat getrating 94')
or 3b. s.request('songinfo 0 100 track_id:94')

What is the expected output? What do you see instead?
for 3a above 'rating 3 ratingpercentage 60'
instead get '60', or 'ercentage 60', or ''
for 3b expect to get a long string of tag:value pairs starting with track_id:94
instead get 'd:94'... or just '4'... followed by the rest of the string
The amount of truncation is small (<20 bytes) but variable in my experience.

What version of the product are you using? On what operating system?
latest pysqueezecenter (0.92) on Ubuntu 10.10, with squeezebox server 7.5.3

Please provide any additional information below.
(trackstat command above is using trackstat plugin)
I am really pleased to have discovered pysqueezecenter ... thanks for a great package

Inconsistent indentation

Hi,
1st of all: thanks to the contributors for this great module.
Although I am pretty new to python, I had following issue:

I installed PyLMS under Python3.6. My application gave me following error-message:
File "/usr/lib/python3.6/site-packages/pylms/player.py", line 607 self.request("sync -") ^ TabError: inconsistent use of tabs and spaces in indentation

Not a big deal. When I opened the file player.py with an editor I could see, that usually blank-spaces where used for indentation. But in line 607 it was a tab. All what I had to do was to change the indentation from tab to blank-spaces and the issue was fixed.

import urllib needed in server.request_with_results

What steps will reproduce the problem?
serverobject.request_with_results("favorites items 0 1")

What is the expected output? What do you see instead?
Expected: (x, [{...}], True)
(0, [], False) is returned.

What version of the product are you using? ver 0.95 on Python 2.7
On what operating system? on WinXP

Please provide any additional information below.
In server.py the server.request_with_results method the following line raises an exception:
quotedColon = urllib.quote(':')

The problem is that urllib has not been imported. Adding "import urllib" at the top of the method fixes the problem and the correct results are returned.

There's also another reference to urllib farther down in the method:
item[urllib.unquote(key)] = self.__unquote(value)

The following change fixes the problem:
item[self.__unquote(value)] = self.__unquote(value)

If last change is made then the "import urllib" line can be removed and so can the "quotedColon = urllib.quote(':')" line.

  • The second line can be removed because quotedColon is set as the first statement in the method.

Thanks for the code,

Mike
Delete comment

pref value question

Hi, Thank you for your work on this tool.
I'm trying to get the name of where my Audio Files are kept in a python program but the command returns null? The playlist dir works fine but the audiodir doesn't:

from pylms.server import Server
from pylms.player import Player
sc = Server(hostname="192.168.0.107")
sc.connect()
sq = sc.get_player("b8:27:eb:1f:3d:fb")
print(sq.request("pref playlistdir ?"))
print(sq.request("pref audiodir ?"))

Any thoughts are appreciated. Thanks

Listen/subscribe capability

I noticed that the subscribe/listen capabilities of the Squeezebox Server CLI has not been implemented. Is there a specific reason for this?

scripting + php

hi there,

your code is great, just what I was looking for.
For my webpage (php) that controls my whole house (almost :) ) : lights, WOL to a pc, garage door, ... I want it to control some basic stuff of the LMS (power on, off and play/pause).
For that I need to do a little scripting, but unfortunately I'm not there. Could you help? My guess it is a stupid small thing (newline, quote, ..).
What I got:

function muz_aan(){
$cmd2=shell_exec("pylms --host 192.168.1.250 --device 00:11:00:11:22:03 -r get_power_state");

if ($cmd2 == "True") {
$muz_power_out="LMS is ON";
} else {
$muz_power_out="LMS is OFF";
}
$muz_aan_out="$muz_power_out";
return $muz_aan_out;

print '

Muzieksysteem ' .$muz_aan_out. '

';

thnaks all!

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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.