repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
SoCo/SoCo | soco/plugins/wimp.py | Wimp.get_music_service_information | def get_music_service_information(self, search_type, search, start=0,
max_items=100):
"""Search for music service information items.
:param search_type: The type of search to perform, possible values are:
'artists', 'albums', 'tracks' and 'playlists'
... | python | def get_music_service_information(self, search_type, search, start=0,
max_items=100):
"""Search for music service information items.
:param search_type: The type of search to perform, possible values are:
'artists', 'albums', 'tracks' and 'playlists'
... | [
"def",
"get_music_service_information",
"(",
"self",
",",
"search_type",
",",
"search",
",",
"start",
"=",
"0",
",",
"max_items",
"=",
"100",
")",
":",
"# Check input",
"if",
"search_type",
"not",
"in",
"[",
"'artists'",
",",
"'albums'",
",",
"'tracks'",
","... | Search for music service information items.
:param search_type: The type of search to perform, possible values are:
'artists', 'albums', 'tracks' and 'playlists'
:type search_type: str
:param search: The search string to use
:type search: str
:param start: The starti... | [
"Search",
"for",
"music",
"service",
"information",
"items",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/plugins/wimp.py#L229-L277 | train |
SoCo/SoCo | soco/plugins/wimp.py | Wimp.browse | def browse(self, ms_item=None):
"""Return the sub-elements of item or of the root if item is None
:param item: Instance of sub-class of
:py:class:`soco.data_structures.MusicServiceItem`. This object must
have item_id, service_id and extended_id properties
Note:
... | python | def browse(self, ms_item=None):
"""Return the sub-elements of item or of the root if item is None
:param item: Instance of sub-class of
:py:class:`soco.data_structures.MusicServiceItem`. This object must
have item_id, service_id and extended_id properties
Note:
... | [
"def",
"browse",
"(",
"self",
",",
"ms_item",
"=",
"None",
")",
":",
"# Check for correct service",
"if",
"ms_item",
"is",
"not",
"None",
"and",
"ms_item",
".",
"service_id",
"!=",
"self",
".",
"_service_id",
":",
"message",
"=",
"'This music service item is not... | Return the sub-elements of item or of the root if item is None
:param item: Instance of sub-class of
:py:class:`soco.data_structures.MusicServiceItem`. This object must
have item_id, service_id and extended_id properties
Note:
Browsing a MSTrack item will return its... | [
"Return",
"the",
"sub",
"-",
"elements",
"of",
"item",
"or",
"of",
"the",
"root",
"if",
"item",
"is",
"None"
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/plugins/wimp.py#L279-L337 | train |
SoCo/SoCo | soco/plugins/wimp.py | Wimp.id_to_extended_id | def id_to_extended_id(item_id, item_class):
"""Return the extended ID from an ID.
:param item_id: The ID of the music library item
:type item_id: str
:param cls: The class of the music service item
:type cls: Sub-class of
:py:class:`soco.data_structures.MusicServiceI... | python | def id_to_extended_id(item_id, item_class):
"""Return the extended ID from an ID.
:param item_id: The ID of the music library item
:type item_id: str
:param cls: The class of the music service item
:type cls: Sub-class of
:py:class:`soco.data_structures.MusicServiceI... | [
"def",
"id_to_extended_id",
"(",
"item_id",
",",
"item_class",
")",
":",
"out",
"=",
"ID_PREFIX",
"[",
"item_class",
"]",
"if",
"out",
":",
"out",
"+=",
"item_id",
"return",
"out"
] | Return the extended ID from an ID.
:param item_id: The ID of the music library item
:type item_id: str
:param cls: The class of the music service item
:type cls: Sub-class of
:py:class:`soco.data_structures.MusicServiceItem`
The extended id can be something like 000... | [
"Return",
"the",
"extended",
"ID",
"from",
"an",
"ID",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/plugins/wimp.py#L340-L356 | train |
SoCo/SoCo | soco/plugins/wimp.py | Wimp.form_uri | def form_uri(item_content, item_class):
"""Form the URI for a music service element.
:param item_content: The content dict of the item
:type item_content: dict
:param item_class: The class of the item
:type item_class: Sub-class of
:py:class:`soco.data_structures.Mus... | python | def form_uri(item_content, item_class):
"""Form the URI for a music service element.
:param item_content: The content dict of the item
:type item_content: dict
:param item_class: The class of the item
:type item_class: Sub-class of
:py:class:`soco.data_structures.Mus... | [
"def",
"form_uri",
"(",
"item_content",
",",
"item_class",
")",
":",
"extension",
"=",
"None",
"if",
"'mime_type'",
"in",
"item_content",
":",
"extension",
"=",
"MIME_TYPE_TO_EXTENSION",
"[",
"item_content",
"[",
"'mime_type'",
"]",
"]",
"out",
"=",
"URIS",
".... | Form the URI for a music service element.
:param item_content: The content dict of the item
:type item_content: dict
:param item_class: The class of the item
:type item_class: Sub-class of
:py:class:`soco.data_structures.MusicServiceItem` | [
"Form",
"the",
"URI",
"for",
"a",
"music",
"service",
"element",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/plugins/wimp.py#L359-L374 | train |
SoCo/SoCo | soco/plugins/wimp.py | Wimp._search_body | def _search_body(self, search_type, search_term, start, max_items):
"""Return the search XML body.
:param search_type: The search type
:type search_type: str
:param search_term: The search term e.g. 'Jon Bon Jovi'
:type search_term: str
:param start: The start index of t... | python | def _search_body(self, search_type, search_term, start, max_items):
"""Return the search XML body.
:param search_type: The search type
:type search_type: str
:param search_term: The search term e.g. 'Jon Bon Jovi'
:type search_term: str
:param start: The start index of t... | [
"def",
"_search_body",
"(",
"self",
",",
"search_type",
",",
"search_term",
",",
"start",
",",
"max_items",
")",
":",
"xml",
"=",
"self",
".",
"_base_body",
"(",
")",
"# Add the Body part",
"XML",
".",
"SubElement",
"(",
"xml",
",",
"'s:Body'",
")",
"item_... | Return the search XML body.
:param search_type: The search type
:type search_type: str
:param search_term: The search term e.g. 'Jon Bon Jovi'
:type search_term: str
:param start: The start index of the returned results
:type start: int
:param max_items: The maxi... | [
"Return",
"the",
"search",
"XML",
"body",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/plugins/wimp.py#L376-L415 | train |
SoCo/SoCo | soco/plugins/wimp.py | Wimp._browse_body | def _browse_body(self, search_id):
"""Return the browse XML body.
The XML is formed by adding, to the envelope of the XML returned by
``self._base_body``, the following ``Body`` part:
.. code :: xml
<s:Body>
<getMetadata xmlns="http://www.sonos.com/Services/1.1">
... | python | def _browse_body(self, search_id):
"""Return the browse XML body.
The XML is formed by adding, to the envelope of the XML returned by
``self._base_body``, the following ``Body`` part:
.. code :: xml
<s:Body>
<getMetadata xmlns="http://www.sonos.com/Services/1.1">
... | [
"def",
"_browse_body",
"(",
"self",
",",
"search_id",
")",
":",
"xml",
"=",
"self",
".",
"_base_body",
"(",
")",
"# Add the Body part",
"XML",
".",
"SubElement",
"(",
"xml",
",",
"'s:Body'",
")",
"item_attrib",
"=",
"{",
"'xmlns'",
":",
"'http://www.sonos.co... | Return the browse XML body.
The XML is formed by adding, to the envelope of the XML returned by
``self._base_body``, the following ``Body`` part:
.. code :: xml
<s:Body>
<getMetadata xmlns="http://www.sonos.com/Services/1.1">
<id>root</id>
<index>... | [
"Return",
"the",
"browse",
"XML",
"body",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/plugins/wimp.py#L417-L450 | train |
SoCo/SoCo | soco/plugins/wimp.py | Wimp._check_for_errors | def _check_for_errors(self, response):
"""Check a response for errors.
:param response: the response from requests.post()
"""
if response.status_code != 200:
xml_error = really_utf8(response.text)
error_dom = XML.fromstring(xml_error)
fault = error_do... | python | def _check_for_errors(self, response):
"""Check a response for errors.
:param response: the response from requests.post()
"""
if response.status_code != 200:
xml_error = really_utf8(response.text)
error_dom = XML.fromstring(xml_error)
fault = error_do... | [
"def",
"_check_for_errors",
"(",
"self",
",",
"response",
")",
":",
"if",
"response",
".",
"status_code",
"!=",
"200",
":",
"xml_error",
"=",
"really_utf8",
"(",
"response",
".",
"text",
")",
"error_dom",
"=",
"XML",
".",
"fromstring",
"(",
"xml_error",
")... | Check a response for errors.
:param response: the response from requests.post() | [
"Check",
"a",
"response",
"for",
"errors",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/plugins/wimp.py#L484-L502 | train |
SoCo/SoCo | soco/music_services/music_service.py | desc_from_uri | def desc_from_uri(uri):
"""Create the content of DIDL desc element from a uri.
Args:
uri (str): A uri, eg:
``'x-sonos-http:track%3a3402413.mp3?sid=2&flags=32&sn=4'``
Returns:
str: The content of a desc element for that uri, eg
``'SA_RINCON519_email@example.c... | python | def desc_from_uri(uri):
"""Create the content of DIDL desc element from a uri.
Args:
uri (str): A uri, eg:
``'x-sonos-http:track%3a3402413.mp3?sid=2&flags=32&sn=4'``
Returns:
str: The content of a desc element for that uri, eg
``'SA_RINCON519_email@example.c... | [
"def",
"desc_from_uri",
"(",
"uri",
")",
":",
"#",
"# If there is an sn parameter (which is the serial number of an account),",
"# we can obtain all the information we need from that, because we can find",
"# the relevant service_id in the account database (it is the same as the",
"# service_typ... | Create the content of DIDL desc element from a uri.
Args:
uri (str): A uri, eg:
``'x-sonos-http:track%3a3402413.mp3?sid=2&flags=32&sn=4'``
Returns:
str: The content of a desc element for that uri, eg
``'SA_RINCON519_email@example.com'`` | [
"Create",
"the",
"content",
"of",
"DIDL",
"desc",
"element",
"from",
"a",
"uri",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L824-L879 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicServiceSoapClient.get_soap_header | def get_soap_header(self):
"""Generate the SOAP authentication header for the related service.
This header contains all the necessary authentication details.
Returns:
str: A string representation of the XML content of the SOAP
header.
"""
# Accordin... | python | def get_soap_header(self):
"""Generate the SOAP authentication header for the related service.
This header contains all the necessary authentication details.
Returns:
str: A string representation of the XML content of the SOAP
header.
"""
# Accordin... | [
"def",
"get_soap_header",
"(",
"self",
")",
":",
"# According to the SONOS SMAPI, this header must be sent with all",
"# SOAP requests. Building this is an expensive operation (though",
"# occasionally necessary), so f we have a cached value, return it",
"if",
"self",
".",
"_cached_soap_head... | Generate the SOAP authentication header for the related service.
This header contains all the necessary authentication details.
Returns:
str: A string representation of the XML content of the SOAP
header. | [
"Generate",
"the",
"SOAP",
"authentication",
"header",
"for",
"the",
"related",
"service",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L76-L125 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicServiceSoapClient.call | def call(self, method, args=None):
"""Call a method on the server.
Args:
method (str): The name of the method to call.
args (List[Tuple[str, str]] or None): A list of (parameter,
value) pairs representing the parameters of the method.
Defaults to ... | python | def call(self, method, args=None):
"""Call a method on the server.
Args:
method (str): The name of the method to call.
args (List[Tuple[str, str]] or None): A list of (parameter,
value) pairs representing the parameters of the method.
Defaults to ... | [
"def",
"call",
"(",
"self",
",",
"method",
",",
"args",
"=",
"None",
")",
":",
"message",
"=",
"SoapMessage",
"(",
"endpoint",
"=",
"self",
".",
"endpoint",
",",
"method",
"=",
"method",
",",
"parameters",
"=",
"[",
"]",
"if",
"args",
"is",
"None",
... | Call a method on the server.
Args:
method (str): The name of the method to call.
args (List[Tuple[str, str]] or None): A list of (parameter,
value) pairs representing the parameters of the method.
Defaults to `None`.
Returns:
~collect... | [
"Call",
"a",
"method",
"on",
"the",
"server",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L127-L195 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService._get_music_services_data_xml | def _get_music_services_data_xml(soco=None):
"""Fetch the music services data xml from a Sonos device.
Args:
soco (SoCo): a SoCo instance to query. If none is specified, a
random device will be used. Defaults to `None`.
Returns:
str: a string containing the ... | python | def _get_music_services_data_xml(soco=None):
"""Fetch the music services data xml from a Sonos device.
Args:
soco (SoCo): a SoCo instance to query. If none is specified, a
random device will be used. Defaults to `None`.
Returns:
str: a string containing the ... | [
"def",
"_get_music_services_data_xml",
"(",
"soco",
"=",
"None",
")",
":",
"device",
"=",
"soco",
"or",
"discovery",
".",
"any_soco",
"(",
")",
"log",
".",
"debug",
"(",
"\"Fetching music services data from %s\"",
",",
"device",
")",
"available_services",
"=",
"... | Fetch the music services data xml from a Sonos device.
Args:
soco (SoCo): a SoCo instance to query. If none is specified, a
random device will be used. Defaults to `None`.
Returns:
str: a string containing the music services data xml | [
"Fetch",
"the",
"music",
"services",
"data",
"xml",
"from",
"a",
"Sonos",
"device",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L371-L387 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService._get_music_services_data | def _get_music_services_data(cls):
"""Parse raw account data xml into a useful python datastructure.
Returns:
dict: Each key is a service_type, and each value is a
`dict` containing relevant data.
"""
# Return from cache if we have it.
if cls._music_servi... | python | def _get_music_services_data(cls):
"""Parse raw account data xml into a useful python datastructure.
Returns:
dict: Each key is a service_type, and each value is a
`dict` containing relevant data.
"""
# Return from cache if we have it.
if cls._music_servi... | [
"def",
"_get_music_services_data",
"(",
"cls",
")",
":",
"# Return from cache if we have it.",
"if",
"cls",
".",
"_music_services_data",
"is",
"not",
"None",
":",
"return",
"cls",
".",
"_music_services_data",
"result",
"=",
"{",
"}",
"root",
"=",
"XML",
".",
"fr... | Parse raw account data xml into a useful python datastructure.
Returns:
dict: Each key is a service_type, and each value is a
`dict` containing relevant data. | [
"Parse",
"raw",
"account",
"data",
"xml",
"into",
"a",
"useful",
"python",
"datastructure",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L390-L452 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService.get_subscribed_services_names | def get_subscribed_services_names(cls):
"""Get a list of the names of all subscribed music services.
Returns:
list: A list of strings.
"""
# This is very inefficient - loops within loops within loops, and
# many network requests
# Optimise it?
account... | python | def get_subscribed_services_names(cls):
"""Get a list of the names of all subscribed music services.
Returns:
list: A list of strings.
"""
# This is very inefficient - loops within loops within loops, and
# many network requests
# Optimise it?
account... | [
"def",
"get_subscribed_services_names",
"(",
"cls",
")",
":",
"# This is very inefficient - loops within loops within loops, and",
"# many network requests",
"# Optimise it?",
"accounts_for_service",
"=",
"Account",
".",
"get_accounts_for_service",
"service_data",
"=",
"cls",
".",
... | Get a list of the names of all subscribed music services.
Returns:
list: A list of strings. | [
"Get",
"a",
"list",
"of",
"the",
"names",
"of",
"all",
"subscribed",
"music",
"services",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L469-L485 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService.get_data_for_name | def get_data_for_name(cls, service_name):
"""Get the data relating to a named music service.
Args:
service_name (str): The name of the music service for which data
is required.
Returns:
dict: Data relating to the music service.
Raises:
... | python | def get_data_for_name(cls, service_name):
"""Get the data relating to a named music service.
Args:
service_name (str): The name of the music service for which data
is required.
Returns:
dict: Data relating to the music service.
Raises:
... | [
"def",
"get_data_for_name",
"(",
"cls",
",",
"service_name",
")",
":",
"for",
"service",
"in",
"cls",
".",
"_get_music_services_data",
"(",
")",
".",
"values",
"(",
")",
":",
"if",
"service_name",
"==",
"service",
"[",
"\"Name\"",
"]",
":",
"return",
"serv... | Get the data relating to a named music service.
Args:
service_name (str): The name of the music service for which data
is required.
Returns:
dict: Data relating to the music service.
Raises:
`MusicServiceException`: if the music service cann... | [
"Get",
"the",
"data",
"relating",
"to",
"a",
"named",
"music",
"service",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L488-L505 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService._get_search_prefix_map | def _get_search_prefix_map(self):
"""Fetch and parse the service search category mapping.
Standard Sonos search categories are 'all', 'artists', 'albums',
'tracks', 'playlists', 'genres', 'stations', 'tags'. Not all are
available for each music service
"""
# TuneIn does ... | python | def _get_search_prefix_map(self):
"""Fetch and parse the service search category mapping.
Standard Sonos search categories are 'all', 'artists', 'albums',
'tracks', 'playlists', 'genres', 'stations', 'tags'. Not all are
available for each music service
"""
# TuneIn does ... | [
"def",
"_get_search_prefix_map",
"(",
"self",
")",
":",
"# TuneIn does not have a pmap. Its search keys are is search:station,",
"# search:show, search:host",
"# Presentation maps can also define custom categories. See eg",
"# http://sonos-pmap.ws.sonos.com/hypemachine_pmap.6.xml",
"# <SearchCat... | Fetch and parse the service search category mapping.
Standard Sonos search categories are 'all', 'artists', 'albums',
'tracks', 'playlists', 'genres', 'stations', 'tags'. Not all are
available for each music service | [
"Fetch",
"and",
"parse",
"the",
"service",
"search",
"category",
"mapping",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L507-L553 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService.sonos_uri_from_id | def sonos_uri_from_id(self, item_id):
"""Get a uri which can be sent for playing.
Args:
item_id (str): The unique id of a playable item for this music
service, such as that returned in the metadata from
`get_metadata`, eg ``spotify:track:2qs5ZcLByNTctJKbhAZ9J... | python | def sonos_uri_from_id(self, item_id):
"""Get a uri which can be sent for playing.
Args:
item_id (str): The unique id of a playable item for this music
service, such as that returned in the metadata from
`get_metadata`, eg ``spotify:track:2qs5ZcLByNTctJKbhAZ9J... | [
"def",
"sonos_uri_from_id",
"(",
"self",
",",
"item_id",
")",
":",
"# Real Sonos URIs look like this:",
"# x-sonos-http:tr%3a92352286.mp3?sid=2&flags=8224&sn=4 The",
"# extension (.mp3) presumably comes from the mime-type returned in a",
"# MusicService.get_metadata() result (though for Spotif... | Get a uri which can be sent for playing.
Args:
item_id (str): The unique id of a playable item for this music
service, such as that returned in the metadata from
`get_metadata`, eg ``spotify:track:2qs5ZcLByNTctJKbhAZ9JE``
Returns:
str: A URI of t... | [
"Get",
"a",
"uri",
"which",
"can",
"be",
"sent",
"for",
"playing",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L577-L616 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService.get_metadata | def get_metadata(
self, item='root', index=0, count=100, recursive=False):
"""Get metadata for a container or item.
Args:
item (str or MusicServiceItem): The container or item to browse
given either as a MusicServiceItem instance or as a str.
Defa... | python | def get_metadata(
self, item='root', index=0, count=100, recursive=False):
"""Get metadata for a container or item.
Args:
item (str or MusicServiceItem): The container or item to browse
given either as a MusicServiceItem instance or as a str.
Defa... | [
"def",
"get_metadata",
"(",
"self",
",",
"item",
"=",
"'root'",
",",
"index",
"=",
"0",
",",
"count",
"=",
"100",
",",
"recursive",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"MusicServiceItem",
")",
":",
"item_id",
"=",
"item",
".... | Get metadata for a container or item.
Args:
item (str or MusicServiceItem): The container or item to browse
given either as a MusicServiceItem instance or as a str.
Defaults to the root item.
index (int): The starting index. Default 0.
count (... | [
"Get",
"metadata",
"for",
"a",
"container",
"or",
"item",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L661-L693 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService.search | def search(self, category, term='', index=0, count=100):
"""Search for an item in a category.
Args:
category (str): The search category to use. Standard Sonos search
categories are 'artists', 'albums', 'tracks', 'playlists',
'genres', 'stations', 'tags'. Not ... | python | def search(self, category, term='', index=0, count=100):
"""Search for an item in a category.
Args:
category (str): The search category to use. Standard Sonos search
categories are 'artists', 'albums', 'tracks', 'playlists',
'genres', 'stations', 'tags'. Not ... | [
"def",
"search",
"(",
"self",
",",
"category",
",",
"term",
"=",
"''",
",",
"index",
"=",
"0",
",",
"count",
"=",
"100",
")",
":",
"search_category",
"=",
"self",
".",
"_get_search_prefix_map",
"(",
")",
".",
"get",
"(",
"category",
",",
"None",
")",... | Search for an item in a category.
Args:
category (str): The search category to use. Standard Sonos search
categories are 'artists', 'albums', 'tracks', 'playlists',
'genres', 'stations', 'tags'. Not all are available for each
music service. Call avail... | [
"Search",
"for",
"an",
"item",
"in",
"a",
"category",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L695-L726 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService.get_media_metadata | def get_media_metadata(self, item_id):
"""Get metadata for a media item.
Args:
item_id (str): The item for which metadata is required.
Returns:
~collections.OrderedDict: The item's metadata, or `None`
See also:
The Sonos `getMediaMetadata API
... | python | def get_media_metadata(self, item_id):
"""Get metadata for a media item.
Args:
item_id (str): The item for which metadata is required.
Returns:
~collections.OrderedDict: The item's metadata, or `None`
See also:
The Sonos `getMediaMetadata API
... | [
"def",
"get_media_metadata",
"(",
"self",
",",
"item_id",
")",
":",
"response",
"=",
"self",
".",
"soap_client",
".",
"call",
"(",
"'getMediaMetadata'",
",",
"[",
"(",
"'id'",
",",
"item_id",
")",
"]",
")",
"return",
"response",
".",
"get",
"(",
"'getMed... | Get metadata for a media item.
Args:
item_id (str): The item for which metadata is required.
Returns:
~collections.OrderedDict: The item's metadata, or `None`
See also:
The Sonos `getMediaMetadata API
<http://musicpartners.sonos.com/node/83>`_ | [
"Get",
"metadata",
"for",
"a",
"media",
"item",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L728-L744 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService.get_media_uri | def get_media_uri(self, item_id):
"""Get a streaming URI for an item.
Note:
You should not need to use this directly. It is used by the Sonos
players (not the controllers) to obtain the uri of the media
stream. If you want to have a player play a media item,
... | python | def get_media_uri(self, item_id):
"""Get a streaming URI for an item.
Note:
You should not need to use this directly. It is used by the Sonos
players (not the controllers) to obtain the uri of the media
stream. If you want to have a player play a media item,
... | [
"def",
"get_media_uri",
"(",
"self",
",",
"item_id",
")",
":",
"response",
"=",
"self",
".",
"soap_client",
".",
"call",
"(",
"'getMediaURI'",
",",
"[",
"(",
"'id'",
",",
"item_id",
")",
"]",
")",
"return",
"response",
".",
"get",
"(",
"'getMediaURIResul... | Get a streaming URI for an item.
Note:
You should not need to use this directly. It is used by the Sonos
players (not the controllers) to obtain the uri of the media
stream. If you want to have a player play a media item,
you should add add it to the queue using its ... | [
"Get",
"a",
"streaming",
"URI",
"for",
"an",
"item",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L746-L767 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService.get_extended_metadata | def get_extended_metadata(self, item_id):
"""Get extended metadata for a media item, such as related items.
Args:
item_id (str): The item for which metadata is required.
Returns:
~collections.OrderedDict: The item's extended metadata or None.
See also:
... | python | def get_extended_metadata(self, item_id):
"""Get extended metadata for a media item, such as related items.
Args:
item_id (str): The item for which metadata is required.
Returns:
~collections.OrderedDict: The item's extended metadata or None.
See also:
... | [
"def",
"get_extended_metadata",
"(",
"self",
",",
"item_id",
")",
":",
"response",
"=",
"self",
".",
"soap_client",
".",
"call",
"(",
"'getExtendedMetadata'",
",",
"[",
"(",
"'id'",
",",
"item_id",
")",
"]",
")",
"return",
"response",
".",
"get",
"(",
"'... | Get extended metadata for a media item, such as related items.
Args:
item_id (str): The item for which metadata is required.
Returns:
~collections.OrderedDict: The item's extended metadata or None.
See also:
The Sonos `getExtendedMetadata API
<h... | [
"Get",
"extended",
"metadata",
"for",
"a",
"media",
"item",
"such",
"as",
"related",
"items",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L783-L799 | train |
SoCo/SoCo | soco/music_services/music_service.py | MusicService.get_extended_metadata_text | def get_extended_metadata_text(self, item_id, metadata_type):
"""Get extended metadata text for a media item.
Args:
item_id (str): The item for which metadata is required
metadata_type (str): The type of text to return, eg
``'ARTIST_BIO'``, or ``'ALBUM_NOTES'``. Call... | python | def get_extended_metadata_text(self, item_id, metadata_type):
"""Get extended metadata text for a media item.
Args:
item_id (str): The item for which metadata is required
metadata_type (str): The type of text to return, eg
``'ARTIST_BIO'``, or ``'ALBUM_NOTES'``. Call... | [
"def",
"get_extended_metadata_text",
"(",
"self",
",",
"item_id",
",",
"metadata_type",
")",
":",
"response",
"=",
"self",
".",
"soap_client",
".",
"call",
"(",
"'getExtendedMetadataText'",
",",
"[",
"(",
"'id'",
",",
"item_id",
")",
",",
"(",
"'type'",
",",... | Get extended metadata text for a media item.
Args:
item_id (str): The item for which metadata is required
metadata_type (str): The type of text to return, eg
``'ARTIST_BIO'``, or ``'ALBUM_NOTES'``. Calling
`get_extended_metadata` for the item will show which exte... | [
"Get",
"extended",
"metadata",
"text",
"for",
"a",
"media",
"item",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/music_service.py#L801-L821 | train |
SoCo/SoCo | soco/music_services/data_structures.py | get_class | def get_class(class_key):
"""Form a music service data structure class from the class key
Args:
class_key (str): A concatenation of the base class (e.g. MediaMetadata)
and the class name
Returns:
class: Subclass of MusicServiceItem
"""
if class_key not in CLASSES:
... | python | def get_class(class_key):
"""Form a music service data structure class from the class key
Args:
class_key (str): A concatenation of the base class (e.g. MediaMetadata)
and the class name
Returns:
class: Subclass of MusicServiceItem
"""
if class_key not in CLASSES:
... | [
"def",
"get_class",
"(",
"class_key",
")",
":",
"if",
"class_key",
"not",
"in",
"CLASSES",
":",
"for",
"basecls",
"in",
"(",
"MediaMetadata",
",",
"MediaCollection",
")",
":",
"if",
"class_key",
".",
"startswith",
"(",
"basecls",
".",
"__name__",
")",
":",... | Form a music service data structure class from the class key
Args:
class_key (str): A concatenation of the base class (e.g. MediaMetadata)
and the class name
Returns:
class: Subclass of MusicServiceItem | [
"Form",
"a",
"music",
"service",
"data",
"structure",
"class",
"from",
"the",
"class",
"key"
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/data_structures.py#L80-L99 | train |
SoCo/SoCo | soco/music_services/data_structures.py | parse_response | def parse_response(service, response, search_type):
"""Parse the response to a music service query and return a SearchResult
Args:
service (MusicService): The music service that produced the response
response (OrderedDict): The response from the soap client call
search_type (str): A str... | python | def parse_response(service, response, search_type):
"""Parse the response to a music service query and return a SearchResult
Args:
service (MusicService): The music service that produced the response
response (OrderedDict): The response from the soap client call
search_type (str): A str... | [
"def",
"parse_response",
"(",
"service",
",",
"response",
",",
"search_type",
")",
":",
"_LOG",
".",
"debug",
"(",
"'Parse response \"%s\" from service \"%s\" of type \"%s\"'",
",",
"response",
",",
"service",
",",
"search_type",
")",
"items",
"=",
"[",
"]",
"# Th... | Parse the response to a music service query and return a SearchResult
Args:
service (MusicService): The music service that produced the response
response (OrderedDict): The response from the soap client call
search_type (str): A string that indicates the search type that the
res... | [
"Parse",
"the",
"response",
"to",
"a",
"music",
"service",
"query",
"and",
"return",
"a",
"SearchResult"
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/data_structures.py#L102-L149 | train |
SoCo/SoCo | soco/music_services/data_structures.py | form_uri | def form_uri(item_id, service, is_track):
"""Form and return a music service item uri
Args:
item_id (str): The item id
service (MusicService): The music service that the item originates from
is_track (bool): Whether the item_id is from a track or not
Returns:
str: The music... | python | def form_uri(item_id, service, is_track):
"""Form and return a music service item uri
Args:
item_id (str): The item id
service (MusicService): The music service that the item originates from
is_track (bool): Whether the item_id is from a track or not
Returns:
str: The music... | [
"def",
"form_uri",
"(",
"item_id",
",",
"service",
",",
"is_track",
")",
":",
"if",
"is_track",
":",
"uri",
"=",
"service",
".",
"sonos_uri_from_id",
"(",
"item_id",
")",
"else",
":",
"uri",
"=",
"'x-rincon-cpcontainer:'",
"+",
"item_id",
"return",
"uri"
] | Form and return a music service item uri
Args:
item_id (str): The item id
service (MusicService): The music service that the item originates from
is_track (bool): Whether the item_id is from a track or not
Returns:
str: The music service item uri | [
"Form",
"and",
"return",
"a",
"music",
"service",
"item",
"uri"
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/data_structures.py#L152-L167 | train |
SoCo/SoCo | soco/music_services/data_structures.py | bool_str | def bool_str(string):
"""Returns a boolean from a string imput of 'true' or 'false'"""
if string not in BOOL_STRS:
raise ValueError('Invalid boolean string: "{}"'.format(string))
return True if string == 'true' else False | python | def bool_str(string):
"""Returns a boolean from a string imput of 'true' or 'false'"""
if string not in BOOL_STRS:
raise ValueError('Invalid boolean string: "{}"'.format(string))
return True if string == 'true' else False | [
"def",
"bool_str",
"(",
"string",
")",
":",
"if",
"string",
"not",
"in",
"BOOL_STRS",
":",
"raise",
"ValueError",
"(",
"'Invalid boolean string: \"{}\"'",
".",
"format",
"(",
"string",
")",
")",
"return",
"True",
"if",
"string",
"==",
"'true'",
"else",
"Fals... | Returns a boolean from a string imput of 'true' or 'false | [
"Returns",
"a",
"boolean",
"from",
"a",
"string",
"imput",
"of",
"true",
"or",
"false"
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/data_structures.py#L174-L178 | train |
SoCo/SoCo | soco/music_services/accounts.py | Account._get_account_xml | def _get_account_xml(soco):
"""Fetch the account data from a Sonos device.
Args:
soco (SoCo): a SoCo instance to query. If soco is `None`, a
random device will be used.
Returns:
str: a byte string containing the account data xml
"""
# It ... | python | def _get_account_xml(soco):
"""Fetch the account data from a Sonos device.
Args:
soco (SoCo): a SoCo instance to query. If soco is `None`, a
random device will be used.
Returns:
str: a byte string containing the account data xml
"""
# It ... | [
"def",
"_get_account_xml",
"(",
"soco",
")",
":",
"# It is likely that the same information is available over UPnP as well",
"# via a call to",
"# systemProperties.GetStringX([('VariableName','R_SvcAccounts')]))",
"# This returns an encrypted string, and, so far, we cannot decrypt it",
"device",... | Fetch the account data from a Sonos device.
Args:
soco (SoCo): a SoCo instance to query. If soco is `None`, a
random device will be used.
Returns:
str: a byte string containing the account data xml | [
"Fetch",
"the",
"account",
"data",
"from",
"a",
"Sonos",
"device",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/accounts.py#L67-L87 | train |
SoCo/SoCo | soco/music_services/accounts.py | Account.get_accounts | def get_accounts(cls, soco=None):
"""Get all accounts known to the Sonos system.
Args:
soco (`SoCo`, optional): a `SoCo` instance to query. If `None`, a
random instance is used. Defaults to `None`.
Returns:
dict: A dict containing account instances. Each... | python | def get_accounts(cls, soco=None):
"""Get all accounts known to the Sonos system.
Args:
soco (`SoCo`, optional): a `SoCo` instance to query. If `None`, a
random instance is used. Defaults to `None`.
Returns:
dict: A dict containing account instances. Each... | [
"def",
"get_accounts",
"(",
"cls",
",",
"soco",
"=",
"None",
")",
":",
"root",
"=",
"XML",
".",
"fromstring",
"(",
"cls",
".",
"_get_account_xml",
"(",
"soco",
")",
")",
"# _get_account_xml returns an ElementTree element like this:",
"# <ZPSupportInfo type=\"User\">",... | Get all accounts known to the Sonos system.
Args:
soco (`SoCo`, optional): a `SoCo` instance to query. If `None`, a
random instance is used. Defaults to `None`.
Returns:
dict: A dict containing account instances. Each key is the
account's serial numb... | [
"Get",
"all",
"accounts",
"known",
"to",
"the",
"Sonos",
"system",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/accounts.py#L90-L187 | train |
SoCo/SoCo | soco/music_services/accounts.py | Account.get_accounts_for_service | def get_accounts_for_service(cls, service_type):
"""Get a list of accounts for a given music service.
Args:
service_type (str): The service_type to use.
Returns:
list: A list of `Account` instances.
"""
return [
a for a in cls.get_accounts().... | python | def get_accounts_for_service(cls, service_type):
"""Get a list of accounts for a given music service.
Args:
service_type (str): The service_type to use.
Returns:
list: A list of `Account` instances.
"""
return [
a for a in cls.get_accounts().... | [
"def",
"get_accounts_for_service",
"(",
"cls",
",",
"service_type",
")",
":",
"return",
"[",
"a",
"for",
"a",
"in",
"cls",
".",
"get_accounts",
"(",
")",
".",
"values",
"(",
")",
"if",
"a",
".",
"service_type",
"==",
"service_type",
"]"
] | Get a list of accounts for a given music service.
Args:
service_type (str): The service_type to use.
Returns:
list: A list of `Account` instances. | [
"Get",
"a",
"list",
"of",
"accounts",
"for",
"a",
"given",
"music",
"service",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_services/accounts.py#L190-L202 | train |
SoCo/SoCo | examples/snapshot/multi_zone_snap.py | play_alert | def play_alert(zones, alert_uri, alert_volume=20, alert_duration=0, fade_back=False):
"""
Demo function using soco.snapshot across multiple Sonos players.
Args:
zones (set): a set of SoCo objects
alert_uri (str): uri that Sonos can play as an alert
alert_volume (int): volume level f... | python | def play_alert(zones, alert_uri, alert_volume=20, alert_duration=0, fade_back=False):
"""
Demo function using soco.snapshot across multiple Sonos players.
Args:
zones (set): a set of SoCo objects
alert_uri (str): uri that Sonos can play as an alert
alert_volume (int): volume level f... | [
"def",
"play_alert",
"(",
"zones",
",",
"alert_uri",
",",
"alert_volume",
"=",
"20",
",",
"alert_duration",
"=",
"0",
",",
"fade_back",
"=",
"False",
")",
":",
"# Use soco.snapshot to capture current state of each zone to allow restore",
"for",
"zone",
"in",
"zones",
... | Demo function using soco.snapshot across multiple Sonos players.
Args:
zones (set): a set of SoCo objects
alert_uri (str): uri that Sonos can play as an alert
alert_volume (int): volume level for playing alert (0 tp 100)
alert_duration (int): length of alert (if zero then length of ... | [
"Demo",
"function",
"using",
"soco",
".",
"snapshot",
"across",
"multiple",
"Sonos",
"players",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/examples/snapshot/multi_zone_snap.py#L27-L71 | train |
SoCo/SoCo | soco/cache.py | TimedCache.get | def get(self, *args, **kwargs):
"""Get an item from the cache for this combination of args and kwargs.
Args:
*args: any arguments.
**kwargs: any keyword arguments.
Returns:
object: The object which has been found in the cache, or `None` if
no une... | python | def get(self, *args, **kwargs):
"""Get an item from the cache for this combination of args and kwargs.
Args:
*args: any arguments.
**kwargs: any keyword arguments.
Returns:
object: The object which has been found in the cache, or `None` if
no une... | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"enabled",
":",
"return",
"None",
"# Look in the cache to see if there is an unexpired item. If there is",
"# we can just return the cached result.",
"cache_key",
... | Get an item from the cache for this combination of args and kwargs.
Args:
*args: any arguments.
**kwargs: any keyword arguments.
Returns:
object: The object which has been found in the cache, or `None` if
no unexpired item is found. This means that there... | [
"Get",
"an",
"item",
"from",
"the",
"cache",
"for",
"this",
"combination",
"of",
"args",
"and",
"kwargs",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/cache.py#L117-L146 | train |
SoCo/SoCo | soco/cache.py | TimedCache.put | def put(self, item, *args, **kwargs):
"""Put an item into the cache, for this combination of args and kwargs.
Args:
*args: any arguments.
**kwargs: any keyword arguments. If ``timeout`` is specified as one
of the keyword arguments, the item will remain available... | python | def put(self, item, *args, **kwargs):
"""Put an item into the cache, for this combination of args and kwargs.
Args:
*args: any arguments.
**kwargs: any keyword arguments. If ``timeout`` is specified as one
of the keyword arguments, the item will remain available... | [
"def",
"put",
"(",
"self",
",",
"item",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"enabled",
":",
"return",
"# Check for a timeout keyword, store and remove it.",
"timeout",
"=",
"kwargs",
".",
"pop",
"(",
"'timeout'",
... | Put an item into the cache, for this combination of args and kwargs.
Args:
*args: any arguments.
**kwargs: any keyword arguments. If ``timeout`` is specified as one
of the keyword arguments, the item will remain available
for retrieval for ``timeout`` s... | [
"Put",
"an",
"item",
"into",
"the",
"cache",
"for",
"this",
"combination",
"of",
"args",
"and",
"kwargs",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/cache.py#L148-L170 | train |
SoCo/SoCo | soco/cache.py | TimedCache.delete | def delete(self, *args, **kwargs):
"""Delete an item from the cache for this combination of args and
kwargs."""
cache_key = self.make_key(args, kwargs)
with self._cache_lock:
try:
del self._cache[cache_key]
except KeyError:
pass | python | def delete(self, *args, **kwargs):
"""Delete an item from the cache for this combination of args and
kwargs."""
cache_key = self.make_key(args, kwargs)
with self._cache_lock:
try:
del self._cache[cache_key]
except KeyError:
pass | [
"def",
"delete",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cache_key",
"=",
"self",
".",
"make_key",
"(",
"args",
",",
"kwargs",
")",
"with",
"self",
".",
"_cache_lock",
":",
"try",
":",
"del",
"self",
".",
"_cache",
"[",
... | Delete an item from the cache for this combination of args and
kwargs. | [
"Delete",
"an",
"item",
"from",
"the",
"cache",
"for",
"this",
"combination",
"of",
"args",
"and",
"kwargs",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/cache.py#L172-L180 | train |
SoCo/SoCo | soco/music_library.py | MusicLibrary.build_album_art_full_uri | def build_album_art_full_uri(self, url):
"""Ensure an Album Art URI is an absolute URI.
Args:
url (str): the album art URI.
Returns:
str: An absolute URI.
"""
# Add on the full album art link, as the URI version
# does not include the ipaddress
... | python | def build_album_art_full_uri(self, url):
"""Ensure an Album Art URI is an absolute URI.
Args:
url (str): the album art URI.
Returns:
str: An absolute URI.
"""
# Add on the full album art link, as the URI version
# does not include the ipaddress
... | [
"def",
"build_album_art_full_uri",
"(",
"self",
",",
"url",
")",
":",
"# Add on the full album art link, as the URI version",
"# does not include the ipaddress",
"if",
"not",
"url",
".",
"startswith",
"(",
"(",
"'http:'",
",",
"'https:'",
")",
")",
":",
"url",
"=",
... | Ensure an Album Art URI is an absolute URI.
Args:
url (str): the album art URI.
Returns:
str: An absolute URI. | [
"Ensure",
"an",
"Album",
"Art",
"URI",
"is",
"an",
"absolute",
"URI",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_library.py#L59-L72 | train |
SoCo/SoCo | soco/music_library.py | MusicLibrary._update_album_art_to_full_uri | def _update_album_art_to_full_uri(self, item):
"""Update an item's Album Art URI to be an absolute URI.
Args:
item: The item to update the URI for
"""
if getattr(item, 'album_art_uri', False):
item.album_art_uri = self.build_album_art_full_uri(
it... | python | def _update_album_art_to_full_uri(self, item):
"""Update an item's Album Art URI to be an absolute URI.
Args:
item: The item to update the URI for
"""
if getattr(item, 'album_art_uri', False):
item.album_art_uri = self.build_album_art_full_uri(
it... | [
"def",
"_update_album_art_to_full_uri",
"(",
"self",
",",
"item",
")",
":",
"if",
"getattr",
"(",
"item",
",",
"'album_art_uri'",
",",
"False",
")",
":",
"item",
".",
"album_art_uri",
"=",
"self",
".",
"build_album_art_full_uri",
"(",
"item",
".",
"album_art_u... | Update an item's Album Art URI to be an absolute URI.
Args:
item: The item to update the URI for | [
"Update",
"an",
"item",
"s",
"Album",
"Art",
"URI",
"to",
"be",
"an",
"absolute",
"URI",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_library.py#L74-L82 | train |
SoCo/SoCo | soco/music_library.py | MusicLibrary.get_music_library_information | def get_music_library_information(self, search_type, start=0,
max_items=100, full_album_art_uri=False,
search_term=None, subcategories=None,
complete_result=False):
"""Retrieve music information obj... | python | def get_music_library_information(self, search_type, start=0,
max_items=100, full_album_art_uri=False,
search_term=None, subcategories=None,
complete_result=False):
"""Retrieve music information obj... | [
"def",
"get_music_library_information",
"(",
"self",
",",
"search_type",
",",
"start",
"=",
"0",
",",
"max_items",
"=",
"100",
",",
"full_album_art_uri",
"=",
"False",
",",
"search_term",
"=",
"None",
",",
"subcategories",
"=",
"None",
",",
"complete_result",
... | Retrieve music information objects from the music library.
This method is the main method to get music information items, like
e.g. tracks, albums etc., from the music library with. It can be used
in a few different ways:
The ``search_term`` argument performs a fuzzy search on that str... | [
"Retrieve",
"music",
"information",
"objects",
"from",
"the",
"music",
"library",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_library.py#L188-L334 | train |
SoCo/SoCo | soco/music_library.py | MusicLibrary._music_lib_search | def _music_lib_search(self, search, start, max_items):
"""Perform a music library search and extract search numbers.
You can get an overview of all the relevant search prefixes (like
'A:') and their meaning with the request:
.. code ::
response = device.contentDirectory.Brows... | python | def _music_lib_search(self, search, start, max_items):
"""Perform a music library search and extract search numbers.
You can get an overview of all the relevant search prefixes (like
'A:') and their meaning with the request:
.. code ::
response = device.contentDirectory.Brows... | [
"def",
"_music_lib_search",
"(",
"self",
",",
"search",
",",
"start",
",",
"max_items",
")",
":",
"response",
"=",
"self",
".",
"contentDirectory",
".",
"Browse",
"(",
"[",
"(",
"'ObjectID'",
",",
"search",
")",
",",
"(",
"'BrowseFlag'",
",",
"'BrowseDirec... | Perform a music library search and extract search numbers.
You can get an overview of all the relevant search prefixes (like
'A:') and their meaning with the request:
.. code ::
response = device.contentDirectory.Browse([
('ObjectID', '0'),
('BrowseFlag', 'B... | [
"Perform",
"a",
"music",
"library",
"search",
"and",
"extract",
"search",
"numbers",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_library.py#L446-L486 | train |
SoCo/SoCo | soco/music_library.py | MusicLibrary.search_track | def search_track(self, artist, album=None, track=None,
full_album_art_uri=False):
"""Search for an artist, an artist's albums, or specific track.
Args:
artist (str): an artist's name.
album (str, optional): an album name. Default `None`.
track (s... | python | def search_track(self, artist, album=None, track=None,
full_album_art_uri=False):
"""Search for an artist, an artist's albums, or specific track.
Args:
artist (str): an artist's name.
album (str, optional): an album name. Default `None`.
track (s... | [
"def",
"search_track",
"(",
"self",
",",
"artist",
",",
"album",
"=",
"None",
",",
"track",
"=",
"None",
",",
"full_album_art_uri",
"=",
"False",
")",
":",
"subcategories",
"=",
"[",
"artist",
"]",
"subcategories",
".",
"append",
"(",
"album",
"or",
"''"... | Search for an artist, an artist's albums, or specific track.
Args:
artist (str): an artist's name.
album (str, optional): an album name. Default `None`.
track (str, optional): a track name. Default `None`.
full_album_art_uri (bool): whether the album art URI shou... | [
"Search",
"for",
"an",
"artist",
"an",
"artist",
"s",
"albums",
"or",
"specific",
"track",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_library.py#L506-L529 | train |
SoCo/SoCo | soco/music_library.py | MusicLibrary.get_albums_for_artist | def get_albums_for_artist(self, artist, full_album_art_uri=False):
"""Get an artist's albums.
Args:
artist (str): an artist's name.
full_album_art_uri: whether the album art URI should be
absolute (i.e. including the IP address). Default `False`.
Returns... | python | def get_albums_for_artist(self, artist, full_album_art_uri=False):
"""Get an artist's albums.
Args:
artist (str): an artist's name.
full_album_art_uri: whether the album art URI should be
absolute (i.e. including the IP address). Default `False`.
Returns... | [
"def",
"get_albums_for_artist",
"(",
"self",
",",
"artist",
",",
"full_album_art_uri",
"=",
"False",
")",
":",
"subcategories",
"=",
"[",
"artist",
"]",
"result",
"=",
"self",
".",
"get_album_artists",
"(",
"full_album_art_uri",
"=",
"full_album_art_uri",
",",
"... | Get an artist's albums.
Args:
artist (str): an artist's name.
full_album_art_uri: whether the album art URI should be
absolute (i.e. including the IP address). Default `False`.
Returns:
A `SearchResult` instance. | [
"Get",
"an",
"artist",
"s",
"albums",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_library.py#L531-L558 | train |
SoCo/SoCo | soco/music_library.py | MusicLibrary.get_tracks_for_album | def get_tracks_for_album(self, artist, album, full_album_art_uri=False):
"""Get the tracks of an artist's album.
Args:
artist (str): an artist's name.
album (str): an album name.
full_album_art_uri: whether the album art URI should be
absolute (i.e. i... | python | def get_tracks_for_album(self, artist, album, full_album_art_uri=False):
"""Get the tracks of an artist's album.
Args:
artist (str): an artist's name.
album (str): an album name.
full_album_art_uri: whether the album art URI should be
absolute (i.e. i... | [
"def",
"get_tracks_for_album",
"(",
"self",
",",
"artist",
",",
"album",
",",
"full_album_art_uri",
"=",
"False",
")",
":",
"subcategories",
"=",
"[",
"artist",
",",
"album",
"]",
"result",
"=",
"self",
".",
"get_album_artists",
"(",
"full_album_art_uri",
"=",... | Get the tracks of an artist's album.
Args:
artist (str): an artist's name.
album (str): an album name.
full_album_art_uri: whether the album art URI should be
absolute (i.e. including the IP address). Default `False`.
Returns:
A `SearchRe... | [
"Get",
"the",
"tracks",
"of",
"an",
"artist",
"s",
"album",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/music_library.py#L560-L578 | train |
SoCo/SoCo | soco/discovery.py | any_soco | def any_soco():
"""Return any visible soco device, for when it doesn't matter which.
Try to obtain an existing instance, or use `discover` if necessary.
Note that this assumes that the existing instance has not left
the network.
Returns:
SoCo: A `SoCo` instance (or subclass if `config.SOCO... | python | def any_soco():
"""Return any visible soco device, for when it doesn't matter which.
Try to obtain an existing instance, or use `discover` if necessary.
Note that this assumes that the existing instance has not left
the network.
Returns:
SoCo: A `SoCo` instance (or subclass if `config.SOCO... | [
"def",
"any_soco",
"(",
")",
":",
"cls",
"=",
"config",
".",
"SOCO_CLASS",
"# pylint: disable=no-member, protected-access",
"try",
":",
"# Try to get the first pre-existing soco instance we know about,",
"# as long as it is visible (i.e. not a bridge etc). Otherwise,",
"# perform disco... | Return any visible soco device, for when it doesn't matter which.
Try to obtain an existing instance, or use `discover` if necessary.
Note that this assumes that the existing instance has not left
the network.
Returns:
SoCo: A `SoCo` instance (or subclass if `config.SOCO_CLASS` is set,
... | [
"Return",
"any",
"visible",
"soco",
"device",
"for",
"when",
"it",
"doesn",
"t",
"matter",
"which",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/discovery.py#L188-L213 | train |
SoCo/SoCo | soco/services.py | Service.wrap_arguments | def wrap_arguments(args=None):
"""Wrap a list of tuples in xml ready to pass into a SOAP request.
Args:
args (list): a list of (name, value) tuples specifying the
name of each argument and its value, eg
``[('InstanceID', 0), ('Speed', 1)]``. The value
... | python | def wrap_arguments(args=None):
"""Wrap a list of tuples in xml ready to pass into a SOAP request.
Args:
args (list): a list of (name, value) tuples specifying the
name of each argument and its value, eg
``[('InstanceID', 0), ('Speed', 1)]``. The value
... | [
"def",
"wrap_arguments",
"(",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"[",
"]",
"tags",
"=",
"[",
"]",
"for",
"name",
",",
"value",
"in",
"args",
":",
"tag",
"=",
"\"<{name}>{value}</{name}>\"",
".",
"format",
"("... | Wrap a list of tuples in xml ready to pass into a SOAP request.
Args:
args (list): a list of (name, value) tuples specifying the
name of each argument and its value, eg
``[('InstanceID', 0), ('Speed', 1)]``. The value
can be a string or something wit... | [
"Wrap",
"a",
"list",
"of",
"tuples",
"in",
"xml",
"ready",
"to",
"pass",
"into",
"a",
"SOAP",
"request",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L233-L263 | train |
SoCo/SoCo | soco/services.py | Service.unwrap_arguments | def unwrap_arguments(xml_response):
"""Extract arguments and their values from a SOAP response.
Args:
xml_response (str): SOAP/xml response text (unicode,
not utf-8).
Returns:
dict: a dict of ``{argument_name: value}`` items.
"""
# A UP... | python | def unwrap_arguments(xml_response):
"""Extract arguments and their values from a SOAP response.
Args:
xml_response (str): SOAP/xml response text (unicode,
not utf-8).
Returns:
dict: a dict of ``{argument_name: value}`` items.
"""
# A UP... | [
"def",
"unwrap_arguments",
"(",
"xml_response",
")",
":",
"# A UPnP SOAP response (including headers) looks like this:",
"# HTTP/1.1 200 OK",
"# CONTENT-LENGTH: bytes in body",
"# CONTENT-TYPE: text/xml; charset=\"utf-8\" DATE: when response was",
"# generated",
"# EXT:",
"# SERVER: OS/versi... | Extract arguments and their values from a SOAP response.
Args:
xml_response (str): SOAP/xml response text (unicode,
not utf-8).
Returns:
dict: a dict of ``{argument_name: value}`` items. | [
"Extract",
"arguments",
"and",
"their",
"values",
"from",
"a",
"SOAP",
"response",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L266-L316 | train |
SoCo/SoCo | soco/services.py | Service.compose_args | def compose_args(self, action_name, in_argdict):
"""Compose the argument list from an argument dictionary, with
respect for default values.
Args:
action_name (str): The name of the action to be performed.
in_argdict (dict): Arguments as a dict, eg
``{'Ins... | python | def compose_args(self, action_name, in_argdict):
"""Compose the argument list from an argument dictionary, with
respect for default values.
Args:
action_name (str): The name of the action to be performed.
in_argdict (dict): Arguments as a dict, eg
``{'Ins... | [
"def",
"compose_args",
"(",
"self",
",",
"action_name",
",",
"in_argdict",
")",
":",
"for",
"action",
"in",
"self",
".",
"actions",
":",
"if",
"action",
".",
"name",
"==",
"action_name",
":",
"# The found 'action' will be visible from outside the loop",
"break",
"... | Compose the argument list from an argument dictionary, with
respect for default values.
Args:
action_name (str): The name of the action to be performed.
in_argdict (dict): Arguments as a dict, eg
``{'InstanceID': 0, 'Speed': 1}. The values
can be ... | [
"Compose",
"the",
"argument",
"list",
"from",
"an",
"argument",
"dictionary",
"with",
"respect",
"for",
"default",
"values",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L318-L371 | train |
SoCo/SoCo | soco/services.py | Service.build_command | def build_command(self, action, args=None):
"""Build a SOAP request.
Args:
action (str): the name of an action (a string as specified in the
service description XML file) to be sent.
args (list, optional): Relevant arguments as a list of (name,
va... | python | def build_command(self, action, args=None):
"""Build a SOAP request.
Args:
action (str): the name of an action (a string as specified in the
service description XML file) to be sent.
args (list, optional): Relevant arguments as a list of (name,
va... | [
"def",
"build_command",
"(",
"self",
",",
"action",
",",
"args",
"=",
"None",
")",
":",
"# A complete request should look something like this:",
"# POST path of control URL HTTP/1.1",
"# HOST: host of control URL:port of control URL",
"# CONTENT-LENGTH: bytes in body",
"# CONTENT-TYP... | Build a SOAP request.
Args:
action (str): the name of an action (a string as specified in the
service description XML file) to be sent.
args (list, optional): Relevant arguments as a list of (name,
value) tuples.
Returns:
tuple: a tup... | [
"Build",
"a",
"SOAP",
"request",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L373-L424 | train |
SoCo/SoCo | soco/services.py | Service.send_command | def send_command(self, action, args=None, cache=None, cache_timeout=None,
**kwargs):
"""Send a command to a Sonos device.
Args:
action (str): the name of an action (a string as specified in the
service description XML file) to be sent.
args (... | python | def send_command(self, action, args=None, cache=None, cache_timeout=None,
**kwargs):
"""Send a command to a Sonos device.
Args:
action (str): the name of an action (a string as specified in the
service description XML file) to be sent.
args (... | [
"def",
"send_command",
"(",
"self",
",",
"action",
",",
"args",
"=",
"None",
",",
"cache",
"=",
"None",
",",
"cache_timeout",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"self",
".",
"compose_args",
... | Send a command to a Sonos device.
Args:
action (str): the name of an action (a string as specified in the
service description XML file) to be sent.
args (list, optional): Relevant arguments as a list of (name,
value) tuples, as an alternative to ``kwargs`... | [
"Send",
"a",
"command",
"to",
"a",
"Sonos",
"device",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L426-L506 | train |
SoCo/SoCo | soco/services.py | Service.handle_upnp_error | def handle_upnp_error(self, xml_error):
"""Disect a UPnP error, and raise an appropriate exception.
Args:
xml_error (str): a unicode string containing the body of the
UPnP/SOAP Fault response. Raises an exception containing the
error code.
"""
... | python | def handle_upnp_error(self, xml_error):
"""Disect a UPnP error, and raise an appropriate exception.
Args:
xml_error (str): a unicode string containing the body of the
UPnP/SOAP Fault response. Raises an exception containing the
error code.
"""
... | [
"def",
"handle_upnp_error",
"(",
"self",
",",
"xml_error",
")",
":",
"# An error code looks something like this:",
"# HTTP/1.1 500 Internal Server Error",
"# CONTENT-LENGTH: bytes in body",
"# CONTENT-TYPE: text/xml; charset=\"utf-8\"",
"# DATE: when response was generated",
"# EXT:",
"#... | Disect a UPnP error, and raise an appropriate exception.
Args:
xml_error (str): a unicode string containing the body of the
UPnP/SOAP Fault response. Raises an exception containing the
error code. | [
"Disect",
"a",
"UPnP",
"error",
"and",
"raise",
"an",
"appropriate",
"exception",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L508-L565 | train |
SoCo/SoCo | soco/services.py | Service.subscribe | def subscribe(
self, requested_timeout=None, auto_renew=False, event_queue=None):
"""Subscribe to the service's events.
Args:
requested_timeout (int, optional): If requested_timeout is
provided, a subscription valid for that
number of seconds will... | python | def subscribe(
self, requested_timeout=None, auto_renew=False, event_queue=None):
"""Subscribe to the service's events.
Args:
requested_timeout (int, optional): If requested_timeout is
provided, a subscription valid for that
number of seconds will... | [
"def",
"subscribe",
"(",
"self",
",",
"requested_timeout",
"=",
"None",
",",
"auto_renew",
"=",
"False",
",",
"event_queue",
"=",
"None",
")",
":",
"subscription",
"=",
"Subscription",
"(",
"self",
",",
"event_queue",
")",
"subscription",
".",
"subscribe",
"... | Subscribe to the service's events.
Args:
requested_timeout (int, optional): If requested_timeout is
provided, a subscription valid for that
number of seconds will be requested, but not guaranteed. Check
`Subscription.timeout` on return to find out wha... | [
"Subscribe",
"to",
"the",
"service",
"s",
"events",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L567-L595 | train |
SoCo/SoCo | soco/services.py | Service.actions | def actions(self):
"""The service's actions with their arguments.
Returns:
list(`Action`): A list of Action namedtuples, consisting of
action_name (str), in_args (list of Argument namedtuples,
consisting of name and argtype), and out_args (ditto).
The return... | python | def actions(self):
"""The service's actions with their arguments.
Returns:
list(`Action`): A list of Action namedtuples, consisting of
action_name (str), in_args (list of Argument namedtuples,
consisting of name and argtype), and out_args (ditto).
The return... | [
"def",
"actions",
"(",
"self",
")",
":",
"if",
"self",
".",
"_actions",
"is",
"None",
":",
"self",
".",
"_actions",
"=",
"list",
"(",
"self",
".",
"iter_actions",
"(",
")",
")",
"return",
"self",
".",
"_actions"
] | The service's actions with their arguments.
Returns:
list(`Action`): A list of Action namedtuples, consisting of
action_name (str), in_args (list of Argument namedtuples,
consisting of name and argtype), and out_args (ditto).
The return value looks like this::
... | [
"The",
"service",
"s",
"actions",
"with",
"their",
"arguments",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L616-L650 | train |
SoCo/SoCo | soco/services.py | Service.event_vars | def event_vars(self):
"""The service's eventable variables.
Returns:
list(tuple): A list of (variable name, data type) tuples.
"""
if self._event_vars is None:
self._event_vars = list(self.iter_event_vars())
return self._event_vars | python | def event_vars(self):
"""The service's eventable variables.
Returns:
list(tuple): A list of (variable name, data type) tuples.
"""
if self._event_vars is None:
self._event_vars = list(self.iter_event_vars())
return self._event_vars | [
"def",
"event_vars",
"(",
"self",
")",
":",
"if",
"self",
".",
"_event_vars",
"is",
"None",
":",
"self",
".",
"_event_vars",
"=",
"list",
"(",
"self",
".",
"iter_event_vars",
"(",
")",
")",
"return",
"self",
".",
"_event_vars"
] | The service's eventable variables.
Returns:
list(tuple): A list of (variable name, data type) tuples. | [
"The",
"service",
"s",
"eventable",
"variables",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L719-L727 | train |
SoCo/SoCo | soco/services.py | Service.iter_event_vars | def iter_event_vars(self):
"""Yield the services eventable variables.
Yields:
`tuple`: a tuple of (variable name, data type).
"""
# pylint: disable=invalid-name
ns = '{urn:schemas-upnp-org:service-1-0}'
scpd_body = requests.get(self.base_url + self.scpd_url)... | python | def iter_event_vars(self):
"""Yield the services eventable variables.
Yields:
`tuple`: a tuple of (variable name, data type).
"""
# pylint: disable=invalid-name
ns = '{urn:schemas-upnp-org:service-1-0}'
scpd_body = requests.get(self.base_url + self.scpd_url)... | [
"def",
"iter_event_vars",
"(",
"self",
")",
":",
"# pylint: disable=invalid-name",
"ns",
"=",
"'{urn:schemas-upnp-org:service-1-0}'",
"scpd_body",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"base_url",
"+",
"self",
".",
"scpd_url",
")",
".",
"text",
"tree",
... | Yield the services eventable variables.
Yields:
`tuple`: a tuple of (variable name, data type). | [
"Yield",
"the",
"services",
"eventable",
"variables",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L729-L748 | train |
SoCo/SoCo | soco/services.py | ZoneGroupTopology.GetZoneGroupState | def GetZoneGroupState(self, *args, **kwargs):
"""Overrides default handling to use the global shared zone group state
cache, unless another cache is specified."""
kwargs['cache'] = kwargs.get('cache', zone_group_state_shared_cache)
return self.send_command('GetZoneGroupState', *args, **k... | python | def GetZoneGroupState(self, *args, **kwargs):
"""Overrides default handling to use the global shared zone group state
cache, unless another cache is specified."""
kwargs['cache'] = kwargs.get('cache', zone_group_state_shared_cache)
return self.send_command('GetZoneGroupState', *args, **k... | [
"def",
"GetZoneGroupState",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'cache'",
"]",
"=",
"kwargs",
".",
"get",
"(",
"'cache'",
",",
"zone_group_state_shared_cache",
")",
"return",
"self",
".",
"send_command",
"(",
... | Overrides default handling to use the global shared zone group state
cache, unless another cache is specified. | [
"Overrides",
"default",
"handling",
"to",
"use",
"the",
"global",
"shared",
"zone",
"group",
"state",
"cache",
"unless",
"another",
"cache",
"is",
"specified",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L786-L790 | train |
SoCo/SoCo | examples/play_local_files/play_local_files.py | add_random_file_from_present_folder | def add_random_file_from_present_folder(machine_ip, port, zone):
"""Add a random non-py file from this folder and subfolders to soco"""
# Make a list of music files, right now it is done by collection all files
# below the current folder whose extension does not start with .py
# This will probably need ... | python | def add_random_file_from_present_folder(machine_ip, port, zone):
"""Add a random non-py file from this folder and subfolders to soco"""
# Make a list of music files, right now it is done by collection all files
# below the current folder whose extension does not start with .py
# This will probably need ... | [
"def",
"add_random_file_from_present_folder",
"(",
"machine_ip",
",",
"port",
",",
"zone",
")",
":",
"# Make a list of music files, right now it is done by collection all files",
"# below the current folder whose extension does not start with .py",
"# This will probably need to be modded for... | Add a random non-py file from this folder and subfolders to soco | [
"Add",
"a",
"random",
"non",
"-",
"py",
"file",
"from",
"this",
"folder",
"and",
"subfolders",
"to",
"soco"
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/examples/play_local_files/play_local_files.py#L64-L87 | train |
SoCo/SoCo | soco/data_structures.py | DidlResource.to_element | def to_element(self):
"""Return an ElementTree Element based on this resource.
Returns:
~xml.etree.ElementTree.Element: an Element.
"""
if not self.protocol_info:
raise DIDLMetadataError('Could not create Element for this'
'res... | python | def to_element(self):
"""Return an ElementTree Element based on this resource.
Returns:
~xml.etree.ElementTree.Element: an Element.
"""
if not self.protocol_info:
raise DIDLMetadataError('Could not create Element for this'
'res... | [
"def",
"to_element",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"protocol_info",
":",
"raise",
"DIDLMetadataError",
"(",
"'Could not create Element for this'",
"'resource:'",
"'protocolInfo not set (required).'",
")",
"root",
"=",
"XML",
".",
"Element",
"(",
"... | Return an ElementTree Element based on this resource.
Returns:
~xml.etree.ElementTree.Element: an Element. | [
"Return",
"an",
"ElementTree",
"Element",
"based",
"on",
"this",
"resource",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/data_structures.py#L199-L236 | train |
SoCo/SoCo | soco/data_structures.py | DidlResource.to_dict | def to_dict(self, remove_nones=False):
"""Return a dict representation of the `DidlResource`.
Args:
remove_nones (bool, optional): Optionally remove dictionary
elements when their value is `None`.
Returns:
dict: a dict representing the `DidlResource`
... | python | def to_dict(self, remove_nones=False):
"""Return a dict representation of the `DidlResource`.
Args:
remove_nones (bool, optional): Optionally remove dictionary
elements when their value is `None`.
Returns:
dict: a dict representing the `DidlResource`
... | [
"def",
"to_dict",
"(",
"self",
",",
"remove_nones",
"=",
"False",
")",
":",
"content",
"=",
"{",
"'uri'",
":",
"self",
".",
"uri",
",",
"'protocol_info'",
":",
"self",
".",
"protocol_info",
",",
"'import_uri'",
":",
"self",
".",
"import_uri",
",",
"'size... | Return a dict representation of the `DidlResource`.
Args:
remove_nones (bool, optional): Optionally remove dictionary
elements when their value is `None`.
Returns:
dict: a dict representing the `DidlResource` | [
"Return",
"a",
"dict",
"representation",
"of",
"the",
"DidlResource",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/data_structures.py#L238-L268 | train |
SoCo/SoCo | soco/data_structures.py | DidlObject.from_element | def from_element(cls, element): # pylint: disable=R0914
"""Create an instance of this class from an ElementTree xml Element.
An alternative constructor. The element must be a DIDL-Lite <item> or
<container> element, and must be properly namespaced.
Args:
xml (~xml.etree... | python | def from_element(cls, element): # pylint: disable=R0914
"""Create an instance of this class from an ElementTree xml Element.
An alternative constructor. The element must be a DIDL-Lite <item> or
<container> element, and must be properly namespaced.
Args:
xml (~xml.etree... | [
"def",
"from_element",
"(",
"cls",
",",
"element",
")",
":",
"# pylint: disable=R0914",
"# We used to check here that we have the right sort of element,",
"# ie a container or an item. But Sonos seems to use both",
"# indiscriminately, eg a playlistContainer can be an item or a",
"# containe... | Create an instance of this class from an ElementTree xml Element.
An alternative constructor. The element must be a DIDL-Lite <item> or
<container> element, and must be properly namespaced.
Args:
xml (~xml.etree.ElementTree.Element): An
:class:`~xml.etree.ElementTre... | [
"Create",
"an",
"instance",
"of",
"this",
"class",
"from",
"an",
"ElementTree",
"xml",
"Element",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/data_structures.py#L433-L519 | train |
SoCo/SoCo | soco/data_structures.py | DidlObject.to_dict | def to_dict(self, remove_nones=False):
"""Return the dict representation of the instance.
Args:
remove_nones (bool, optional): Optionally remove dictionary
elements when their value is `None`.
Returns:
dict: a dict representation of the `DidlObject`.
... | python | def to_dict(self, remove_nones=False):
"""Return the dict representation of the instance.
Args:
remove_nones (bool, optional): Optionally remove dictionary
elements when their value is `None`.
Returns:
dict: a dict representation of the `DidlObject`.
... | [
"def",
"to_dict",
"(",
"self",
",",
"remove_nones",
"=",
"False",
")",
":",
"content",
"=",
"{",
"}",
"# Get the value of each attribute listed in _translation, and add it",
"# to the content dict",
"for",
"key",
"in",
"self",
".",
"_translation",
":",
"if",
"hasattr"... | Return the dict representation of the instance.
Args:
remove_nones (bool, optional): Optionally remove dictionary
elements when their value is `None`.
Returns:
dict: a dict representation of the `DidlObject`. | [
"Return",
"the",
"dict",
"representation",
"of",
"the",
"instance",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/data_structures.py#L591-L617 | train |
SoCo/SoCo | soco/data_structures.py | DidlObject.set_uri | def set_uri(self, uri, resource_nr=0, protocol_info=None):
"""Set a resource uri for this instance. If no resource exists, create
a new one with the given protocol info.
Args:
uri (str): The resource uri.
resource_nr (int): The index of the resource on which to set the
... | python | def set_uri(self, uri, resource_nr=0, protocol_info=None):
"""Set a resource uri for this instance. If no resource exists, create
a new one with the given protocol info.
Args:
uri (str): The resource uri.
resource_nr (int): The index of the resource on which to set the
... | [
"def",
"set_uri",
"(",
"self",
",",
"uri",
",",
"resource_nr",
"=",
"0",
",",
"protocol_info",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"resources",
"[",
"resource_nr",
"]",
".",
"uri",
"=",
"uri",
"if",
"protocol_info",
"is",
"not",
"None",
"... | Set a resource uri for this instance. If no resource exists, create
a new one with the given protocol info.
Args:
uri (str): The resource uri.
resource_nr (int): The index of the resource on which to set the
uri. If it does not exist, a new resource is added to t... | [
"Set",
"a",
"resource",
"uri",
"for",
"this",
"instance",
".",
"If",
"no",
"resource",
"exists",
"create",
"a",
"new",
"one",
"with",
"the",
"given",
"protocol",
"info",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/data_structures.py#L682-L704 | train |
SoCo/SoCo | soco/data_structures.py | DidlFavorite.reference | def reference(self):
"""The Didl object this favorite refers to."""
# Import from_didl_string if it isn't present already. The import
# happens here because it would cause cyclic import errors if the
# import happened at load time.
global _FROM_DIDL_STRING_FUNCTION # pylint: di... | python | def reference(self):
"""The Didl object this favorite refers to."""
# Import from_didl_string if it isn't present already. The import
# happens here because it would cause cyclic import errors if the
# import happened at load time.
global _FROM_DIDL_STRING_FUNCTION # pylint: di... | [
"def",
"reference",
"(",
"self",
")",
":",
"# Import from_didl_string if it isn't present already. The import",
"# happens here because it would cause cyclic import errors if the",
"# import happened at load time.",
"global",
"_FROM_DIDL_STRING_FUNCTION",
"# pylint: disable=global-statement",
... | The Didl object this favorite refers to. | [
"The",
"Didl",
"object",
"this",
"favorite",
"refers",
"to",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/data_structures.py#L841-L857 | train |
SoCo/SoCo | soco/events.py | EventNotifyHandler.do_NOTIFY | def do_NOTIFY(self): # pylint: disable=invalid-name
"""Serve a ``NOTIFY`` request.
A ``NOTIFY`` request will be sent by a Sonos device when a state
variable changes. See the `UPnP Spec §4.3 [pdf]
<http://upnp.org/specs/arch/UPnP-arch
-DeviceArchitecture-v1.1.pdf>`_ for details... | python | def do_NOTIFY(self): # pylint: disable=invalid-name
"""Serve a ``NOTIFY`` request.
A ``NOTIFY`` request will be sent by a Sonos device when a state
variable changes. See the `UPnP Spec §4.3 [pdf]
<http://upnp.org/specs/arch/UPnP-arch
-DeviceArchitecture-v1.1.pdf>`_ for details... | [
"def",
"do_NOTIFY",
"(",
"self",
")",
":",
"# pylint: disable=invalid-name",
"timestamp",
"=",
"time",
".",
"time",
"(",
")",
"headers",
"=",
"requests",
".",
"structures",
".",
"CaseInsensitiveDict",
"(",
"self",
".",
"headers",
")",
"seq",
"=",
"headers",
... | Serve a ``NOTIFY`` request.
A ``NOTIFY`` request will be sent by a Sonos device when a state
variable changes. See the `UPnP Spec §4.3 [pdf]
<http://upnp.org/specs/arch/UPnP-arch
-DeviceArchitecture-v1.1.pdf>`_ for details. | [
"Serve",
"a",
"NOTIFY",
"request",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/events.py#L234-L270 | train |
SoCo/SoCo | soco/events.py | EventListener.stop | def stop(self):
"""Stop the event listener."""
# Signal the thread to stop before handling the next request
self._listener_thread.stop_flag.set()
# Send a dummy request in case the http server is currently listening
try:
urlopen(
'http://%s:%s/' % (sel... | python | def stop(self):
"""Stop the event listener."""
# Signal the thread to stop before handling the next request
self._listener_thread.stop_flag.set()
# Send a dummy request in case the http server is currently listening
try:
urlopen(
'http://%s:%s/' % (sel... | [
"def",
"stop",
"(",
"self",
")",
":",
"# Signal the thread to stop before handling the next request",
"self",
".",
"_listener_thread",
".",
"stop_flag",
".",
"set",
"(",
")",
"# Send a dummy request in case the http server is currently listening",
"try",
":",
"urlopen",
"(",
... | Stop the event listener. | [
"Stop",
"the",
"event",
"listener",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/events.py#L365-L380 | train |
SoCo/SoCo | soco/events.py | Subscription.subscribe | def subscribe(self, requested_timeout=None, auto_renew=False):
"""Subscribe to the service.
If requested_timeout is provided, a subscription valid for that number
of seconds will be requested, but not guaranteed. Check
`timeout` on return to find out what period of validity is
a... | python | def subscribe(self, requested_timeout=None, auto_renew=False):
"""Subscribe to the service.
If requested_timeout is provided, a subscription valid for that number
of seconds will be requested, but not guaranteed. Check
`timeout` on return to find out what period of validity is
a... | [
"def",
"subscribe",
"(",
"self",
",",
"requested_timeout",
"=",
"None",
",",
"auto_renew",
"=",
"False",
")",
":",
"class",
"AutoRenewThread",
"(",
"threading",
".",
"Thread",
")",
":",
"\"\"\"Used by the auto_renew code to renew a subscription from within\n a ... | Subscribe to the service.
If requested_timeout is provided, a subscription valid for that number
of seconds will be requested, but not guaranteed. Check
`timeout` on return to find out what period of validity is
actually allocated.
Note:
SoCo will try to unsubscribe... | [
"Subscribe",
"to",
"the",
"service",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/events.py#L418-L526 | train |
SoCo/SoCo | soco/events.py | Subscription.renew | def renew(self, requested_timeout=None):
"""Renew the event subscription.
You should not try to renew a subscription which has been
unsubscribed, or once it has expired.
Args:
requested_timeout (int, optional): The period for which a renewal
request should b... | python | def renew(self, requested_timeout=None):
"""Renew the event subscription.
You should not try to renew a subscription which has been
unsubscribed, or once it has expired.
Args:
requested_timeout (int, optional): The period for which a renewal
request should b... | [
"def",
"renew",
"(",
"self",
",",
"requested_timeout",
"=",
"None",
")",
":",
"# NB This code is sometimes called from a separate thread (when",
"# subscriptions are auto-renewed. Be careful to ensure thread-safety",
"if",
"self",
".",
"_has_been_unsubscribed",
":",
"raise",
"SoC... | Renew the event subscription.
You should not try to renew a subscription which has been
unsubscribed, or once it has expired.
Args:
requested_timeout (int, optional): The period for which a renewal
request should be made. If None (the default), use the timeout
... | [
"Renew",
"the",
"event",
"subscription",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/events.py#L528-L581 | train |
SoCo/SoCo | soco/core.py | only_on_master | def only_on_master(function):
"""Decorator that raises SoCoSlaveException on master call on slave."""
@wraps(function)
def inner_function(self, *args, **kwargs):
"""Master checking inner function."""
if not self.is_coordinator:
message = 'The method or property "{0}" can only be ... | python | def only_on_master(function):
"""Decorator that raises SoCoSlaveException on master call on slave."""
@wraps(function)
def inner_function(self, *args, **kwargs):
"""Master checking inner function."""
if not self.is_coordinator:
message = 'The method or property "{0}" can only be ... | [
"def",
"only_on_master",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"inner_function",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Master checking inner function.\"\"\"",
"if",
"not",
"self",
".",
"is_co... | Decorator that raises SoCoSlaveException on master call on slave. | [
"Decorator",
"that",
"raises",
"SoCoSlaveException",
"on",
"master",
"call",
"on",
"slave",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L97-L107 | train |
SoCo/SoCo | soco/core.py | SoCo.ramp_to_volume | def ramp_to_volume(self, volume, ramp_type='SLEEP_TIMER_RAMP_TYPE'):
"""Smoothly change the volume.
There are three ramp types available:
* ``'SLEEP_TIMER_RAMP_TYPE'`` (default): Linear ramp from the
current volume up or down to the new volume. The ramp rate is
... | python | def ramp_to_volume(self, volume, ramp_type='SLEEP_TIMER_RAMP_TYPE'):
"""Smoothly change the volume.
There are three ramp types available:
* ``'SLEEP_TIMER_RAMP_TYPE'`` (default): Linear ramp from the
current volume up or down to the new volume. The ramp rate is
... | [
"def",
"ramp_to_volume",
"(",
"self",
",",
"volume",
",",
"ramp_type",
"=",
"'SLEEP_TIMER_RAMP_TYPE'",
")",
":",
"response",
"=",
"self",
".",
"renderingControl",
".",
"RampToVolume",
"(",
"[",
"(",
"'InstanceID'",
",",
"0",
")",
",",
"(",
"'Channel'",
",",
... | Smoothly change the volume.
There are three ramp types available:
* ``'SLEEP_TIMER_RAMP_TYPE'`` (default): Linear ramp from the
current volume up or down to the new volume. The ramp rate is
1.25 steps per second. For example: To change from volume 50 to
vo... | [
"Smoothly",
"change",
"the",
"volume",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L443-L481 | train |
SoCo/SoCo | soco/core.py | SoCo.play_from_queue | def play_from_queue(self, index, start=True):
"""Play a track from the queue by index.
The index number is required as an argument, where the first index
is 0.
Args:
index (int): 0-based index of the track to play
start (bool): If the item that has been set shou... | python | def play_from_queue(self, index, start=True):
"""Play a track from the queue by index.
The index number is required as an argument, where the first index
is 0.
Args:
index (int): 0-based index of the track to play
start (bool): If the item that has been set shou... | [
"def",
"play_from_queue",
"(",
"self",
",",
"index",
",",
"start",
"=",
"True",
")",
":",
"# Grab the speaker's information if we haven't already since we'll need",
"# it in the next step.",
"if",
"not",
"self",
".",
"speaker_info",
":",
"self",
".",
"get_speaker_info",
... | Play a track from the queue by index.
The index number is required as an argument, where the first index
is 0.
Args:
index (int): 0-based index of the track to play
start (bool): If the item that has been set should start playing | [
"Play",
"a",
"track",
"from",
"the",
"queue",
"by",
"index",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L484-L516 | train |
SoCo/SoCo | soco/core.py | SoCo.play_uri | def play_uri(self, uri='', meta='', title='', start=True,
force_radio=False):
"""Play a URI.
Playing a URI will replace what was playing with the stream given by
the URI. For some streams at least a title is required as metadata.
This can be provided using the `meta` ar... | python | def play_uri(self, uri='', meta='', title='', start=True,
force_radio=False):
"""Play a URI.
Playing a URI will replace what was playing with the stream given by
the URI. For some streams at least a title is required as metadata.
This can be provided using the `meta` ar... | [
"def",
"play_uri",
"(",
"self",
",",
"uri",
"=",
"''",
",",
"meta",
"=",
"''",
",",
"title",
"=",
"''",
",",
"start",
"=",
"True",
",",
"force_radio",
"=",
"False",
")",
":",
"if",
"meta",
"==",
"''",
"and",
"title",
"!=",
"''",
":",
"meta_templa... | Play a URI.
Playing a URI will replace what was playing with the stream given by
the URI. For some streams at least a title is required as metadata.
This can be provided using the `meta` argument or the `title` argument.
If the `title` argument is provided minimal metadata will be gener... | [
"Play",
"a",
"URI",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L528-L610 | train |
SoCo/SoCo | soco/core.py | SoCo.volume | def volume(self, volume):
"""Set the speaker's volume."""
volume = int(volume)
volume = max(0, min(volume, 100)) # Coerce in range
self.renderingControl.SetVolume([
('InstanceID', 0),
('Channel', 'Master'),
('DesiredVolume', volume)
]) | python | def volume(self, volume):
"""Set the speaker's volume."""
volume = int(volume)
volume = max(0, min(volume, 100)) # Coerce in range
self.renderingControl.SetVolume([
('InstanceID', 0),
('Channel', 'Master'),
('DesiredVolume', volume)
]) | [
"def",
"volume",
"(",
"self",
",",
"volume",
")",
":",
"volume",
"=",
"int",
"(",
"volume",
")",
"volume",
"=",
"max",
"(",
"0",
",",
"min",
"(",
"volume",
",",
"100",
")",
")",
"# Coerce in range",
"self",
".",
"renderingControl",
".",
"SetVolume",
... | Set the speaker's volume. | [
"Set",
"the",
"speaker",
"s",
"volume",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L713-L721 | train |
SoCo/SoCo | soco/core.py | SoCo.bass | def bass(self, bass):
"""Set the speaker's bass."""
bass = int(bass)
bass = max(-10, min(bass, 10)) # Coerce in range
self.renderingControl.SetBass([
('InstanceID', 0),
('DesiredBass', bass)
]) | python | def bass(self, bass):
"""Set the speaker's bass."""
bass = int(bass)
bass = max(-10, min(bass, 10)) # Coerce in range
self.renderingControl.SetBass([
('InstanceID', 0),
('DesiredBass', bass)
]) | [
"def",
"bass",
"(",
"self",
",",
"bass",
")",
":",
"bass",
"=",
"int",
"(",
"bass",
")",
"bass",
"=",
"max",
"(",
"-",
"10",
",",
"min",
"(",
"bass",
",",
"10",
")",
")",
"# Coerce in range",
"self",
".",
"renderingControl",
".",
"SetBass",
"(",
... | Set the speaker's bass. | [
"Set",
"the",
"speaker",
"s",
"bass",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L738-L745 | train |
SoCo/SoCo | soco/core.py | SoCo.treble | def treble(self, treble):
"""Set the speaker's treble."""
treble = int(treble)
treble = max(-10, min(treble, 10)) # Coerce in range
self.renderingControl.SetTreble([
('InstanceID', 0),
('DesiredTreble', treble)
]) | python | def treble(self, treble):
"""Set the speaker's treble."""
treble = int(treble)
treble = max(-10, min(treble, 10)) # Coerce in range
self.renderingControl.SetTreble([
('InstanceID', 0),
('DesiredTreble', treble)
]) | [
"def",
"treble",
"(",
"self",
",",
"treble",
")",
":",
"treble",
"=",
"int",
"(",
"treble",
")",
"treble",
"=",
"max",
"(",
"-",
"10",
",",
"min",
"(",
"treble",
",",
"10",
")",
")",
"# Coerce in range",
"self",
".",
"renderingControl",
".",
"SetTreb... | Set the speaker's treble. | [
"Set",
"the",
"speaker",
"s",
"treble",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L762-L769 | train |
SoCo/SoCo | soco/core.py | SoCo._parse_zone_group_state | def _parse_zone_group_state(self):
"""The Zone Group State contains a lot of useful information.
Retrieve and parse it, and populate the relevant properties.
"""
# zoneGroupTopology.GetZoneGroupState()['ZoneGroupState'] returns XML like
# this:
#
# <ZoneGroups>
# <ZoneGroup Coordinator="RINC... | python | def _parse_zone_group_state(self):
"""The Zone Group State contains a lot of useful information.
Retrieve and parse it, and populate the relevant properties.
"""
# zoneGroupTopology.GetZoneGroupState()['ZoneGroupState'] returns XML like
# this:
#
# <ZoneGroups>
# <ZoneGroup Coordinator="RINC... | [
"def",
"_parse_zone_group_state",
"(",
"self",
")",
":",
"# zoneGroupTopology.GetZoneGroupState()['ZoneGroupState'] returns XML like",
"# this:",
"#",
"# <ZoneGroups>",
"# <ZoneGroup Coordinator=\"RINCON_000XXX1400\" ID=\"RINCON_000XXXX1400:0\">",
"# <ZoneGroupMember",
"# BootS... | The Zone Group State contains a lot of useful information.
Retrieve and parse it, and populate the relevant properties. | [
"The",
"Zone",
"Group",
"State",
"contains",
"a",
"lot",
"of",
"useful",
"information",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L865-L987 | train |
SoCo/SoCo | soco/core.py | SoCo.partymode | def partymode(self):
"""Put all the speakers in the network in the same group, a.k.a Party
Mode.
This blog shows the initial research responsible for this:
http://blog.travelmarx.com/2010/06/exploring-sonos-via-upnp.html
The trick seems to be (only tested on a two-speaker setup... | python | def partymode(self):
"""Put all the speakers in the network in the same group, a.k.a Party
Mode.
This blog shows the initial research responsible for this:
http://blog.travelmarx.com/2010/06/exploring-sonos-via-upnp.html
The trick seems to be (only tested on a two-speaker setup... | [
"def",
"partymode",
"(",
"self",
")",
":",
"# Tell every other visible zone to join this one",
"# pylint: disable = expression-not-assigned",
"[",
"zone",
".",
"join",
"(",
"self",
")",
"for",
"zone",
"in",
"self",
".",
"visible_zones",
"if",
"zone",
"is",
"not",
"s... | Put all the speakers in the network in the same group, a.k.a Party
Mode.
This blog shows the initial research responsible for this:
http://blog.travelmarx.com/2010/06/exploring-sonos-via-upnp.html
The trick seems to be (only tested on a two-speaker setup) to tell each
speaker w... | [
"Put",
"all",
"the",
"speakers",
"in",
"the",
"network",
"in",
"the",
"same",
"group",
"a",
".",
"k",
".",
"a",
"Party",
"Mode",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1031-L1044 | train |
SoCo/SoCo | soco/core.py | SoCo.switch_to_line_in | def switch_to_line_in(self, source=None):
""" Switch the speaker's input to line-in.
Args:
source (SoCo): The speaker whose line-in should be played.
Default is line-in from the speaker itself.
"""
if source:
uid = source.uid
else:
... | python | def switch_to_line_in(self, source=None):
""" Switch the speaker's input to line-in.
Args:
source (SoCo): The speaker whose line-in should be played.
Default is line-in from the speaker itself.
"""
if source:
uid = source.uid
else:
... | [
"def",
"switch_to_line_in",
"(",
"self",
",",
"source",
"=",
"None",
")",
":",
"if",
"source",
":",
"uid",
"=",
"source",
".",
"uid",
"else",
":",
"uid",
"=",
"self",
".",
"uid",
"self",
".",
"avTransport",
".",
"SetAVTransportURI",
"(",
"[",
"(",
"'... | Switch the speaker's input to line-in.
Args:
source (SoCo): The speaker whose line-in should be played.
Default is line-in from the speaker itself. | [
"Switch",
"the",
"speaker",
"s",
"input",
"to",
"line",
"-",
"in",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1070-L1086 | train |
SoCo/SoCo | soco/core.py | SoCo.get_current_track_info | def get_current_track_info(self):
"""Get information about the currently playing track.
Returns:
dict: A dictionary containing information about the currently
playing track: playlist_position, duration, title, artist, album,
position and an album_art link.
I... | python | def get_current_track_info(self):
"""Get information about the currently playing track.
Returns:
dict: A dictionary containing information about the currently
playing track: playlist_position, duration, title, artist, album,
position and an album_art link.
I... | [
"def",
"get_current_track_info",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"avTransport",
".",
"GetPositionInfo",
"(",
"[",
"(",
"'InstanceID'",
",",
"0",
")",
",",
"(",
"'Channel'",
",",
"'Master'",
")",
"]",
")",
"track",
"=",
"{",
"'title'"... | Get information about the currently playing track.
Returns:
dict: A dictionary containing information about the currently
playing track: playlist_position, duration, title, artist, album,
position and an album_art link.
If we're unable to return data for a field, we... | [
"Get",
"information",
"about",
"the",
"currently",
"playing",
"track",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1146-L1227 | train |
SoCo/SoCo | soco/core.py | SoCo.get_speaker_info | def get_speaker_info(self, refresh=False, timeout=None):
"""Get information about the Sonos speaker.
Arguments:
refresh(bool): Refresh the speaker info cache.
timeout: How long to wait for the server to send
data before giving up, as a float, or a
... | python | def get_speaker_info(self, refresh=False, timeout=None):
"""Get information about the Sonos speaker.
Arguments:
refresh(bool): Refresh the speaker info cache.
timeout: How long to wait for the server to send
data before giving up, as a float, or a
... | [
"def",
"get_speaker_info",
"(",
"self",
",",
"refresh",
"=",
"False",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"speaker_info",
"and",
"refresh",
"is",
"False",
":",
"return",
"self",
".",
"speaker_info",
"else",
":",
"response",
"=",
"re... | Get information about the Sonos speaker.
Arguments:
refresh(bool): Refresh the speaker info cache.
timeout: How long to wait for the server to send
data before giving up, as a float, or a
`(connect timeout, read timeout)` tuple
e.g. (3, 5)... | [
"Get",
"information",
"about",
"the",
"Sonos",
"speaker",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1229-L1282 | train |
SoCo/SoCo | soco/core.py | SoCo.get_current_transport_info | def get_current_transport_info(self):
"""Get the current playback state.
Returns:
dict: The following information about the
speaker's playing state:
* current_transport_state (``PLAYING``, ``TRANSITIONING``,
``PAUSED_PLAYBACK``, ``STOPPED``)
... | python | def get_current_transport_info(self):
"""Get the current playback state.
Returns:
dict: The following information about the
speaker's playing state:
* current_transport_state (``PLAYING``, ``TRANSITIONING``,
``PAUSED_PLAYBACK``, ``STOPPED``)
... | [
"def",
"get_current_transport_info",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"avTransport",
".",
"GetTransportInfo",
"(",
"[",
"(",
"'InstanceID'",
",",
"0",
")",
",",
"]",
")",
"playstate",
"=",
"{",
"'current_transport_status'",
":",
"''",
","... | Get the current playback state.
Returns:
dict: The following information about the
speaker's playing state:
* current_transport_state (``PLAYING``, ``TRANSITIONING``,
``PAUSED_PLAYBACK``, ``STOPPED``)
* current_transport_status (OK, ?)
... | [
"Get",
"the",
"current",
"playback",
"state",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1284-L1315 | train |
SoCo/SoCo | soco/core.py | SoCo.get_queue | def get_queue(self, start=0, max_items=100, full_album_art_uri=False):
"""Get information about the queue.
:param start: Starting number of returned matches
:param max_items: Maximum number of returned matches
:param full_album_art_uri: If the album art URI should include the
... | python | def get_queue(self, start=0, max_items=100, full_album_art_uri=False):
"""Get information about the queue.
:param start: Starting number of returned matches
:param max_items: Maximum number of returned matches
:param full_album_art_uri: If the album art URI should include the
... | [
"def",
"get_queue",
"(",
"self",
",",
"start",
"=",
"0",
",",
"max_items",
"=",
"100",
",",
"full_album_art_uri",
"=",
"False",
")",
":",
"queue",
"=",
"[",
"]",
"response",
"=",
"self",
".",
"contentDirectory",
".",
"Browse",
"(",
"[",
"(",
"'ObjectID... | Get information about the queue.
:param start: Starting number of returned matches
:param max_items: Maximum number of returned matches
:param full_album_art_uri: If the album art URI should include the
IP address
:returns: A :py:class:`~.soco.data_structures.Queue` object
... | [
"Get",
"information",
"about",
"the",
"queue",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1317-L1358 | train |
SoCo/SoCo | soco/core.py | SoCo.add_uri_to_queue | def add_uri_to_queue(self, uri, position=0, as_next=False):
"""Add the URI to the queue.
For arguments and return value see `add_to_queue`.
"""
# FIXME: The res.protocol_info should probably represent the mime type
# etc of the uri. But this seems OK.
res = [DidlResource... | python | def add_uri_to_queue(self, uri, position=0, as_next=False):
"""Add the URI to the queue.
For arguments and return value see `add_to_queue`.
"""
# FIXME: The res.protocol_info should probably represent the mime type
# etc of the uri. But this seems OK.
res = [DidlResource... | [
"def",
"add_uri_to_queue",
"(",
"self",
",",
"uri",
",",
"position",
"=",
"0",
",",
"as_next",
"=",
"False",
")",
":",
"# FIXME: The res.protocol_info should probably represent the mime type",
"# etc of the uri. But this seems OK.",
"res",
"=",
"[",
"DidlResource",
"(",
... | Add the URI to the queue.
For arguments and return value see `add_to_queue`. | [
"Add",
"the",
"URI",
"to",
"the",
"queue",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1395-L1404 | train |
SoCo/SoCo | soco/core.py | SoCo.add_to_queue | def add_to_queue(self, queueable_item, position=0, as_next=False):
"""Add a queueable item to the queue.
Args:
queueable_item (DidlObject or MusicServiceItem): The item to be
added to the queue
position (int): The index (1-based) at which the URI should be
... | python | def add_to_queue(self, queueable_item, position=0, as_next=False):
"""Add a queueable item to the queue.
Args:
queueable_item (DidlObject or MusicServiceItem): The item to be
added to the queue
position (int): The index (1-based) at which the URI should be
... | [
"def",
"add_to_queue",
"(",
"self",
",",
"queueable_item",
",",
"position",
"=",
"0",
",",
"as_next",
"=",
"False",
")",
":",
"metadata",
"=",
"to_didl_string",
"(",
"queueable_item",
")",
"response",
"=",
"self",
".",
"avTransport",
".",
"AddURIToQueue",
"(... | Add a queueable item to the queue.
Args:
queueable_item (DidlObject or MusicServiceItem): The item to be
added to the queue
position (int): The index (1-based) at which the URI should be
added. Default is 0 (add URI at the end of the queue).
a... | [
"Add",
"a",
"queueable",
"item",
"to",
"the",
"queue",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1407-L1430 | train |
SoCo/SoCo | soco/core.py | SoCo.add_multiple_to_queue | def add_multiple_to_queue(self, items, container=None):
"""Add a sequence of items to the queue.
Args:
items (list): A sequence of items to the be added to the queue
container (DidlObject, optional): A container object which
includes the items.
"""
... | python | def add_multiple_to_queue(self, items, container=None):
"""Add a sequence of items to the queue.
Args:
items (list): A sequence of items to the be added to the queue
container (DidlObject, optional): A container object which
includes the items.
"""
... | [
"def",
"add_multiple_to_queue",
"(",
"self",
",",
"items",
",",
"container",
"=",
"None",
")",
":",
"if",
"container",
"is",
"not",
"None",
":",
"container_uri",
"=",
"container",
".",
"resources",
"[",
"0",
"]",
".",
"uri",
"container_metadata",
"=",
"to_... | Add a sequence of items to the queue.
Args:
items (list): A sequence of items to the be added to the queue
container (DidlObject, optional): A container object which
includes the items. | [
"Add",
"a",
"sequence",
"of",
"items",
"to",
"the",
"queue",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1432-L1463 | train |
SoCo/SoCo | soco/core.py | SoCo.remove_from_queue | def remove_from_queue(self, index):
"""Remove a track from the queue by index. The index number is
required as an argument, where the first index is 0.
Args:
index (int): The (0-based) index of the track to remove
"""
# TODO: what do these parameters actually do?
... | python | def remove_from_queue(self, index):
"""Remove a track from the queue by index. The index number is
required as an argument, where the first index is 0.
Args:
index (int): The (0-based) index of the track to remove
"""
# TODO: what do these parameters actually do?
... | [
"def",
"remove_from_queue",
"(",
"self",
",",
"index",
")",
":",
"# TODO: what do these parameters actually do?",
"updid",
"=",
"'0'",
"objid",
"=",
"'Q:0/'",
"+",
"str",
"(",
"index",
"+",
"1",
")",
"self",
".",
"avTransport",
".",
"RemoveTrackFromQueue",
"(",
... | Remove a track from the queue by index. The index number is
required as an argument, where the first index is 0.
Args:
index (int): The (0-based) index of the track to remove | [
"Remove",
"a",
"track",
"from",
"the",
"queue",
"by",
"index",
".",
"The",
"index",
"number",
"is",
"required",
"as",
"an",
"argument",
"where",
"the",
"first",
"index",
"is",
"0",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1466-L1480 | train |
SoCo/SoCo | soco/core.py | SoCo.get_favorite_radio_shows | def get_favorite_radio_shows(self, start=0, max_items=100):
"""Get favorite radio shows from Sonos' Radio app.
Returns:
dict: A dictionary containing the total number of favorites, the
number of favorites returned, and the actual list of favorite radio
shows, represe... | python | def get_favorite_radio_shows(self, start=0, max_items=100):
"""Get favorite radio shows from Sonos' Radio app.
Returns:
dict: A dictionary containing the total number of favorites, the
number of favorites returned, and the actual list of favorite radio
shows, represe... | [
"def",
"get_favorite_radio_shows",
"(",
"self",
",",
"start",
"=",
"0",
",",
"max_items",
"=",
"100",
")",
":",
"message",
"=",
"'The output type of this method will probably change in '",
"'the future to use SoCo data structures'",
"warnings",
".",
"warn",
"(",
"message"... | Get favorite radio shows from Sonos' Radio app.
Returns:
dict: A dictionary containing the total number of favorites, the
number of favorites returned, and the actual list of favorite radio
shows, represented as a dictionary with `title` and `uri` keys.
Depending on... | [
"Get",
"favorite",
"radio",
"shows",
"from",
"Sonos",
"Radio",
"app",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1490-L1506 | train |
SoCo/SoCo | soco/core.py | SoCo.get_favorite_radio_stations | def get_favorite_radio_stations(self, start=0, max_items=100):
"""Get favorite radio stations from Sonos' Radio app.
See :meth:`get_favorite_radio_shows` for return type and remarks.
"""
message = 'The output type of this method will probably change in '\
'the future t... | python | def get_favorite_radio_stations(self, start=0, max_items=100):
"""Get favorite radio stations from Sonos' Radio app.
See :meth:`get_favorite_radio_shows` for return type and remarks.
"""
message = 'The output type of this method will probably change in '\
'the future t... | [
"def",
"get_favorite_radio_stations",
"(",
"self",
",",
"start",
"=",
"0",
",",
"max_items",
"=",
"100",
")",
":",
"message",
"=",
"'The output type of this method will probably change in '",
"'the future to use SoCo data structures'",
"warnings",
".",
"warn",
"(",
"messa... | Get favorite radio stations from Sonos' Radio app.
See :meth:`get_favorite_radio_shows` for return type and remarks. | [
"Get",
"favorite",
"radio",
"stations",
"from",
"Sonos",
"Radio",
"app",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1510-L1518 | train |
SoCo/SoCo | soco/core.py | SoCo.get_sonos_favorites | def get_sonos_favorites(self, start=0, max_items=100):
"""Get Sonos favorites.
See :meth:`get_favorite_radio_shows` for return type and remarks.
"""
message = 'The output type of this method will probably change in '\
'the future to use SoCo data structures'
wa... | python | def get_sonos_favorites(self, start=0, max_items=100):
"""Get Sonos favorites.
See :meth:`get_favorite_radio_shows` for return type and remarks.
"""
message = 'The output type of this method will probably change in '\
'the future to use SoCo data structures'
wa... | [
"def",
"get_sonos_favorites",
"(",
"self",
",",
"start",
"=",
"0",
",",
"max_items",
"=",
"100",
")",
":",
"message",
"=",
"'The output type of this method will probably change in '",
"'the future to use SoCo data structures'",
"warnings",
".",
"warn",
"(",
"message",
"... | Get Sonos favorites.
See :meth:`get_favorite_radio_shows` for return type and remarks. | [
"Get",
"Sonos",
"favorites",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1521-L1529 | train |
SoCo/SoCo | soco/core.py | SoCo.create_sonos_playlist | def create_sonos_playlist(self, title):
"""Create a new empty Sonos playlist.
Args:
title: Name of the playlist
:rtype: :py:class:`~.soco.data_structures.DidlPlaylistContainer`
"""
response = self.avTransport.CreateSavedQueue([
('InstanceID', 0),
... | python | def create_sonos_playlist(self, title):
"""Create a new empty Sonos playlist.
Args:
title: Name of the playlist
:rtype: :py:class:`~.soco.data_structures.DidlPlaylistContainer`
"""
response = self.avTransport.CreateSavedQueue([
('InstanceID', 0),
... | [
"def",
"create_sonos_playlist",
"(",
"self",
",",
"title",
")",
":",
"response",
"=",
"self",
".",
"avTransport",
".",
"CreateSavedQueue",
"(",
"[",
"(",
"'InstanceID'",
",",
"0",
")",
",",
"(",
"'Title'",
",",
"title",
")",
",",
"(",
"'EnqueuedURI'",
",... | Create a new empty Sonos playlist.
Args:
title: Name of the playlist
:rtype: :py:class:`~.soco.data_structures.DidlPlaylistContainer` | [
"Create",
"a",
"new",
"empty",
"Sonos",
"playlist",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1583-L1604 | train |
SoCo/SoCo | soco/core.py | SoCo.create_sonos_playlist_from_queue | def create_sonos_playlist_from_queue(self, title):
"""Create a new Sonos playlist from the current queue.
Args:
title: Name of the playlist
:rtype: :py:class:`~.soco.data_structures.DidlPlaylistContainer`
"""
# Note: probably same as Queue service method SaveAsSonos... | python | def create_sonos_playlist_from_queue(self, title):
"""Create a new Sonos playlist from the current queue.
Args:
title: Name of the playlist
:rtype: :py:class:`~.soco.data_structures.DidlPlaylistContainer`
"""
# Note: probably same as Queue service method SaveAsSonos... | [
"def",
"create_sonos_playlist_from_queue",
"(",
"self",
",",
"title",
")",
":",
"# Note: probably same as Queue service method SaveAsSonosPlaylist",
"# but this has not been tested. This method is what the",
"# controller uses.",
"response",
"=",
"self",
".",
"avTransport",
".",
"... | Create a new Sonos playlist from the current queue.
Args:
title: Name of the playlist
:rtype: :py:class:`~.soco.data_structures.DidlPlaylistContainer` | [
"Create",
"a",
"new",
"Sonos",
"playlist",
"from",
"the",
"current",
"queue",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1608-L1629 | train |
SoCo/SoCo | soco/core.py | SoCo.remove_sonos_playlist | def remove_sonos_playlist(self, sonos_playlist):
"""Remove a Sonos playlist.
Args:
sonos_playlist (DidlPlaylistContainer): Sonos playlist to remove
or the item_id (str).
Returns:
bool: True if succesful, False otherwise
Raises:
SoCoU... | python | def remove_sonos_playlist(self, sonos_playlist):
"""Remove a Sonos playlist.
Args:
sonos_playlist (DidlPlaylistContainer): Sonos playlist to remove
or the item_id (str).
Returns:
bool: True if succesful, False otherwise
Raises:
SoCoU... | [
"def",
"remove_sonos_playlist",
"(",
"self",
",",
"sonos_playlist",
")",
":",
"object_id",
"=",
"getattr",
"(",
"sonos_playlist",
",",
"'item_id'",
",",
"sonos_playlist",
")",
"return",
"self",
".",
"contentDirectory",
".",
"DestroyObject",
"(",
"[",
"(",
"'Obje... | Remove a Sonos playlist.
Args:
sonos_playlist (DidlPlaylistContainer): Sonos playlist to remove
or the item_id (str).
Returns:
bool: True if succesful, False otherwise
Raises:
SoCoUPnPException: If sonos_playlist does not point to a valid
... | [
"Remove",
"a",
"Sonos",
"playlist",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1632-L1648 | train |
SoCo/SoCo | soco/core.py | SoCo.add_item_to_sonos_playlist | def add_item_to_sonos_playlist(self, queueable_item, sonos_playlist):
"""Adds a queueable item to a Sonos' playlist.
Args:
queueable_item (DidlObject): the item to add to the Sonos' playlist
sonos_playlist (DidlPlaylistContainer): the Sonos' playlist to
which the... | python | def add_item_to_sonos_playlist(self, queueable_item, sonos_playlist):
"""Adds a queueable item to a Sonos' playlist.
Args:
queueable_item (DidlObject): the item to add to the Sonos' playlist
sonos_playlist (DidlPlaylistContainer): the Sonos' playlist to
which the... | [
"def",
"add_item_to_sonos_playlist",
"(",
"self",
",",
"queueable_item",
",",
"sonos_playlist",
")",
":",
"# Get the update_id for the playlist",
"response",
",",
"_",
"=",
"self",
".",
"music_library",
".",
"_music_lib_search",
"(",
"sonos_playlist",
".",
"item_id",
... | Adds a queueable item to a Sonos' playlist.
Args:
queueable_item (DidlObject): the item to add to the Sonos' playlist
sonos_playlist (DidlPlaylistContainer): the Sonos' playlist to
which the item should be added | [
"Adds",
"a",
"queueable",
"item",
"to",
"a",
"Sonos",
"playlist",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1650-L1678 | train |
SoCo/SoCo | soco/core.py | SoCo.get_sleep_timer | def get_sleep_timer(self):
"""Retrieves remaining sleep time, if any
Returns:
int or NoneType: Number of seconds left in timer. If there is no
sleep timer currently set it will return None.
"""
resp = self.avTransport.GetRemainingSleepTimerDuration([
... | python | def get_sleep_timer(self):
"""Retrieves remaining sleep time, if any
Returns:
int or NoneType: Number of seconds left in timer. If there is no
sleep timer currently set it will return None.
"""
resp = self.avTransport.GetRemainingSleepTimerDuration([
... | [
"def",
"get_sleep_timer",
"(",
"self",
")",
":",
"resp",
"=",
"self",
".",
"avTransport",
".",
"GetRemainingSleepTimerDuration",
"(",
"[",
"(",
"'InstanceID'",
",",
"0",
")",
",",
"]",
")",
"if",
"resp",
"[",
"'RemainingSleepTimerDuration'",
"]",
":",
"times... | Retrieves remaining sleep time, if any
Returns:
int or NoneType: Number of seconds left in timer. If there is no
sleep timer currently set it will return None. | [
"Retrieves",
"remaining",
"sleep",
"time",
"if",
"any"
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1720-L1736 | train |
SoCo/SoCo | soco/core.py | SoCo.get_sonos_playlist_by_attr | def get_sonos_playlist_by_attr(self, attr_name, match):
"""Return the first Sonos Playlist DidlPlaylistContainer that
matches the attribute specified.
Args:
attr_name (str): DidlPlaylistContainer attribute to compare. The
most useful being: 'title' and 'item_id'.
... | python | def get_sonos_playlist_by_attr(self, attr_name, match):
"""Return the first Sonos Playlist DidlPlaylistContainer that
matches the attribute specified.
Args:
attr_name (str): DidlPlaylistContainer attribute to compare. The
most useful being: 'title' and 'item_id'.
... | [
"def",
"get_sonos_playlist_by_attr",
"(",
"self",
",",
"attr_name",
",",
"match",
")",
":",
"for",
"sonos_playlist",
"in",
"self",
".",
"get_sonos_playlists",
"(",
")",
":",
"if",
"getattr",
"(",
"sonos_playlist",
",",
"attr_name",
")",
"==",
"match",
":",
"... | Return the first Sonos Playlist DidlPlaylistContainer that
matches the attribute specified.
Args:
attr_name (str): DidlPlaylistContainer attribute to compare. The
most useful being: 'title' and 'item_id'.
match (str): Value to match.
Returns:
... | [
"Return",
"the",
"first",
"Sonos",
"Playlist",
"DidlPlaylistContainer",
"that",
"matches",
"the",
"attribute",
"specified",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1950-L1977 | train |
SoCo/SoCo | soco/utils.py | really_unicode | def really_unicode(in_string):
"""Make a string unicode. Really.
Ensure ``in_string`` is returned as unicode through a series of
progressively relaxed decodings.
Args:
in_string (str): The string to convert.
Returns:
str: Unicode.
Raises:
ValueError
"""
if... | python | def really_unicode(in_string):
"""Make a string unicode. Really.
Ensure ``in_string`` is returned as unicode through a series of
progressively relaxed decodings.
Args:
in_string (str): The string to convert.
Returns:
str: Unicode.
Raises:
ValueError
"""
if... | [
"def",
"really_unicode",
"(",
"in_string",
")",
":",
"if",
"isinstance",
"(",
"in_string",
",",
"StringType",
")",
":",
"for",
"args",
"in",
"(",
"(",
"'utf-8'",
",",
")",
",",
"(",
"'latin-1'",
",",
")",
",",
"(",
"'ascii'",
",",
"'replace'",
")",
"... | Make a string unicode. Really.
Ensure ``in_string`` is returned as unicode through a series of
progressively relaxed decodings.
Args:
in_string (str): The string to convert.
Returns:
str: Unicode.
Raises:
ValueError | [
"Make",
"a",
"string",
"unicode",
".",
"Really",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/utils.py#L22-L47 | train |
SoCo/SoCo | soco/utils.py | camel_to_underscore | def camel_to_underscore(string):
"""Convert camelcase to lowercase and underscore.
Recipe from http://stackoverflow.com/a/1176023
Args:
string (str): The string to convert.
Returns:
str: The converted string.
"""
string = FIRST_CAP_RE.sub(r'\1_\2', string)
return ALL_CAP_R... | python | def camel_to_underscore(string):
"""Convert camelcase to lowercase and underscore.
Recipe from http://stackoverflow.com/a/1176023
Args:
string (str): The string to convert.
Returns:
str: The converted string.
"""
string = FIRST_CAP_RE.sub(r'\1_\2', string)
return ALL_CAP_R... | [
"def",
"camel_to_underscore",
"(",
"string",
")",
":",
"string",
"=",
"FIRST_CAP_RE",
".",
"sub",
"(",
"r'\\1_\\2'",
",",
"string",
")",
"return",
"ALL_CAP_RE",
".",
"sub",
"(",
"r'\\1_\\2'",
",",
"string",
")",
".",
"lower",
"(",
")"
] | Convert camelcase to lowercase and underscore.
Recipe from http://stackoverflow.com/a/1176023
Args:
string (str): The string to convert.
Returns:
str: The converted string. | [
"Convert",
"camelcase",
"to",
"lowercase",
"and",
"underscore",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/utils.py#L73-L85 | train |
SoCo/SoCo | soco/utils.py | prettify | def prettify(unicode_text):
"""Return a pretty-printed version of a unicode XML string.
Useful for debugging.
Args:
unicode_text (str): A text representation of XML (unicode,
*not* utf-8).
Returns:
str: A pretty-printed version of the input.
"""
import xml.dom.min... | python | def prettify(unicode_text):
"""Return a pretty-printed version of a unicode XML string.
Useful for debugging.
Args:
unicode_text (str): A text representation of XML (unicode,
*not* utf-8).
Returns:
str: A pretty-printed version of the input.
"""
import xml.dom.min... | [
"def",
"prettify",
"(",
"unicode_text",
")",
":",
"import",
"xml",
".",
"dom",
".",
"minidom",
"reparsed",
"=",
"xml",
".",
"dom",
".",
"minidom",
".",
"parseString",
"(",
"unicode_text",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"return",
"reparsed",
"."... | Return a pretty-printed version of a unicode XML string.
Useful for debugging.
Args:
unicode_text (str): A text representation of XML (unicode,
*not* utf-8).
Returns:
str: A pretty-printed version of the input. | [
"Return",
"a",
"pretty",
"-",
"printed",
"version",
"of",
"a",
"unicode",
"XML",
"string",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/utils.py#L88-L103 | train |
SoCo/SoCo | soco/soap.py | SoapMessage.prepare_headers | def prepare_headers(self, http_headers, soap_action):
"""Prepare the http headers for sending.
Add the SOAPACTION header to the others.
Args:
http_headers (dict): A dict in the form {'Header': 'Value,..}
containing http headers to use for the http request.
... | python | def prepare_headers(self, http_headers, soap_action):
"""Prepare the http headers for sending.
Add the SOAPACTION header to the others.
Args:
http_headers (dict): A dict in the form {'Header': 'Value,..}
containing http headers to use for the http request.
... | [
"def",
"prepare_headers",
"(",
"self",
",",
"http_headers",
",",
"soap_action",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'text/xml; charset=\"utf-8\"'",
"}",
"if",
"soap_action",
"is",
"not",
"None",
":",
"headers",
".",
"update",
"(",
"{",
"'SOA... | Prepare the http headers for sending.
Add the SOAPACTION header to the others.
Args:
http_headers (dict): A dict in the form {'Header': 'Value,..}
containing http headers to use for the http request.
soap_action (str): The value of the SOAPACTION header.
... | [
"Prepare",
"the",
"http",
"headers",
"for",
"sending",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/soap.py#L147-L166 | train |
SoCo/SoCo | soco/soap.py | SoapMessage.prepare_soap_body | def prepare_soap_body(self, method, parameters, namespace):
"""Prepare the SOAP message body for sending.
Args:
method (str): The name of the method to call.
parameters (list): A list of (name, value) tuples containing
the parameters to pass to the method.
... | python | def prepare_soap_body(self, method, parameters, namespace):
"""Prepare the SOAP message body for sending.
Args:
method (str): The name of the method to call.
parameters (list): A list of (name, value) tuples containing
the parameters to pass to the method.
... | [
"def",
"prepare_soap_body",
"(",
"self",
",",
"method",
",",
"parameters",
",",
"namespace",
")",
":",
"tags",
"=",
"[",
"]",
"for",
"name",
",",
"value",
"in",
"parameters",
":",
"tag",
"=",
"\"<{name}>{value}</{name}>\"",
".",
"format",
"(",
"name",
"=",... | Prepare the SOAP message body for sending.
Args:
method (str): The name of the method to call.
parameters (list): A list of (name, value) tuples containing
the parameters to pass to the method.
namespace (str): tThe XML namespace to use for the method.
... | [
"Prepare",
"the",
"SOAP",
"message",
"body",
"for",
"sending",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/soap.py#L186-L225 | train |
SoCo/SoCo | soco/soap.py | SoapMessage.prepare_soap_envelope | def prepare_soap_envelope(self, prepared_soap_header, prepared_soap_body):
"""Prepare the SOAP Envelope for sending.
Args:
prepared_soap_header (str): A SOAP Header prepared by
`prepare_soap_header`
prepared_soap_body (str): A SOAP Body prepared by
... | python | def prepare_soap_envelope(self, prepared_soap_header, prepared_soap_body):
"""Prepare the SOAP Envelope for sending.
Args:
prepared_soap_header (str): A SOAP Header prepared by
`prepare_soap_header`
prepared_soap_body (str): A SOAP Body prepared by
... | [
"def",
"prepare_soap_envelope",
"(",
"self",
",",
"prepared_soap_header",
",",
"prepared_soap_body",
")",
":",
"# pylint: disable=bad-continuation",
"soap_env_template",
"=",
"(",
"'<?xml version=\"1.0\"?>'",
"'<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"'",
"' s... | Prepare the SOAP Envelope for sending.
Args:
prepared_soap_header (str): A SOAP Header prepared by
`prepare_soap_header`
prepared_soap_body (str): A SOAP Body prepared by
`prepare_soap_body`
Returns:
str: A prepared SOAP Envelope | [
"Prepare",
"the",
"SOAP",
"Envelope",
"for",
"sending",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/soap.py#L227-L252 | train |
SoCo/SoCo | soco/soap.py | SoapMessage.prepare | def prepare(self):
"""Prepare the SOAP message for sending to the server."""
headers = self.prepare_headers(self.http_headers, self.soap_action)
soap_header = self.prepare_soap_header(self.soap_header)
soap_body = self.prepare_soap_body(
self.method, self.parameters, self.na... | python | def prepare(self):
"""Prepare the SOAP message for sending to the server."""
headers = self.prepare_headers(self.http_headers, self.soap_action)
soap_header = self.prepare_soap_header(self.soap_header)
soap_body = self.prepare_soap_body(
self.method, self.parameters, self.na... | [
"def",
"prepare",
"(",
"self",
")",
":",
"headers",
"=",
"self",
".",
"prepare_headers",
"(",
"self",
".",
"http_headers",
",",
"self",
".",
"soap_action",
")",
"soap_header",
"=",
"self",
".",
"prepare_soap_header",
"(",
"self",
".",
"soap_header",
")",
"... | Prepare the SOAP message for sending to the server. | [
"Prepare",
"the",
"SOAP",
"message",
"for",
"sending",
"to",
"the",
"server",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/soap.py#L254-L263 | train |
SoCo/SoCo | soco/soap.py | SoapMessage.call | def call(self):
"""Call the SOAP method on the server.
Returns:
str: the decapusulated SOAP response from the server,
still encoded as utf-8.
Raises:
SoapFault: if a SOAP error occurs.
~requests.exceptions.HTTPError: if an http error occurs... | python | def call(self):
"""Call the SOAP method on the server.
Returns:
str: the decapusulated SOAP response from the server,
still encoded as utf-8.
Raises:
SoapFault: if a SOAP error occurs.
~requests.exceptions.HTTPError: if an http error occurs... | [
"def",
"call",
"(",
"self",
")",
":",
"headers",
",",
"data",
"=",
"self",
".",
"prepare",
"(",
")",
"# Check log level before logging XML, since prettifying it is",
"# expensive",
"if",
"_LOG",
".",
"isEnabledFor",
"(",
"logging",
".",
"DEBUG",
")",
":",
"_LOG"... | Call the SOAP method on the server.
Returns:
str: the decapusulated SOAP response from the server,
still encoded as utf-8.
Raises:
SoapFault: if a SOAP error occurs.
~requests.exceptions.HTTPError: if an http error occurs. | [
"Call",
"the",
"SOAP",
"method",
"on",
"the",
"server",
"."
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/soap.py#L265-L319 | train |
SoCo/SoCo | dev_tools/analyse_ws.py | __build_option_parser | def __build_option_parser():
""" Build the option parser for this script """
description = """
Tool to analyze Wireshark dumps of Sonos traffic.
The files that are input to this script must be in the
"Wireshark/tcpdump/...-libpcap" format, which can be exported from
Wireshark.
To use the o... | python | def __build_option_parser():
""" Build the option parser for this script """
description = """
Tool to analyze Wireshark dumps of Sonos traffic.
The files that are input to this script must be in the
"Wireshark/tcpdump/...-libpcap" format, which can be exported from
Wireshark.
To use the o... | [
"def",
"__build_option_parser",
"(",
")",
":",
"description",
"=",
"\"\"\"\n Tool to analyze Wireshark dumps of Sonos traffic.\n\n The files that are input to this script must be in the\n \"Wireshark/tcpdump/...-libpcap\" format, which can be exported from\n Wireshark.\n\n To use the op... | Build the option parser for this script | [
"Build",
"the",
"option",
"parser",
"for",
"this",
"script"
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/dev_tools/analyse_ws.py#L434-L489 | train |
SoCo/SoCo | dev_tools/analyse_ws.py | main | def main():
""" Main method of the script """
parser = __build_option_parser()
args = parser.parse_args()
analyze_ws = AnalyzeWS(args)
try:
analyze_ws.set_file(args.file_[0])
except IOError:
print 'IOError raised while reading file. Exiting!'
sys.exit(3)
# Start the ... | python | def main():
""" Main method of the script """
parser = __build_option_parser()
args = parser.parse_args()
analyze_ws = AnalyzeWS(args)
try:
analyze_ws.set_file(args.file_[0])
except IOError:
print 'IOError raised while reading file. Exiting!'
sys.exit(3)
# Start the ... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"__build_option_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"analyze_ws",
"=",
"AnalyzeWS",
"(",
"args",
")",
"try",
":",
"analyze_ws",
".",
"set_file",
"(",
"args",
".",
"file_",
... | Main method of the script | [
"Main",
"method",
"of",
"the",
"script"
] | 671937e07d7973b78c0cbee153d4f3ad68ec48c6 | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/dev_tools/analyse_ws.py#L510-L527 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.