QueryLMS


NameQueryLMS JSON
Version 0.2.4.0 PyPI version JSON
download
home_pagehttps://github.com/txoof/querylms
SummarySimple interface for making queries and issuing commands to Logitech Media Server and associated players
upload_time2024-02-09 16:38:46
maintainer
docs_urlNone
authorAaron Ciuffo
requires_python>=3.7
license
keywords graphics e-paper display waveshare
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://github.com/roberteinhaus/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")
  
```

## Changes

**V 0.2**

* add additional keys to `get_now_playing` method
* return now-playing information for streams 

Notes:

* Album artwork is not properly returned for streams
* Album information may not be returned at all for streams

## 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=1, handle_requests_exceptions=False, request_timeout=5)
  
  Class to handle queries for an LMS player
  
  Each Query LMS object is associated with a single player_id
  
  If no host and port number are specified, the QueryLMS 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 first located (or specified) 
  server or a single player.
  
  By default any http requests exceptions encoutered when communicating
  with the server are raised and should be handled by your program. 
  Suppress and log exceptions with handle_reqests_exceptions=True
  
  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/
      handle_requests_exceptions(bool): True: quietly handle exceptions; False: raise exceptions
      request_timeout(int): seconds to wait for server to respond
      
  
  Additional API documentation: https://github.com/elParaguayo/LMS-CLI-Documentation/blob/master/LMS-CLI.md
  
  Methods defined here:
  
  __init__(self, host=None, port=None, player_name=None, player_id=None, scan_timeout=1, handle_requests_exceptions=False, request_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)
      return title of favorite radio stations
  
  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_favorite_radio(self)
      return favorited radio stations
  
  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
      
      Returns:
          dict
  
  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 saved radio stations
      
      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)
  
  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

  play_stream(self, url)
      play compatible stream such as Internet Radio or sound file on associated player
  
  previous_song(self)
      rewind one track on associated player
      
      Returns:
          (dict): {}
  
  query(self, player_id=None, *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.
      
      If the server IP/name or port change it is necessary
      to run set_server() again to trigger updates of the query urls
      
      QueryLMS will not detect dynamic changes of player name.
      
      Use the static method scan_lms() to find host information
      
      Use the get_players() method to list player names/ids associated with a LMS
      
      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
  
  ----------------------------------------------------------------------
  Readonly properties defined here:
  
  is_playing_remote_stream
  
  ----------------------------------------------------------------------
  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)

 ```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/txoof/querylms",
    "name": "QueryLMS",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "graphics e-paper display waveshare",
    "author": "Aaron Ciuffo",
    "author_email": "aaron.ciuffo@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/10/32/80ed00b288c1c6e670f866d1a1af701f3e3471765fb14b0848e1096b86d0/QueryLMS-0.2.4.0.tar.gz",
    "platform": null,
    "description": "# QueryLMS Python Library\nQueryLMS 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.\n\nQueryLMS is a rewrite of [LMSQuery](https://github.com/roberteinhaus/lmsquery) and reuses a significant portion of the LMSQuery code.\n\nUsage:\n```\n    import QueryLMS\n    # create the object and try to discover LMS on the local network\n    # try to associate with \"My Player\"\n    my_player = QueryLMS(player_name='My Player')\n    # get now playing tracks\n    my_player.get_now_playing()\n    >>> {'time': 0,\n         'mode': 'stop',\n         'id': 17001,\n         'title': 'We Belong Together',\n         'artist': 'Vampire Weekend feat. Danielle Haim',\n         'coverid': 'c9d646ff',\n         'duration': 190.733,\n         'album_id': '2064',\n         'genre': 'No Genre',\n         'album': 'Father of the Bride',\n         'artwork_url': 'http://192.168.178.9:9000/music/c9d646ff/cover.jpg'}\n  \n  # create the object with a defined hostname and port\n  # try to associate with player \"Living Room\"\n  living_room = QueryLMS(host=\"media-server.local\", port=9001, player_name=\"Living Room\")\n  \n```\n\n## Changes\n\n**V 0.2**\n\n* add additional keys to `get_now_playing` method\n* return now-playing information for streams \n\nNotes:\n\n* Album artwork is not properly returned for streams\n* Album information may not be returned at all for streams\n\n## API\n\nAll player related calls will raise ValueError if player_id is not set.\n\n```\nclass QueryLMS(builtins.object)\n  QueryLMS(host=None, port=None, player_name=None, player_id=None, scan_timeout=1, handle_requests_exceptions=False, request_timeout=5)\n  \n  Class to handle queries for an LMS player\n  \n  Each Query LMS object is associated with a single player_id\n  \n  If no host and port number are specified, the QueryLMS object will attempt to locate\n  an active LMS Server on the network. If a player_name is specified, the Query\n  object will attempt to find the player_id associated with that name.\n  \n  All queries are run against the first located (or specified) \n  server or a single player.\n  \n  By default any http requests exceptions encoutered when communicating\n  with the server are raised and should be handled by your program. \n  Suppress and log exceptions with handle_reqests_exceptions=True\n  \n  Attributes:\n      host(str): LMS Server hostname or ip address\n      port(int): LMS Server port number\n      player_name(str): Player name\n      player_id(str): unique player id in hex\n      scan_timeout(int): seconds to search local network for an LMS server\n      server_query_url(str): url to use when querying host status\n      server_base_url(str): base url of server: http://host:port/\n      handle_requests_exceptions(bool): True: quietly handle exceptions; False: raise exceptions\n      request_timeout(int): seconds to wait for server to respond\n      \n  \n  Additional API documentation: https://github.com/elParaguayo/LMS-CLI-Documentation/blob/master/LMS-CLI.md\n  \n  Methods defined here:\n  \n  __init__(self, host=None, port=None, player_name=None, player_id=None, scan_timeout=1, handle_requests_exceptions=False, request_timeout=5)\n      inits QueryLMS Class with host, port, player_id, player_name and scan_timeout\n      \n      Args:\n          host(str): LMS host name or ip address \n          port(int): LMS port number\n          player_name(str): name of player to associate with\n          player_id(str): player_id in hex \n          scan_timeout(int): seconds to search for LMS host\n  \n  display(self, line1, line2, duration=5)\n      display line1 and line2 on associated player\n      \n      Args:\n          line1(str)\n          line1(str)\n  \n  display_all(self, line1, line2, duration=5)\n      display line1 and line2 on all connected players\n      \n      Args:\n          line1(str)\n          line1(str)\n  \n  get_alarms(self, enabled=True)\n      ???\n  \n  get_artist_album(self, artist_id)\n      query associated player for currently playing album artist\n      \n      Returns:\n          (str)\n  \n  get_artist_count(self)\n      query server for total number of artists\n      \n      Returns:\n          (int): count of unique artist ids\n  \n  get_artists(self)\n      query server for internal artist id, names\n      Returns:\n          (dict): JSON formatted list of ids and artists\n  \n  get_current_album(self)\n      query associated player for currently playing track album\n      \n      Returns:\n          (str)\n  \n  get_current_artist(self)\n      query associated player for currently playing artist\n      \n      Returns:\n          (str)\n  \n  get_current_radio_title(self, radio)\n      return title of favorite radio stations\n  \n  get_current_song_title(self)\n      query associated player for currently playing track title\n      \n      Returns:\n          (str)\n  \n  get_current_title(self)\n      query associated player for currently playing track title\n      \n      Returns:\n          (str)\n  \n  get_favorite_radio(self)\n      return favorited radio stations\n  \n  get_next_alarm(self)\n      ???\n  \n  get_now_playing(self)\n      query associated player for now playing information including:\n      * album\n      * artist\n      * artwork_url\n      * duration\n      * genre\n      * coverid\n      * id\n      * title\n      \n      Returns:\n          dict\n  \n  get_player_count(self)\n      query server for total number of connected players\n      \n      Returns:\n          (int): count of unique players connected\n  \n  get_player_pref(self, pref)\n      ???\n  \n  get_players(self)\n      query server for connected player information\n      \n      Returns:\n          (dict): JSON formatted list of player information\n  \n  get_radios_count(self)\n      query server for total number of saved radio stations\n      \n      Returns:\n          (int): count of unique radios connected\n  \n  get_server_status(self)\n      query server status in JSON\n      \n      Returns:\n          (dict): JSON formatted server status\n  \n  get_volume(self)\n      query associated player for volume\n      \n      Returns:\n          (str)\n  \n  next_song(self)\n      fast forward one track on associated player\n      \n      Returns:\n          (dict): {}\n  \n  pause(self)\n      pause associated player\n      \n      Returns:\n          (dict): {}\n  \n  play_album(self, album_id)\n      play an album on associated player\n      \n      Args:\n          album_id(int): internal album id\n          \n      Returns:\n          (dict): {'count': int} total tracks on album\n  \n  play_radio(self, radio)\n      play radio??? on associated player\n\n  play_stream(self, url)\n      play compatible stream such as Internet Radio or sound file on associated player\n  \n  previous_song(self)\n      rewind one track on associated player\n      \n      Returns:\n          (dict): {}\n  \n  query(self, player_id=None, *args)\n      # Basic Query\n      #####################################\n  \n  rescan(self)\n      rescan LMS library\n      \n      Returns:\n          (dict): {}\n  \n  search(self, searchstring, count=9999)\n      query server for searchstring (ignoring case)\n      \n      Args:\n          searchstring(str): string to search for\n      \n      Returns:\n          (dict): JSON formatted list of all entities containing searchstring\n  \n  search_albums(self, searchstring, count=9999)\n      query server for searchstring in album names (ignoring case)\n      \n      Args:\n          searchstring(str): string to search tracks for\n          \n      Returns:\n          (dict): JSON formatted list of all album entities containing searchstring\n  \n  search_contributors(self, searchstring, count=9999)\n      query server for searchstring in contributors names (ignoring case)\n      \n      Args:\n          searchstring(str): string to search tracks for\n          \n      Returns:\n          (dict): JSON formatted list of all contributors entities containing searchstring\n  \n  search_players(self, searchstring, count=9999)\n      query server for searchstring in player names (ignoring case)\n      \n      Args:\n          searchstring(str): string to search tracks for\n          \n      Returns:\n          (dict): JSON formatted list of all player entities containing searchstring\n  \n  search_tracks(self, searchstring, count=9999)\n      query server for searchstring in track names (ignoring case)\n      \n      Args:\n          searchstring(str): string to search tracks for\n          \n      Returns:\n          (dict): JSON formatted list of all track entities containing searchstring\n  \n  set_player_pref(self, pref, value)\n      ???\n  \n  set_power(self, power=1)\n      send power command to connected player\n  \n  set_power_all(self, power=1)\n  \n  set_server(self)\n      set the server details using \"host\" and \"port\"\n      \n      If no host and port is specified, queryLMS will search for the \n      first LMS server on the local network segment.\n      \n      If the server IP/name or port change it is necessary\n      to run set_server() again to trigger updates of the query urls\n      \n      QueryLMS will not detect dynamic changes of player name.\n      \n      Use the static method scan_lms() to find host information\n      \n      Use the get_players() method to list player names/ids associated with a LMS\n      \n      Sets:\n          server_query_url\n          server_base_url\n          player_id (if not already set)\n  \n  set_volume(self, volume)\n      set volume on associated player\n      \n      Args:\n          volume(int): 0-100\n          \n      Returns:\n          (dict): {}\n  \n  skip_songs(self, amount=1)\n      skip n tracks on associated player\n      \n      Args:\n          amount(int): number of tracks to skip\n      \n      Returns:\n          (dict): {}\n  \n  ----------------------------------------------------------------------\n  Static methods defined here:\n  \n  scan_lms(scan_timeout=None)\n      Search local network for Logitech Media Servers\n      \n      Based on netdisco/lms.py by cxlwill - https://github.com/cxlwill\n      \n      Args:\n        scan_timeout (int): timeout seconds\n      \n      Returns:\n        list: Dictionary of LMS Server IP and listen ports\n  \n  ----------------------------------------------------------------------\n  Readonly properties defined here:\n  \n  is_playing_remote_stream\n  \n  ----------------------------------------------------------------------\n  Data descriptors defined here:\n  \n  __dict__\n      dictionary for instance variables (if defined)\n  \n  __weakref__\n      list of weak references to the object (if defined)\n  \n  host\n      LMS ip address or hostname: (str)\n  \n  player_id\n      LMS player unique hexidecimal id (str)\n  \n  player_name\n      human readable name of player: (str)\n  \n  port\n      LMS server port: (int)\n\n ```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Simple interface for making queries and issuing commands to Logitech Media Server and associated players",
    "version": "0.2.4.0",
    "project_urls": {
        "Homepage": "https://github.com/txoof/querylms",
        "Source": "https://github.com/txoof/querylms"
    },
    "split_keywords": [
        "graphics",
        "e-paper",
        "display",
        "waveshare"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9b9c859bbdaf565d0adb8186e95a5464e4bce6d48d1a9a0abea822ece1cdca01",
                "md5": "f9b87b22e4d85617afef0daf866086bb",
                "sha256": "03a8c78e1e93bd6a6303faf5b06e8320aa63db5b9a05f73688c0860082aa863b"
            },
            "downloads": -1,
            "filename": "QueryLMS-0.2.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f9b87b22e4d85617afef0daf866086bb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 12222,
            "upload_time": "2024-02-09T16:38:45",
            "upload_time_iso_8601": "2024-02-09T16:38:45.314253Z",
            "url": "https://files.pythonhosted.org/packages/9b/9c/859bbdaf565d0adb8186e95a5464e4bce6d48d1a9a0abea822ece1cdca01/QueryLMS-0.2.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "103280ed00b288c1c6e670f866d1a1af701f3e3471765fb14b0848e1096b86d0",
                "md5": "30bfc76c15f2746273002ef6fa560907",
                "sha256": "39612c1840545f9f8026e0fad1d3291a7eb9d7747c894c60b446b5ae5f21f692"
            },
            "downloads": -1,
            "filename": "QueryLMS-0.2.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "30bfc76c15f2746273002ef6fa560907",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 13630,
            "upload_time": "2024-02-09T16:38:46",
            "upload_time_iso_8601": "2024-02-09T16:38:46.916638Z",
            "url": "https://files.pythonhosted.org/packages/10/32/80ed00b288c1c6e670f866d1a1af701f3e3471765fb14b0848e1096b86d0/QueryLMS-0.2.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-09 16:38:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "txoof",
    "github_project": "querylms",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "querylms"
}
        
Elapsed time: 0.18315s