QueryLMS creates an simple interface for making queries and issuing commands to Logitech Media Server and associated players
Project description
QueryLMS Python Library
QueryLMS manages queries to a Logitech Media Server and associates with a single player. A QueryLMS object can be used to query server or player status information and control an LMS player.
QueryLMS is a rewrite of LMSQuery and reuses a significant portion of the LMSQuery code.
Usage:
import QueryLMS
# create the object and try to discover LMS on the local network
# try to associate with "My Player"
my_player = QueryLMS(player_name='My Player')
# get now playing tracks
my_player.get_now_playing()
>>> {'time': 0,
'mode': 'stop',
'id': 17001,
'title': 'We Belong Together',
'artist': 'Vampire Weekend feat. Danielle Haim',
'coverid': 'c9d646ff',
'duration': 190.733,
'album_id': '2064',
'genre': 'No Genre',
'album': 'Father of the Bride',
'artwork_url': 'http://192.168.178.9:9000/music/c9d646ff/cover.jpg'}
# create the object with a defined hostname and port
# try to associate with player "Living Room"
living_room = QueryLMS(host="media-server.local", port=9001, player_name="Living Room")
API
All player related calls will raise ValueError if player_id is not set.
class QueryLMS(builtins.object)
QueryLMS(host=None, port=None, player_name=None, player_id=None, scan_timeout=5)
Class to handle queries for a LMS player
Each Query LMS object is associated with a single player
If no host and port number are specified, the object will attempt to locate
an active LMS Server on the network. If a player_name is specified, the Query
object will attempt to find the player_id associated with that name.
All queries are run against the server or a single server
Attributes:
host(str): LMS Server hostname or ip address
port(int): LMS Server port number
player_name(str): Player name
player_id(str): unique player id in hex
scan_timeout(int): seconds to search local network for an LMS server
server_query_url(str): url to use when querying host status
server_base_url(str): base url of server: http://host:port/
Methods defined here:
__init__(self, host=None, port=None, player_name=None, player_id=None, scan_timeout=5)
inits QueryLMS Class with host, port, player_id, player_name and scan_timeout
Args:
host(str): LMS host name or ip address
port(int): LMS port number
player_name(str): name of player to associate with
player_id(str): player_id in hex
scan_timeout(int): seconds to search for LMS host
display(self, line1, line2, duration=5)
display line1 and line2 on associated player
Args:
line1(str)
line1(str)
display_all(self, line1, line2, duration=5)
display line1 and line2 on all connected players
Args:
line1(str)
line1(str)
get_alarms(self, enabled=True)
???
get_artist_album(self, artist_id)
query associated player for currently playing album artist
Returns:
(str)
get_artist_count(self)
query server for total number of artists
Returns:
(int): count of unique artist ids
get_artists(self)
query server for internal artist id, names
Returns:
(dict): JSON formatted list of ids and artists
get_current_album(self)
query associated player for currently playing track album
Returns:
(str)
get_current_artist(self)
query associated player for currently playing artist
Returns:
(str)
get_current_radio_title(self, radio)
???
get_current_song_title(self)
query associated player for currently playing track title
Returns:
(str)
get_current_title(self)
query associated player for currently playing track title
Returns:
(str)
get_next_alarm(self)
???
get_now_playing(self)
query associated player for now playing information including:
* album
* artist
* artwork_url
* duration
* genre
* coverid
* id
* title
get_player_count(self)
query server for total number of connected players
Returns:
(int): count of unique players connected
get_player_pref(self, pref)
???
get_players(self)
query server for connected player information
Returns:
(dict): JSON formatted list of player information
get_radios_count(self)
query server for total number of radios
Returns:
(int): count of unique radios connected
get_server_status(self)
query server status in JSON
Returns:
(dict): JSON formatted server status
get_volume(self)
query associated player for volume
Returns:
(str)
is_playing_remote_stream(self)
???
next_song(self)
fast forward one track on associated player
Returns:
(dict): {}
pause(self)
pause associated player
Returns:
(dict): {}
play_album(self, album_id)
play an album on associated player
Args:
album_id(int): internal album id
Returns:
(dict): {'count': int} total tracks on album
play_radio(self, radio)
play radio??? on associated player
previous_song(self)
rewind one track on associated player
Returns:
(dict): {}
query(self, player_id='', *args)
# Basic Query
#####################################
rescan(self)
rescan LMS library
Returns:
(dict): {}
search(self, searchstring, count=9999)
query server for searchstring (ignoring case)
Args:
searchstring(str): string to search for
Returns:
(dict): JSON formatted list of all entities containing searchstring
search_albums(self, searchstring, count=9999)
query server for searchstring in album names (ignoring case)
Args:
searchstring(str): string to search tracks for
Returns:
(dict): JSON formatted list of all album entities containing searchstring
search_contributors(self, searchstring, count=9999)
query server for searchstring in contributors names (ignoring case)
Args:
searchstring(str): string to search tracks for
Returns:
(dict): JSON formatted list of all contributors entities containing searchstring
search_players(self, searchstring, count=9999)
query server for searchstring in player names (ignoring case)
Args:
searchstring(str): string to search tracks for
Returns:
(dict): JSON formatted list of all player entities containing searchstring
search_tracks(self, searchstring, count=9999)
query server for searchstring in track names (ignoring case)
Args:
searchstring(str): string to search tracks for
Returns:
(dict): JSON formatted list of all track entities containing searchstring
set_player_pref(self, pref, value)
???
set_power(self, power=1)
send power command to connected player
set_power_all(self, power=1)
set_server(self)
set the server details using "host" and "port"
if no host and port is specified, queryLMS will search for the first LMS server
on the local network segment
Sets:
server_query_url
server_base_url
player_id (if not already set)
set_volume(self, volume)
set volume on associated player
Args:
volume(int): 0-100
Returns:
(dict): {}
skip_songs(self, amount=1)
skip n tracks on associated player
Args:
amount(int): number of tracks to skip
Returns:
(dict): {}
----------------------------------------------------------------------
Static methods defined here:
scan_lms(scan_timeout=None)
Search local network for Logitech Media Servers
Based on netdisco/lms.py by cxlwill - https://github.com/cxlwill
Args:
scan_timeout (int): timeout seconds
Returns:
list: Dictionary of LMS Server IP and listen ports
----------------------------------------------------------------------
Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
host
LMS ip address or hostname: (str)
player_id
LMS player unique hexidecimal id (str)
player_name
human readable name of player: (str)
port
LMS server port: (int)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file QueryLMS-0.2.0.tar.gz.
File metadata
- Download URL: QueryLMS-0.2.0.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd87da70d7202b0d24ced5b0093a33b98f382c500f8c75146620cffd28d1f320
|
|
| MD5 |
6079409cf3820790fc3233b47e301f83
|
|
| BLAKE2b-256 |
ab994381141d05c84bf4f768d92c6a98a4fcd24018f219297e0149592143d78e
|
File details
Details for the file QueryLMS-0.2.0-py3-none-any.whl.
File metadata
- Download URL: QueryLMS-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a94486f39fab6cbe795781ef4cade1c37226d3662005e41e691cd9679cda3264
|
|
| MD5 |
611c0c70e1dfc3bcbe9fe406befb6d85
|
|
| BLAKE2b-256 |
540c2581d914cb62bf0db11b21773c269e1a69da361b93233dac1f58e123de93
|