id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
15,300 | EventRegistry/event-registry-python | eventregistry/TopicPage.py | TopicPage.getArticles | def getArticles(self,
page=1,
count=100,
sortBy = "rel",
sortByAsc = False,
returnInfo=ReturnInfo()):
"""
return a list of articles that match the topic page
@param page: which page of the results to return (default:... | python | def getArticles(self,
page=1,
count=100,
sortBy = "rel",
sortByAsc = False,
returnInfo=ReturnInfo()):
"""
return a list of articles that match the topic page
@param page: which page of the results to return (default:... | [
"def",
"getArticles",
"(",
"self",
",",
"page",
"=",
"1",
",",
"count",
"=",
"100",
",",
"sortBy",
"=",
"\"rel\"",
",",
"sortByAsc",
"=",
"False",
",",
"returnInfo",
"=",
"ReturnInfo",
"(",
")",
")",
":",
"assert",
"page",
">=",
"1",
"assert",
"count... | return a list of articles that match the topic page
@param page: which page of the results to return (default: 1)
@param count: number of articles to return (default: 100)
@param sortBy: how are articles sorted. Options: id (internal id), date (publishing date), cosSim (closeness to the event ce... | [
"return",
"a",
"list",
"of",
"articles",
"that",
"match",
"the",
"topic",
"page"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/TopicPage.py#L333-L360 |
15,301 | EventRegistry/event-registry-python | eventregistry/Query.py | CombinedQuery.AND | def AND(queryArr,
exclude = None):
"""
create a combined query with multiple items on which to perform an AND operation
@param queryArr: a list of items on which to perform an AND operation. Items can be either a CombinedQuery or BaseQuery instances.
@param exclude: a instanc... | python | def AND(queryArr,
exclude = None):
"""
create a combined query with multiple items on which to perform an AND operation
@param queryArr: a list of items on which to perform an AND operation. Items can be either a CombinedQuery or BaseQuery instances.
@param exclude: a instanc... | [
"def",
"AND",
"(",
"queryArr",
",",
"exclude",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"queryArr",
",",
"list",
")",
",",
"\"provided argument as not a list\"",
"assert",
"len",
"(",
"queryArr",
")",
">",
"0",
",",
"\"queryArr had an empty list\"",
... | create a combined query with multiple items on which to perform an AND operation
@param queryArr: a list of items on which to perform an AND operation. Items can be either a CombinedQuery or BaseQuery instances.
@param exclude: a instance of BaseQuery, CombinedQuery or None. Used to filter out results m... | [
"create",
"a",
"combined",
"query",
"with",
"multiple",
"items",
"on",
"which",
"to",
"perform",
"an",
"AND",
"operation"
] | 534d20b616de02f5e1cd73665a02d189645dbeb6 | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/Query.py#L121-L138 |
15,302 | postlund/pyatv | pyatv/mrp/pairing.py | MrpPairingProcedure.start_pairing | async def start_pairing(self):
"""Start pairing procedure."""
self.srp.initialize()
msg = messages.crypto_pairing({
tlv8.TLV_METHOD: b'\x00',
tlv8.TLV_SEQ_NO: b'\x01'})
resp = await self.protocol.send_and_receive(
msg, generate_identifier=False)
... | python | async def start_pairing(self):
"""Start pairing procedure."""
self.srp.initialize()
msg = messages.crypto_pairing({
tlv8.TLV_METHOD: b'\x00',
tlv8.TLV_SEQ_NO: b'\x01'})
resp = await self.protocol.send_and_receive(
msg, generate_identifier=False)
... | [
"async",
"def",
"start_pairing",
"(",
"self",
")",
":",
"self",
".",
"srp",
".",
"initialize",
"(",
")",
"msg",
"=",
"messages",
".",
"crypto_pairing",
"(",
"{",
"tlv8",
".",
"TLV_METHOD",
":",
"b'\\x00'",
",",
"tlv8",
".",
"TLV_SEQ_NO",
":",
"b'\\x01'",... | Start pairing procedure. | [
"Start",
"pairing",
"procedure",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/pairing.py#L27-L45 |
15,303 | postlund/pyatv | pyatv/mrp/pairing.py | MrpPairingProcedure.finish_pairing | async def finish_pairing(self, pin):
"""Finish pairing process."""
self.srp.step1(pin)
pub_key, proof = self.srp.step2(self._atv_pub_key, self._atv_salt)
msg = messages.crypto_pairing({
tlv8.TLV_SEQ_NO: b'\x03',
tlv8.TLV_PUBLIC_KEY: pub_key,
tlv8.TLV... | python | async def finish_pairing(self, pin):
"""Finish pairing process."""
self.srp.step1(pin)
pub_key, proof = self.srp.step2(self._atv_pub_key, self._atv_salt)
msg = messages.crypto_pairing({
tlv8.TLV_SEQ_NO: b'\x03',
tlv8.TLV_PUBLIC_KEY: pub_key,
tlv8.TLV... | [
"async",
"def",
"finish_pairing",
"(",
"self",
",",
"pin",
")",
":",
"self",
".",
"srp",
".",
"step1",
"(",
"pin",
")",
"pub_key",
",",
"proof",
"=",
"self",
".",
"srp",
".",
"step2",
"(",
"self",
".",
"_atv_pub_key",
",",
"self",
".",
"_atv_salt",
... | Finish pairing process. | [
"Finish",
"pairing",
"process",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/pairing.py#L47-L74 |
15,304 | postlund/pyatv | pyatv/mrp/pairing.py | MrpPairingVerifier.verify_credentials | async def verify_credentials(self):
"""Verify credentials with device."""
_, public_key = self.srp.initialize()
msg = messages.crypto_pairing({
tlv8.TLV_SEQ_NO: b'\x01',
tlv8.TLV_PUBLIC_KEY: public_key})
resp = await self.protocol.send_and_receive(
ms... | python | async def verify_credentials(self):
"""Verify credentials with device."""
_, public_key = self.srp.initialize()
msg = messages.crypto_pairing({
tlv8.TLV_SEQ_NO: b'\x01',
tlv8.TLV_PUBLIC_KEY: public_key})
resp = await self.protocol.send_and_receive(
ms... | [
"async",
"def",
"verify_credentials",
"(",
"self",
")",
":",
"_",
",",
"public_key",
"=",
"self",
".",
"srp",
".",
"initialize",
"(",
")",
"msg",
"=",
"messages",
".",
"crypto_pairing",
"(",
"{",
"tlv8",
".",
"TLV_SEQ_NO",
":",
"b'\\x01'",
",",
"tlv8",
... | Verify credentials with device. | [
"Verify",
"credentials",
"with",
"device",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/pairing.py#L88-L116 |
15,305 | postlund/pyatv | pyatv/dmap/tag_definitions.py | lookup_tag | def lookup_tag(name):
"""Look up a tag based on its key. Returns a DmapTag."""
return next((_TAGS[t] for t in _TAGS if t == name),
DmapTag(_read_unknown, 'unknown tag')) | python | def lookup_tag(name):
"""Look up a tag based on its key. Returns a DmapTag."""
return next((_TAGS[t] for t in _TAGS if t == name),
DmapTag(_read_unknown, 'unknown tag')) | [
"def",
"lookup_tag",
"(",
"name",
")",
":",
"return",
"next",
"(",
"(",
"_TAGS",
"[",
"t",
"]",
"for",
"t",
"in",
"_TAGS",
"if",
"t",
"==",
"name",
")",
",",
"DmapTag",
"(",
"_read_unknown",
",",
"'unknown tag'",
")",
")"
] | Look up a tag based on its key. Returns a DmapTag. | [
"Look",
"up",
"a",
"tag",
"based",
"on",
"its",
"key",
".",
"Returns",
"a",
"DmapTag",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/tag_definitions.py#L105-L108 |
15,306 | postlund/pyatv | pyatv/__init__.py | connect_to_apple_tv | def connect_to_apple_tv(details, loop, protocol=None, session=None):
"""Connect and logins to an Apple TV."""
service = _get_service_used_to_connect(details, protocol)
# If no session is given, create a default one
if session is None:
session = ClientSession(loop=loop)
# AirPlay service is... | python | def connect_to_apple_tv(details, loop, protocol=None, session=None):
"""Connect and logins to an Apple TV."""
service = _get_service_used_to_connect(details, protocol)
# If no session is given, create a default one
if session is None:
session = ClientSession(loop=loop)
# AirPlay service is... | [
"def",
"connect_to_apple_tv",
"(",
"details",
",",
"loop",
",",
"protocol",
"=",
"None",
",",
"session",
"=",
"None",
")",
":",
"service",
"=",
"_get_service_used_to_connect",
"(",
"details",
",",
"protocol",
")",
"# If no session is given, create a default one",
"i... | Connect and logins to an Apple TV. | [
"Connect",
"and",
"logins",
"to",
"an",
"Apple",
"TV",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__init__.py#L165-L180 |
15,307 | postlund/pyatv | pyatv/__init__.py | _ServiceListener.add_service | def add_service(self, zeroconf, service_type, name):
"""Handle callback from zeroconf when a service has been discovered."""
self.lock.acquire()
try:
self._internal_add(zeroconf, service_type, name)
finally:
self.lock.release() | python | def add_service(self, zeroconf, service_type, name):
"""Handle callback from zeroconf when a service has been discovered."""
self.lock.acquire()
try:
self._internal_add(zeroconf, service_type, name)
finally:
self.lock.release() | [
"def",
"add_service",
"(",
"self",
",",
"zeroconf",
",",
"service_type",
",",
"name",
")",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"_internal_add",
"(",
"zeroconf",
",",
"service_type",
",",
"name",
")",
"finally",
... | Handle callback from zeroconf when a service has been discovered. | [
"Handle",
"callback",
"from",
"zeroconf",
"when",
"a",
"service",
"has",
"been",
"discovered",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__init__.py#L43-L49 |
15,308 | postlund/pyatv | pyatv/__init__.py | _ServiceListener.add_hs_service | def add_hs_service(self, info, address):
"""Add a new device to discovered list."""
if self.protocol and self.protocol != PROTOCOL_DMAP:
return
name = info.properties[b'Name'].decode('utf-8')
hsgid = info.properties[b'hG'].decode('utf-8')
self._handle_service(
... | python | def add_hs_service(self, info, address):
"""Add a new device to discovered list."""
if self.protocol and self.protocol != PROTOCOL_DMAP:
return
name = info.properties[b'Name'].decode('utf-8')
hsgid = info.properties[b'hG'].decode('utf-8')
self._handle_service(
... | [
"def",
"add_hs_service",
"(",
"self",
",",
"info",
",",
"address",
")",
":",
"if",
"self",
".",
"protocol",
"and",
"self",
".",
"protocol",
"!=",
"PROTOCOL_DMAP",
":",
"return",
"name",
"=",
"info",
".",
"properties",
"[",
"b'Name'",
"]",
".",
"decode",
... | Add a new device to discovered list. | [
"Add",
"a",
"new",
"device",
"to",
"discovered",
"list",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__init__.py#L75-L83 |
15,309 | postlund/pyatv | pyatv/__init__.py | _ServiceListener.add_non_hs_service | def add_non_hs_service(self, info, address):
"""Add a new device without Home Sharing to discovered list."""
if self.protocol and self.protocol != PROTOCOL_DMAP:
return
name = info.properties[b'CtlN'].decode('utf-8')
self._handle_service(
address, name, conf.Dmap... | python | def add_non_hs_service(self, info, address):
"""Add a new device without Home Sharing to discovered list."""
if self.protocol and self.protocol != PROTOCOL_DMAP:
return
name = info.properties[b'CtlN'].decode('utf-8')
self._handle_service(
address, name, conf.Dmap... | [
"def",
"add_non_hs_service",
"(",
"self",
",",
"info",
",",
"address",
")",
":",
"if",
"self",
".",
"protocol",
"and",
"self",
".",
"protocol",
"!=",
"PROTOCOL_DMAP",
":",
"return",
"name",
"=",
"info",
".",
"properties",
"[",
"b'CtlN'",
"]",
".",
"decod... | Add a new device without Home Sharing to discovered list. | [
"Add",
"a",
"new",
"device",
"without",
"Home",
"Sharing",
"to",
"discovered",
"list",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__init__.py#L85-L92 |
15,310 | postlund/pyatv | pyatv/__init__.py | _ServiceListener.add_mrp_service | def add_mrp_service(self, info, address):
"""Add a new MediaRemoteProtocol device to discovered list."""
if self.protocol and self.protocol != PROTOCOL_MRP:
return
name = info.properties[b'Name'].decode('utf-8')
self._handle_service(address, name, conf.MrpService(info.port)) | python | def add_mrp_service(self, info, address):
"""Add a new MediaRemoteProtocol device to discovered list."""
if self.protocol and self.protocol != PROTOCOL_MRP:
return
name = info.properties[b'Name'].decode('utf-8')
self._handle_service(address, name, conf.MrpService(info.port)) | [
"def",
"add_mrp_service",
"(",
"self",
",",
"info",
",",
"address",
")",
":",
"if",
"self",
".",
"protocol",
"and",
"self",
".",
"protocol",
"!=",
"PROTOCOL_MRP",
":",
"return",
"name",
"=",
"info",
".",
"properties",
"[",
"b'Name'",
"]",
".",
"decode",
... | Add a new MediaRemoteProtocol device to discovered list. | [
"Add",
"a",
"new",
"MediaRemoteProtocol",
"device",
"to",
"discovered",
"list",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__init__.py#L94-L100 |
15,311 | postlund/pyatv | pyatv/__init__.py | _ServiceListener.add_airplay_service | def add_airplay_service(self, info, address):
"""Add a new AirPlay device to discovered list."""
name = info.name.replace('._airplay._tcp.local.', '')
self._handle_service(address, name, conf.AirPlayService(info.port)) | python | def add_airplay_service(self, info, address):
"""Add a new AirPlay device to discovered list."""
name = info.name.replace('._airplay._tcp.local.', '')
self._handle_service(address, name, conf.AirPlayService(info.port)) | [
"def",
"add_airplay_service",
"(",
"self",
",",
"info",
",",
"address",
")",
":",
"name",
"=",
"info",
".",
"name",
".",
"replace",
"(",
"'._airplay._tcp.local.'",
",",
"''",
")",
"self",
".",
"_handle_service",
"(",
"address",
",",
"name",
",",
"conf",
... | Add a new AirPlay device to discovered list. | [
"Add",
"a",
"new",
"AirPlay",
"device",
"to",
"discovered",
"list",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__init__.py#L102-L105 |
15,312 | postlund/pyatv | pyatv/conf.py | AppleTV.usable_service | def usable_service(self):
"""Return a usable service or None if there is none.
A service is usable if enough configuration to be able to make a
connection is available. If several protocols are usable, MRP will be
preferred over DMAP.
"""
services = self._services
... | python | def usable_service(self):
"""Return a usable service or None if there is none.
A service is usable if enough configuration to be able to make a
connection is available. If several protocols are usable, MRP will be
preferred over DMAP.
"""
services = self._services
... | [
"def",
"usable_service",
"(",
"self",
")",
":",
"services",
"=",
"self",
".",
"_services",
"for",
"protocol",
"in",
"self",
".",
"_supported_protocols",
":",
"if",
"protocol",
"in",
"services",
"and",
"services",
"[",
"protocol",
"]",
".",
"is_usable",
"(",
... | Return a usable service or None if there is none.
A service is usable if enough configuration to be able to make a
connection is available. If several protocols are usable, MRP will be
preferred over DMAP. | [
"Return",
"a",
"usable",
"service",
"or",
"None",
"if",
"there",
"is",
"none",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/conf.py#L49-L61 |
15,313 | postlund/pyatv | pyatv/conf.py | DmapService.superseeded_by | def superseeded_by(self, other_service):
"""Return True if input service has login id and this has not."""
if not other_service or \
other_service.__class__ != self.__class__ or \
other_service.protocol != self.protocol or \
other_service.port != self.port... | python | def superseeded_by(self, other_service):
"""Return True if input service has login id and this has not."""
if not other_service or \
other_service.__class__ != self.__class__ or \
other_service.protocol != self.protocol or \
other_service.port != self.port... | [
"def",
"superseeded_by",
"(",
"self",
",",
"other_service",
")",
":",
"if",
"not",
"other_service",
"or",
"other_service",
".",
"__class__",
"!=",
"self",
".",
"__class__",
"or",
"other_service",
".",
"protocol",
"!=",
"self",
".",
"protocol",
"or",
"other_ser... | Return True if input service has login id and this has not. | [
"Return",
"True",
"if",
"input",
"service",
"has",
"login",
"id",
"and",
"this",
"has",
"not",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/conf.py#L130-L140 |
15,314 | postlund/pyatv | examples/autodiscover.py | print_what_is_playing | async def print_what_is_playing(loop):
"""Find a device and print what is playing."""
print('Discovering devices on network...')
atvs = await pyatv.scan_for_apple_tvs(loop, timeout=5)
if not atvs:
print('no device found', file=sys.stderr)
return
print('Connecting to {0}'.format(atv... | python | async def print_what_is_playing(loop):
"""Find a device and print what is playing."""
print('Discovering devices on network...')
atvs = await pyatv.scan_for_apple_tvs(loop, timeout=5)
if not atvs:
print('no device found', file=sys.stderr)
return
print('Connecting to {0}'.format(atv... | [
"async",
"def",
"print_what_is_playing",
"(",
"loop",
")",
":",
"print",
"(",
"'Discovering devices on network...'",
")",
"atvs",
"=",
"await",
"pyatv",
".",
"scan_for_apple_tvs",
"(",
"loop",
",",
"timeout",
"=",
"5",
")",
"if",
"not",
"atvs",
":",
"print",
... | Find a device and print what is playing. | [
"Find",
"a",
"device",
"and",
"print",
"what",
"is",
"playing",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/examples/autodiscover.py#L11-L29 |
15,315 | postlund/pyatv | pyatv/dmap/pairing.py | DmapPairingHandler.start | async def start(self, **kwargs):
"""Start the pairing server and publish service."""
zeroconf = kwargs['zeroconf']
self._name = kwargs['name']
self._pairing_guid = kwargs.get('pairing_guid', None) or \
self._generate_random_guid()
self._web_server = web.Server(self.h... | python | async def start(self, **kwargs):
"""Start the pairing server and publish service."""
zeroconf = kwargs['zeroconf']
self._name = kwargs['name']
self._pairing_guid = kwargs.get('pairing_guid', None) or \
self._generate_random_guid()
self._web_server = web.Server(self.h... | [
"async",
"def",
"start",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"zeroconf",
"=",
"kwargs",
"[",
"'zeroconf'",
"]",
"self",
".",
"_name",
"=",
"kwargs",
"[",
"'name'",
"]",
"self",
".",
"_pairing_guid",
"=",
"kwargs",
".",
"get",
"(",
"'pairi... | Start the pairing server and publish service. | [
"Start",
"the",
"pairing",
"server",
"and",
"publish",
"service",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/pairing.py#L71-L86 |
15,316 | postlund/pyatv | pyatv/dmap/pairing.py | DmapPairingHandler.stop | async def stop(self, **kwargs):
"""Stop pairing server and unpublish service."""
_LOGGER.debug('Shutting down pairing server')
if self._web_server is not None:
await self._web_server.shutdown()
self._server.close()
if self._server is not None:
await s... | python | async def stop(self, **kwargs):
"""Stop pairing server and unpublish service."""
_LOGGER.debug('Shutting down pairing server')
if self._web_server is not None:
await self._web_server.shutdown()
self._server.close()
if self._server is not None:
await s... | [
"async",
"def",
"stop",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"'Shutting down pairing server'",
")",
"if",
"self",
".",
"_web_server",
"is",
"not",
"None",
":",
"await",
"self",
".",
"_web_server",
".",
"shutdown",
... | Stop pairing server and unpublish service. | [
"Stop",
"pairing",
"server",
"and",
"unpublish",
"service",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/pairing.py#L88-L96 |
15,317 | postlund/pyatv | pyatv/dmap/pairing.py | DmapPairingHandler.handle_request | async def handle_request(self, request):
"""Respond to request if PIN is correct."""
service_name = request.rel_url.query['servicename']
received_code = request.rel_url.query['pairingcode'].lower()
_LOGGER.info('Got pairing request from %s with code %s',
service_name... | python | async def handle_request(self, request):
"""Respond to request if PIN is correct."""
service_name = request.rel_url.query['servicename']
received_code = request.rel_url.query['pairingcode'].lower()
_LOGGER.info('Got pairing request from %s with code %s',
service_name... | [
"async",
"def",
"handle_request",
"(",
"self",
",",
"request",
")",
":",
"service_name",
"=",
"request",
".",
"rel_url",
".",
"query",
"[",
"'servicename'",
"]",
"received_code",
"=",
"request",
".",
"rel_url",
".",
"query",
"[",
"'pairingcode'",
"]",
".",
... | Respond to request if PIN is correct. | [
"Respond",
"to",
"request",
"if",
"PIN",
"is",
"correct",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/pairing.py#L129-L145 |
15,318 | postlund/pyatv | pyatv/log.py | log_binary | def log_binary(logger, message, **kwargs):
"""Log binary data if debug is enabled."""
if logger.isEnabledFor(logging.DEBUG):
output = ('{0}={1}'.format(k, binascii.hexlify(
bytearray(v)).decode()) for k, v in sorted(kwargs.items()))
logger.debug('%s (%s)', message, ', '.join(output)) | python | def log_binary(logger, message, **kwargs):
"""Log binary data if debug is enabled."""
if logger.isEnabledFor(logging.DEBUG):
output = ('{0}={1}'.format(k, binascii.hexlify(
bytearray(v)).decode()) for k, v in sorted(kwargs.items()))
logger.debug('%s (%s)', message, ', '.join(output)) | [
"def",
"log_binary",
"(",
"logger",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"logger",
".",
"isEnabledFor",
"(",
"logging",
".",
"DEBUG",
")",
":",
"output",
"=",
"(",
"'{0}={1}'",
".",
"format",
"(",
"k",
",",
"binascii",
".",
"hexli... | Log binary data if debug is enabled. | [
"Log",
"binary",
"data",
"if",
"debug",
"is",
"enabled",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/log.py#L8-L13 |
15,319 | postlund/pyatv | pyatv/__main__.py | _extract_command_with_args | def _extract_command_with_args(cmd):
"""Parse input command with arguments.
Parses the input command in such a way that the user may
provide additional argument to the command. The format used is this:
command=arg1,arg2,arg3,...
all the additional arguments are passed as arguments to the target
... | python | def _extract_command_with_args(cmd):
"""Parse input command with arguments.
Parses the input command in such a way that the user may
provide additional argument to the command. The format used is this:
command=arg1,arg2,arg3,...
all the additional arguments are passed as arguments to the target
... | [
"def",
"_extract_command_with_args",
"(",
"cmd",
")",
":",
"def",
"_isint",
"(",
"value",
")",
":",
"try",
":",
"int",
"(",
"value",
")",
"return",
"True",
"except",
"ValueError",
":",
"return",
"False",
"equal_sign",
"=",
"cmd",
".",
"find",
"(",
"'='",... | Parse input command with arguments.
Parses the input command in such a way that the user may
provide additional argument to the command. The format used is this:
command=arg1,arg2,arg3,...
all the additional arguments are passed as arguments to the target
method. | [
"Parse",
"input",
"command",
"with",
"arguments",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__main__.py#L362-L385 |
15,320 | postlund/pyatv | pyatv/__main__.py | main | def main():
"""Start the asyncio event loop and runs the application."""
# Helper method so that the coroutine exits cleanly if an exception
# happens (which would leave resources dangling)
async def _run_application(loop):
try:
return await cli_handler(loop)
except Keyboard... | python | def main():
"""Start the asyncio event loop and runs the application."""
# Helper method so that the coroutine exits cleanly if an exception
# happens (which would leave resources dangling)
async def _run_application(loop):
try:
return await cli_handler(loop)
except Keyboard... | [
"def",
"main",
"(",
")",
":",
"# Helper method so that the coroutine exits cleanly if an exception",
"# happens (which would leave resources dangling)",
"async",
"def",
"_run_application",
"(",
"loop",
")",
":",
"try",
":",
"return",
"await",
"cli_handler",
"(",
"loop",
")"... | Start the asyncio event loop and runs the application. | [
"Start",
"the",
"asyncio",
"event",
"loop",
"and",
"runs",
"the",
"application",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__main__.py#L484-L513 |
15,321 | postlund/pyatv | pyatv/__main__.py | GlobalCommands.commands | async def commands(self):
"""Print a list with available commands."""
_print_commands('Remote control', interface.RemoteControl)
_print_commands('Metadata', interface.Metadata)
_print_commands('Playing', interface.Playing)
_print_commands('AirPlay', interface.AirPlay)
_pr... | python | async def commands(self):
"""Print a list with available commands."""
_print_commands('Remote control', interface.RemoteControl)
_print_commands('Metadata', interface.Metadata)
_print_commands('Playing', interface.Playing)
_print_commands('AirPlay', interface.AirPlay)
_pr... | [
"async",
"def",
"commands",
"(",
"self",
")",
":",
"_print_commands",
"(",
"'Remote control'",
",",
"interface",
".",
"RemoteControl",
")",
"_print_commands",
"(",
"'Metadata'",
",",
"interface",
".",
"Metadata",
")",
"_print_commands",
"(",
"'Playing'",
",",
"i... | Print a list with available commands. | [
"Print",
"a",
"list",
"with",
"available",
"commands",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__main__.py#L43-L52 |
15,322 | postlund/pyatv | pyatv/__main__.py | GlobalCommands.help | async def help(self):
"""Print help text for a command."""
if len(self.args.command) != 2:
print('Which command do you want help with?', file=sys.stderr)
return 1
iface = [interface.RemoteControl,
interface.Metadata,
interface.Playing,
... | python | async def help(self):
"""Print help text for a command."""
if len(self.args.command) != 2:
print('Which command do you want help with?', file=sys.stderr)
return 1
iface = [interface.RemoteControl,
interface.Metadata,
interface.Playing,
... | [
"async",
"def",
"help",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"args",
".",
"command",
")",
"!=",
"2",
":",
"print",
"(",
"'Which command do you want help with?'",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"return",
"1",
"iface",
"=",... | Print help text for a command. | [
"Print",
"help",
"text",
"for",
"a",
"command",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__main__.py#L54-L78 |
15,323 | postlund/pyatv | pyatv/__main__.py | GlobalCommands.scan | async def scan(self):
"""Scan for Apple TVs on the network."""
atvs = await pyatv.scan_for_apple_tvs(
self.loop, timeout=self.args.scan_timeout, only_usable=False)
_print_found_apple_tvs(atvs)
return 0 | python | async def scan(self):
"""Scan for Apple TVs on the network."""
atvs = await pyatv.scan_for_apple_tvs(
self.loop, timeout=self.args.scan_timeout, only_usable=False)
_print_found_apple_tvs(atvs)
return 0 | [
"async",
"def",
"scan",
"(",
"self",
")",
":",
"atvs",
"=",
"await",
"pyatv",
".",
"scan_for_apple_tvs",
"(",
"self",
".",
"loop",
",",
"timeout",
"=",
"self",
".",
"args",
".",
"scan_timeout",
",",
"only_usable",
"=",
"False",
")",
"_print_found_apple_tvs... | Scan for Apple TVs on the network. | [
"Scan",
"for",
"Apple",
"TVs",
"on",
"the",
"network",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__main__.py#L80-L86 |
15,324 | postlund/pyatv | pyatv/__main__.py | DeviceCommands.cli | async def cli(self):
"""Enter commands in a simple CLI."""
print('Enter commands and press enter')
print('Type help for help and exit to quit')
while True:
command = await _read_input(self.loop, 'pyatv> ')
if command.lower() == 'exit':
break
... | python | async def cli(self):
"""Enter commands in a simple CLI."""
print('Enter commands and press enter')
print('Type help for help and exit to quit')
while True:
command = await _read_input(self.loop, 'pyatv> ')
if command.lower() == 'exit':
break
... | [
"async",
"def",
"cli",
"(",
"self",
")",
":",
"print",
"(",
"'Enter commands and press enter'",
")",
"print",
"(",
"'Type help for help and exit to quit'",
")",
"while",
"True",
":",
"command",
"=",
"await",
"_read_input",
"(",
"self",
".",
"loop",
",",
"'pyatv>... | Enter commands in a simple CLI. | [
"Enter",
"commands",
"in",
"a",
"simple",
"CLI",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__main__.py#L101-L115 |
15,325 | postlund/pyatv | pyatv/__main__.py | DeviceCommands.artwork_save | async def artwork_save(self):
"""Download artwork and save it to artwork.png."""
artwork = await self.atv.metadata.artwork()
if artwork is not None:
with open('artwork.png', 'wb') as file:
file.write(artwork)
else:
print('No artwork is currently av... | python | async def artwork_save(self):
"""Download artwork and save it to artwork.png."""
artwork = await self.atv.metadata.artwork()
if artwork is not None:
with open('artwork.png', 'wb') as file:
file.write(artwork)
else:
print('No artwork is currently av... | [
"async",
"def",
"artwork_save",
"(",
"self",
")",
":",
"artwork",
"=",
"await",
"self",
".",
"atv",
".",
"metadata",
".",
"artwork",
"(",
")",
"if",
"artwork",
"is",
"not",
"None",
":",
"with",
"open",
"(",
"'artwork.png'",
",",
"'wb'",
")",
"as",
"f... | Download artwork and save it to artwork.png. | [
"Download",
"artwork",
"and",
"save",
"it",
"to",
"artwork",
".",
"png",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__main__.py#L117-L126 |
15,326 | postlund/pyatv | pyatv/__main__.py | DeviceCommands.push_updates | async def push_updates(self):
"""Listen for push updates."""
print('Press ENTER to stop')
self.atv.push_updater.start()
await self.atv.login()
await self.loop.run_in_executor(None, sys.stdin.readline)
self.atv.push_updater.stop()
return 0 | python | async def push_updates(self):
"""Listen for push updates."""
print('Press ENTER to stop')
self.atv.push_updater.start()
await self.atv.login()
await self.loop.run_in_executor(None, sys.stdin.readline)
self.atv.push_updater.stop()
return 0 | [
"async",
"def",
"push_updates",
"(",
"self",
")",
":",
"print",
"(",
"'Press ENTER to stop'",
")",
"self",
".",
"atv",
".",
"push_updater",
".",
"start",
"(",
")",
"await",
"self",
".",
"atv",
".",
"login",
"(",
")",
"await",
"self",
".",
"loop",
".",
... | Listen for push updates. | [
"Listen",
"for",
"push",
"updates",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__main__.py#L128-L136 |
15,327 | postlund/pyatv | pyatv/__main__.py | DeviceCommands.auth | async def auth(self):
"""Perform AirPlay device authentication."""
credentials = await self.atv.airplay.generate_credentials()
await self.atv.airplay.load_credentials(credentials)
try:
await self.atv.airplay.start_authentication()
pin = await _read_input(self.loo... | python | async def auth(self):
"""Perform AirPlay device authentication."""
credentials = await self.atv.airplay.generate_credentials()
await self.atv.airplay.load_credentials(credentials)
try:
await self.atv.airplay.start_authentication()
pin = await _read_input(self.loo... | [
"async",
"def",
"auth",
"(",
"self",
")",
":",
"credentials",
"=",
"await",
"self",
".",
"atv",
".",
"airplay",
".",
"generate_credentials",
"(",
")",
"await",
"self",
".",
"atv",
".",
"airplay",
".",
"load_credentials",
"(",
"credentials",
")",
"try",
"... | Perform AirPlay device authentication. | [
"Perform",
"AirPlay",
"device",
"authentication",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__main__.py#L138-L154 |
15,328 | postlund/pyatv | pyatv/__main__.py | DeviceCommands.pair | async def pair(self):
"""Pair pyatv as a remote control with an Apple TV."""
# Connect using the specified protocol
# TODO: config should be stored elsewhere so that API is same for both
protocol = self.atv.service.protocol
if protocol == const.PROTOCOL_DMAP:
await se... | python | async def pair(self):
"""Pair pyatv as a remote control with an Apple TV."""
# Connect using the specified protocol
# TODO: config should be stored elsewhere so that API is same for both
protocol = self.atv.service.protocol
if protocol == const.PROTOCOL_DMAP:
await se... | [
"async",
"def",
"pair",
"(",
"self",
")",
":",
"# Connect using the specified protocol",
"# TODO: config should be stored elsewhere so that API is same for both",
"protocol",
"=",
"self",
".",
"atv",
".",
"service",
".",
"protocol",
"if",
"protocol",
"==",
"const",
".",
... | Pair pyatv as a remote control with an Apple TV. | [
"Pair",
"pyatv",
"as",
"a",
"remote",
"control",
"with",
"an",
"Apple",
"TV",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/__main__.py#L156-L198 |
15,329 | postlund/pyatv | pyatv/convert.py | media_kind | def media_kind(kind):
"""Convert iTunes media kind to API representation."""
if kind in [1]:
return const.MEDIA_TYPE_UNKNOWN
if kind in [3, 7, 11, 12, 13, 18, 32]:
return const.MEDIA_TYPE_VIDEO
if kind in [2, 4, 10, 14, 17, 21, 36]:
return const.MEDIA_TYPE_MUSIC
if kind in [8... | python | def media_kind(kind):
"""Convert iTunes media kind to API representation."""
if kind in [1]:
return const.MEDIA_TYPE_UNKNOWN
if kind in [3, 7, 11, 12, 13, 18, 32]:
return const.MEDIA_TYPE_VIDEO
if kind in [2, 4, 10, 14, 17, 21, 36]:
return const.MEDIA_TYPE_MUSIC
if kind in [8... | [
"def",
"media_kind",
"(",
"kind",
")",
":",
"if",
"kind",
"in",
"[",
"1",
"]",
":",
"return",
"const",
".",
"MEDIA_TYPE_UNKNOWN",
"if",
"kind",
"in",
"[",
"3",
",",
"7",
",",
"11",
",",
"12",
",",
"13",
",",
"18",
",",
"32",
"]",
":",
"return",... | Convert iTunes media kind to API representation. | [
"Convert",
"iTunes",
"media",
"kind",
"to",
"API",
"representation",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/convert.py#L6-L17 |
15,330 | postlund/pyatv | pyatv/convert.py | media_type_str | def media_type_str(mediatype):
"""Convert internal API media type to string."""
if mediatype == const.MEDIA_TYPE_UNKNOWN:
return 'Unknown'
if mediatype == const.MEDIA_TYPE_VIDEO:
return 'Video'
if mediatype == const.MEDIA_TYPE_MUSIC:
return 'Music'
if mediatype == const.MEDIA... | python | def media_type_str(mediatype):
"""Convert internal API media type to string."""
if mediatype == const.MEDIA_TYPE_UNKNOWN:
return 'Unknown'
if mediatype == const.MEDIA_TYPE_VIDEO:
return 'Video'
if mediatype == const.MEDIA_TYPE_MUSIC:
return 'Music'
if mediatype == const.MEDIA... | [
"def",
"media_type_str",
"(",
"mediatype",
")",
":",
"if",
"mediatype",
"==",
"const",
".",
"MEDIA_TYPE_UNKNOWN",
":",
"return",
"'Unknown'",
"if",
"mediatype",
"==",
"const",
".",
"MEDIA_TYPE_VIDEO",
":",
"return",
"'Video'",
"if",
"mediatype",
"==",
"const",
... | Convert internal API media type to string. | [
"Convert",
"internal",
"API",
"media",
"type",
"to",
"string",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/convert.py#L20-L30 |
15,331 | postlund/pyatv | pyatv/convert.py | playstate | def playstate(state):
"""Convert iTunes playstate to API representation."""
# pylint: disable=too-many-return-statements
if state is None:
return const.PLAY_STATE_NO_MEDIA
if state == 0:
return const.PLAY_STATE_IDLE
if state == 1:
return const.PLAY_STATE_LOADING
if state ... | python | def playstate(state):
"""Convert iTunes playstate to API representation."""
# pylint: disable=too-many-return-statements
if state is None:
return const.PLAY_STATE_NO_MEDIA
if state == 0:
return const.PLAY_STATE_IDLE
if state == 1:
return const.PLAY_STATE_LOADING
if state ... | [
"def",
"playstate",
"(",
"state",
")",
":",
"# pylint: disable=too-many-return-statements",
"if",
"state",
"is",
"None",
":",
"return",
"const",
".",
"PLAY_STATE_NO_MEDIA",
"if",
"state",
"==",
"0",
":",
"return",
"const",
".",
"PLAY_STATE_IDLE",
"if",
"state",
... | Convert iTunes playstate to API representation. | [
"Convert",
"iTunes",
"playstate",
"to",
"API",
"representation",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/convert.py#L33-L51 |
15,332 | postlund/pyatv | pyatv/convert.py | playstate_str | def playstate_str(state):
"""Convert internal API playstate to string."""
if state == const.PLAY_STATE_NO_MEDIA:
return 'No media'
if state == const.PLAY_STATE_IDLE:
return 'Idle'
if state == const.PLAY_STATE_LOADING:
return 'Loading'
if state == const.PLAY_STATE_PAUSED:
... | python | def playstate_str(state):
"""Convert internal API playstate to string."""
if state == const.PLAY_STATE_NO_MEDIA:
return 'No media'
if state == const.PLAY_STATE_IDLE:
return 'Idle'
if state == const.PLAY_STATE_LOADING:
return 'Loading'
if state == const.PLAY_STATE_PAUSED:
... | [
"def",
"playstate_str",
"(",
"state",
")",
":",
"if",
"state",
"==",
"const",
".",
"PLAY_STATE_NO_MEDIA",
":",
"return",
"'No media'",
"if",
"state",
"==",
"const",
".",
"PLAY_STATE_IDLE",
":",
"return",
"'Idle'",
"if",
"state",
"==",
"const",
".",
"PLAY_STA... | Convert internal API playstate to string. | [
"Convert",
"internal",
"API",
"playstate",
"to",
"string",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/convert.py#L55-L71 |
15,333 | postlund/pyatv | pyatv/convert.py | repeat_str | def repeat_str(state):
"""Convert internal API repeat state to string."""
if state == const.REPEAT_STATE_OFF:
return 'Off'
if state == const.REPEAT_STATE_TRACK:
return 'Track'
if state == const.REPEAT_STATE_ALL:
return 'All'
return 'Unsupported' | python | def repeat_str(state):
"""Convert internal API repeat state to string."""
if state == const.REPEAT_STATE_OFF:
return 'Off'
if state == const.REPEAT_STATE_TRACK:
return 'Track'
if state == const.REPEAT_STATE_ALL:
return 'All'
return 'Unsupported' | [
"def",
"repeat_str",
"(",
"state",
")",
":",
"if",
"state",
"==",
"const",
".",
"REPEAT_STATE_OFF",
":",
"return",
"'Off'",
"if",
"state",
"==",
"const",
".",
"REPEAT_STATE_TRACK",
":",
"return",
"'Track'",
"if",
"state",
"==",
"const",
".",
"REPEAT_STATE_AL... | Convert internal API repeat state to string. | [
"Convert",
"internal",
"API",
"repeat",
"state",
"to",
"string",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/convert.py#L74-L82 |
15,334 | postlund/pyatv | pyatv/convert.py | protocol_str | def protocol_str(protocol):
"""Convert internal API protocol to string."""
if protocol == const.PROTOCOL_MRP:
return 'MRP'
if protocol == const.PROTOCOL_DMAP:
return 'DMAP'
if protocol == const.PROTOCOL_AIRPLAY:
return 'AirPlay'
return 'Unknown' | python | def protocol_str(protocol):
"""Convert internal API protocol to string."""
if protocol == const.PROTOCOL_MRP:
return 'MRP'
if protocol == const.PROTOCOL_DMAP:
return 'DMAP'
if protocol == const.PROTOCOL_AIRPLAY:
return 'AirPlay'
return 'Unknown' | [
"def",
"protocol_str",
"(",
"protocol",
")",
":",
"if",
"protocol",
"==",
"const",
".",
"PROTOCOL_MRP",
":",
"return",
"'MRP'",
"if",
"protocol",
"==",
"const",
".",
"PROTOCOL_DMAP",
":",
"return",
"'DMAP'",
"if",
"protocol",
"==",
"const",
".",
"PROTOCOL_AI... | Convert internal API protocol to string. | [
"Convert",
"internal",
"API",
"protocol",
"to",
"string",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/convert.py#L96-L104 |
15,335 | postlund/pyatv | pyatv/dmap/parser.py | first | def first(dmap_data, *path):
"""Look up a value given a path in some parsed DMAP data."""
if not (path and isinstance(dmap_data, list)):
return dmap_data
for key in dmap_data:
if path[0] in key:
return first(key[path[0]], *path[1:])
return None | python | def first(dmap_data, *path):
"""Look up a value given a path in some parsed DMAP data."""
if not (path and isinstance(dmap_data, list)):
return dmap_data
for key in dmap_data:
if path[0] in key:
return first(key[path[0]], *path[1:])
return None | [
"def",
"first",
"(",
"dmap_data",
",",
"*",
"path",
")",
":",
"if",
"not",
"(",
"path",
"and",
"isinstance",
"(",
"dmap_data",
",",
"list",
")",
")",
":",
"return",
"dmap_data",
"for",
"key",
"in",
"dmap_data",
":",
"if",
"path",
"[",
"0",
"]",
"in... | Look up a value given a path in some parsed DMAP data. | [
"Look",
"up",
"a",
"value",
"given",
"a",
"path",
"in",
"some",
"parsed",
"DMAP",
"data",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/parser.py#L56-L65 |
15,336 | postlund/pyatv | pyatv/dmap/parser.py | pprint | def pprint(data, tag_lookup, indent=0):
"""Return a pretty formatted string of parsed DMAP data."""
output = ''
if isinstance(data, dict):
for key, value in data.items():
tag = tag_lookup(key)
if isinstance(value, (dict, list)) and tag.type is not read_bplist:
... | python | def pprint(data, tag_lookup, indent=0):
"""Return a pretty formatted string of parsed DMAP data."""
output = ''
if isinstance(data, dict):
for key, value in data.items():
tag = tag_lookup(key)
if isinstance(value, (dict, list)) and tag.type is not read_bplist:
... | [
"def",
"pprint",
"(",
"data",
",",
"tag_lookup",
",",
"indent",
"=",
"0",
")",
":",
"output",
"=",
"''",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"tag",
"=",
... | Return a pretty formatted string of parsed DMAP data. | [
"Return",
"a",
"pretty",
"formatted",
"string",
"of",
"parsed",
"DMAP",
"data",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/parser.py#L69-L87 |
15,337 | postlund/pyatv | pyatv/interface.py | retrieve_commands | def retrieve_commands(obj):
"""Retrieve all commands and help texts from an API object."""
commands = {} # Name and help
for func in obj.__dict__:
if not inspect.isfunction(obj.__dict__[func]) and \
not isinstance(obj.__dict__[func], property):
continue
if func.starts... | python | def retrieve_commands(obj):
"""Retrieve all commands and help texts from an API object."""
commands = {} # Name and help
for func in obj.__dict__:
if not inspect.isfunction(obj.__dict__[func]) and \
not isinstance(obj.__dict__[func], property):
continue
if func.starts... | [
"def",
"retrieve_commands",
"(",
"obj",
")",
":",
"commands",
"=",
"{",
"}",
"# Name and help",
"for",
"func",
"in",
"obj",
".",
"__dict__",
":",
"if",
"not",
"inspect",
".",
"isfunction",
"(",
"obj",
".",
"__dict__",
"[",
"func",
"]",
")",
"and",
"not... | Retrieve all commands and help texts from an API object. | [
"Retrieve",
"all",
"commands",
"and",
"help",
"texts",
"from",
"an",
"API",
"object",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/interface.py#L28-L39 |
15,338 | postlund/pyatv | pyatv/interface.py | Playing.hash | def hash(self):
"""Create a unique hash for what is currently playing.
The hash is based on title, artist, album and total time. It should
always be the same for the same content, but it is not guaranteed.
"""
base = '{0}{1}{2}{3}'.format(
self.title, self.artist, se... | python | def hash(self):
"""Create a unique hash for what is currently playing.
The hash is based on title, artist, album and total time. It should
always be the same for the same content, but it is not guaranteed.
"""
base = '{0}{1}{2}{3}'.format(
self.title, self.artist, se... | [
"def",
"hash",
"(",
"self",
")",
":",
"base",
"=",
"'{0}{1}{2}{3}'",
".",
"format",
"(",
"self",
".",
"title",
",",
"self",
".",
"artist",
",",
"self",
".",
"album",
",",
"self",
".",
"total_time",
")",
"return",
"hashlib",
".",
"sha256",
"(",
"base"... | Create a unique hash for what is currently playing.
The hash is based on title, artist, album and total time. It should
always be the same for the same content, but it is not guaranteed. | [
"Create",
"a",
"unique",
"hash",
"for",
"what",
"is",
"currently",
"playing",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/interface.py#L213-L221 |
15,339 | postlund/pyatv | scripts/autogen_protobuf_extensions.py | extract_message_info | def extract_message_info():
"""Get information about all messages of interest."""
base_path = BASE_PACKAGE.replace('.', '/')
filename = os.path.join(base_path, 'ProtocolMessage.proto')
with open(filename, 'r') as file:
types_found = False
for line in file:
stripped = line.l... | python | def extract_message_info():
"""Get information about all messages of interest."""
base_path = BASE_PACKAGE.replace('.', '/')
filename = os.path.join(base_path, 'ProtocolMessage.proto')
with open(filename, 'r') as file:
types_found = False
for line in file:
stripped = line.l... | [
"def",
"extract_message_info",
"(",
")",
":",
"base_path",
"=",
"BASE_PACKAGE",
".",
"replace",
"(",
"'.'",
",",
"'/'",
")",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"base_path",
",",
"'ProtocolMessage.proto'",
")",
"with",
"open",
"(",
"filen... | Get information about all messages of interest. | [
"Get",
"information",
"about",
"all",
"messages",
"of",
"interest",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/scripts/autogen_protobuf_extensions.py#L54-L83 |
15,340 | postlund/pyatv | scripts/autogen_protobuf_extensions.py | main | def main():
"""Script starts somewhere around here."""
message_names = set()
packages = []
messages = []
extensions = []
constants = []
# Extract everything needed to generate output file
for info in extract_message_info():
message_names.add(info.title)
packages.append(
... | python | def main():
"""Script starts somewhere around here."""
message_names = set()
packages = []
messages = []
extensions = []
constants = []
# Extract everything needed to generate output file
for info in extract_message_info():
message_names.add(info.title)
packages.append(
... | [
"def",
"main",
"(",
")",
":",
"message_names",
"=",
"set",
"(",
")",
"packages",
"=",
"[",
"]",
"messages",
"=",
"[",
"]",
"extensions",
"=",
"[",
"]",
"constants",
"=",
"[",
"]",
"# Extract everything needed to generate output file",
"for",
"info",
"in",
... | Script starts somewhere around here. | [
"Script",
"starts",
"somewhere",
"around",
"here",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/scripts/autogen_protobuf_extensions.py#L101-L140 |
15,341 | postlund/pyatv | pyatv/mrp/srp.py | hkdf_expand | def hkdf_expand(salt, info, shared_secret):
"""Derive encryption keys from shared secret."""
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
from cryptography.hazmat.backends import default_backend
hkdf = HKDF(
algorithm=hashes.SHA51... | python | def hkdf_expand(salt, info, shared_secret):
"""Derive encryption keys from shared secret."""
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
from cryptography.hazmat.backends import default_backend
hkdf = HKDF(
algorithm=hashes.SHA51... | [
"def",
"hkdf_expand",
"(",
"salt",
",",
"info",
",",
"shared_secret",
")",
":",
"from",
"cryptography",
".",
"hazmat",
".",
"primitives",
"import",
"hashes",
"from",
"cryptography",
".",
"hazmat",
".",
"primitives",
".",
"kdf",
".",
"hkdf",
"import",
"HKDF",... | Derive encryption keys from shared secret. | [
"Derive",
"encryption",
"keys",
"from",
"shared",
"secret",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/srp.py#L53-L65 |
15,342 | postlund/pyatv | pyatv/mrp/srp.py | Credentials.parse | def parse(cls, detail_string):
"""Parse a string represention of Credentials."""
split = detail_string.split(':')
if len(split) != 4:
raise Exception('invalid credentials') # TODO: other exception
ltpk = binascii.unhexlify(split[0])
ltsk = binascii.unhexlify(split[1... | python | def parse(cls, detail_string):
"""Parse a string represention of Credentials."""
split = detail_string.split(':')
if len(split) != 4:
raise Exception('invalid credentials') # TODO: other exception
ltpk = binascii.unhexlify(split[0])
ltsk = binascii.unhexlify(split[1... | [
"def",
"parse",
"(",
"cls",
",",
"detail_string",
")",
":",
"split",
"=",
"detail_string",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(",
"split",
")",
"!=",
"4",
":",
"raise",
"Exception",
"(",
"'invalid credentials'",
")",
"# TODO: other exception",
"l... | Parse a string represention of Credentials. | [
"Parse",
"a",
"string",
"represention",
"of",
"Credentials",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/srp.py#L32-L42 |
15,343 | postlund/pyatv | pyatv/mrp/srp.py | SRPAuthHandler.initialize | def initialize(self):
"""Initialize operation by generating new keys."""
self._signing_key = SigningKey(os.urandom(32))
self._auth_private = self._signing_key.to_seed()
self._auth_public = self._signing_key.get_verifying_key().to_bytes()
self._verify_private = curve25519.Private(... | python | def initialize(self):
"""Initialize operation by generating new keys."""
self._signing_key = SigningKey(os.urandom(32))
self._auth_private = self._signing_key.to_seed()
self._auth_public = self._signing_key.get_verifying_key().to_bytes()
self._verify_private = curve25519.Private(... | [
"def",
"initialize",
"(",
"self",
")",
":",
"self",
".",
"_signing_key",
"=",
"SigningKey",
"(",
"os",
".",
"urandom",
"(",
"32",
")",
")",
"self",
".",
"_auth_private",
"=",
"self",
".",
"_signing_key",
".",
"to_seed",
"(",
")",
"self",
".",
"_auth_pu... | Initialize operation by generating new keys. | [
"Initialize",
"operation",
"by",
"generating",
"new",
"keys",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/srp.py#L85-L92 |
15,344 | postlund/pyatv | pyatv/mrp/srp.py | SRPAuthHandler.verify1 | def verify1(self, credentials, session_pub_key, encrypted):
"""First verification step."""
# No additional hashing used
self._shared = self._verify_private.get_shared_key(
curve25519.Public(session_pub_key), hashfunc=lambda x: x)
session_key = hkdf_expand('Pair-Verify-Encryp... | python | def verify1(self, credentials, session_pub_key, encrypted):
"""First verification step."""
# No additional hashing used
self._shared = self._verify_private.get_shared_key(
curve25519.Public(session_pub_key), hashfunc=lambda x: x)
session_key = hkdf_expand('Pair-Verify-Encryp... | [
"def",
"verify1",
"(",
"self",
",",
"credentials",
",",
"session_pub_key",
",",
"encrypted",
")",
":",
"# No additional hashing used",
"self",
".",
"_shared",
"=",
"self",
".",
"_verify_private",
".",
"get_shared_key",
"(",
"curve25519",
".",
"Public",
"(",
"ses... | First verification step. | [
"First",
"verification",
"step",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/srp.py#L94-L127 |
15,345 | postlund/pyatv | pyatv/mrp/srp.py | SRPAuthHandler.verify2 | def verify2(self):
"""Last verification step.
The derived keys (output, input) are returned here.
"""
output_key = hkdf_expand('MediaRemote-Salt',
'MediaRemote-Write-Encryption-Key',
self._shared)
input_key = hkd... | python | def verify2(self):
"""Last verification step.
The derived keys (output, input) are returned here.
"""
output_key = hkdf_expand('MediaRemote-Salt',
'MediaRemote-Write-Encryption-Key',
self._shared)
input_key = hkd... | [
"def",
"verify2",
"(",
"self",
")",
":",
"output_key",
"=",
"hkdf_expand",
"(",
"'MediaRemote-Salt'",
",",
"'MediaRemote-Write-Encryption-Key'",
",",
"self",
".",
"_shared",
")",
"input_key",
"=",
"hkdf_expand",
"(",
"'MediaRemote-Salt'",
",",
"'MediaRemote-Read-Encry... | Last verification step.
The derived keys (output, input) are returned here. | [
"Last",
"verification",
"step",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/srp.py#L129-L143 |
15,346 | postlund/pyatv | pyatv/mrp/srp.py | SRPAuthHandler.step1 | def step1(self, pin):
"""First pairing step."""
context = SRPContext(
'Pair-Setup', str(pin),
prime=constants.PRIME_3072,
generator=constants.PRIME_3072_GEN,
hash_func=hashlib.sha512)
self._session = SRPClientSession(
context, binascii.... | python | def step1(self, pin):
"""First pairing step."""
context = SRPContext(
'Pair-Setup', str(pin),
prime=constants.PRIME_3072,
generator=constants.PRIME_3072_GEN,
hash_func=hashlib.sha512)
self._session = SRPClientSession(
context, binascii.... | [
"def",
"step1",
"(",
"self",
",",
"pin",
")",
":",
"context",
"=",
"SRPContext",
"(",
"'Pair-Setup'",
",",
"str",
"(",
"pin",
")",
",",
"prime",
"=",
"constants",
".",
"PRIME_3072",
",",
"generator",
"=",
"constants",
".",
"PRIME_3072_GEN",
",",
"hash_fu... | First pairing step. | [
"First",
"pairing",
"step",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/srp.py#L145-L153 |
15,347 | postlund/pyatv | pyatv/mrp/srp.py | SRPAuthHandler.step2 | def step2(self, atv_pub_key, atv_salt):
"""Second pairing step."""
pk_str = binascii.hexlify(atv_pub_key).decode()
salt = binascii.hexlify(atv_salt).decode()
self._client_session_key, _, _ = self._session.process(pk_str, salt)
if not self._session.verify_proof(self._session.key_... | python | def step2(self, atv_pub_key, atv_salt):
"""Second pairing step."""
pk_str = binascii.hexlify(atv_pub_key).decode()
salt = binascii.hexlify(atv_salt).decode()
self._client_session_key, _, _ = self._session.process(pk_str, salt)
if not self._session.verify_proof(self._session.key_... | [
"def",
"step2",
"(",
"self",
",",
"atv_pub_key",
",",
"atv_salt",
")",
":",
"pk_str",
"=",
"binascii",
".",
"hexlify",
"(",
"atv_pub_key",
")",
".",
"decode",
"(",
")",
"salt",
"=",
"binascii",
".",
"hexlify",
"(",
"atv_salt",
")",
".",
"decode",
"(",
... | Second pairing step. | [
"Second",
"pairing",
"step",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/srp.py#L155-L167 |
15,348 | postlund/pyatv | pyatv/mrp/srp.py | SRPAuthHandler.step3 | def step3(self):
"""Third pairing step."""
ios_device_x = hkdf_expand(
'Pair-Setup-Controller-Sign-Salt',
'Pair-Setup-Controller-Sign-Info',
binascii.unhexlify(self._client_session_key))
self._session_key = hkdf_expand(
'Pair-Setup-Encrypt-Salt',
... | python | def step3(self):
"""Third pairing step."""
ios_device_x = hkdf_expand(
'Pair-Setup-Controller-Sign-Salt',
'Pair-Setup-Controller-Sign-Info',
binascii.unhexlify(self._client_session_key))
self._session_key = hkdf_expand(
'Pair-Setup-Encrypt-Salt',
... | [
"def",
"step3",
"(",
"self",
")",
":",
"ios_device_x",
"=",
"hkdf_expand",
"(",
"'Pair-Setup-Controller-Sign-Salt'",
",",
"'Pair-Setup-Controller-Sign-Info'",
",",
"binascii",
".",
"unhexlify",
"(",
"self",
".",
"_client_session_key",
")",
")",
"self",
".",
"_sessio... | Third pairing step. | [
"Third",
"pairing",
"step",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/srp.py#L169-L191 |
15,349 | postlund/pyatv | pyatv/mrp/srp.py | SRPAuthHandler.step4 | def step4(self, encrypted_data):
"""Last pairing step."""
chacha = chacha20.Chacha20Cipher(self._session_key, self._session_key)
decrypted_tlv_bytes = chacha.decrypt(
encrypted_data, nounce='PS-Msg06'.encode())
if not decrypted_tlv_bytes:
raise Exception('data dec... | python | def step4(self, encrypted_data):
"""Last pairing step."""
chacha = chacha20.Chacha20Cipher(self._session_key, self._session_key)
decrypted_tlv_bytes = chacha.decrypt(
encrypted_data, nounce='PS-Msg06'.encode())
if not decrypted_tlv_bytes:
raise Exception('data dec... | [
"def",
"step4",
"(",
"self",
",",
"encrypted_data",
")",
":",
"chacha",
"=",
"chacha20",
".",
"Chacha20Cipher",
"(",
"self",
".",
"_session_key",
",",
"self",
".",
"_session_key",
")",
"decrypted_tlv_bytes",
"=",
"chacha",
".",
"decrypt",
"(",
"encrypted_data"... | Last pairing step. | [
"Last",
"pairing",
"step",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/srp.py#L193-L215 |
15,350 | postlund/pyatv | pyatv/airplay/srp.py | hash_sha512 | def hash_sha512(*indata):
"""Create SHA512 hash for input arguments."""
hasher = hashlib.sha512()
for data in indata:
if isinstance(data, str):
hasher.update(data.encode('utf-8'))
elif isinstance(data, bytes):
hasher.update(data)
else:
raise Except... | python | def hash_sha512(*indata):
"""Create SHA512 hash for input arguments."""
hasher = hashlib.sha512()
for data in indata:
if isinstance(data, str):
hasher.update(data.encode('utf-8'))
elif isinstance(data, bytes):
hasher.update(data)
else:
raise Except... | [
"def",
"hash_sha512",
"(",
"*",
"indata",
")",
":",
"hasher",
"=",
"hashlib",
".",
"sha512",
"(",
")",
"for",
"data",
"in",
"indata",
":",
"if",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"hasher",
".",
"update",
"(",
"data",
".",
"encode",
"... | Create SHA512 hash for input arguments. | [
"Create",
"SHA512",
"hash",
"for",
"input",
"arguments",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/srp.py#L20-L30 |
15,351 | postlund/pyatv | pyatv/airplay/srp.py | aes_encrypt | def aes_encrypt(mode, aes_key, aes_iv, *data):
"""Encrypt data with AES in specified mode."""
encryptor = Cipher(
algorithms.AES(aes_key),
mode(aes_iv),
backend=default_backend()).encryptor()
result = None
for value in data:
result = encryptor.update(value)
encryptor... | python | def aes_encrypt(mode, aes_key, aes_iv, *data):
"""Encrypt data with AES in specified mode."""
encryptor = Cipher(
algorithms.AES(aes_key),
mode(aes_iv),
backend=default_backend()).encryptor()
result = None
for value in data:
result = encryptor.update(value)
encryptor... | [
"def",
"aes_encrypt",
"(",
"mode",
",",
"aes_key",
",",
"aes_iv",
",",
"*",
"data",
")",
":",
"encryptor",
"=",
"Cipher",
"(",
"algorithms",
".",
"AES",
"(",
"aes_key",
")",
",",
"mode",
"(",
"aes_iv",
")",
",",
"backend",
"=",
"default_backend",
"(",
... | Encrypt data with AES in specified mode. | [
"Encrypt",
"data",
"with",
"AES",
"in",
"specified",
"mode",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/srp.py#L33-L45 |
15,352 | postlund/pyatv | pyatv/airplay/srp.py | new_credentials | def new_credentials():
"""Generate a new identifier and seed for authentication.
Use the returned values in the following way:
* The identifier shall be passed as username to SRPAuthHandler.step1
* Seed shall be passed to SRPAuthHandler constructor
"""
identifier = binascii.b2a_hex(os.urandom(8... | python | def new_credentials():
"""Generate a new identifier and seed for authentication.
Use the returned values in the following way:
* The identifier shall be passed as username to SRPAuthHandler.step1
* Seed shall be passed to SRPAuthHandler constructor
"""
identifier = binascii.b2a_hex(os.urandom(8... | [
"def",
"new_credentials",
"(",
")",
":",
"identifier",
"=",
"binascii",
".",
"b2a_hex",
"(",
"os",
".",
"urandom",
"(",
"8",
")",
")",
".",
"decode",
"(",
")",
".",
"upper",
"(",
")",
"seed",
"=",
"binascii",
".",
"b2a_hex",
"(",
"os",
".",
"urando... | Generate a new identifier and seed for authentication.
Use the returned values in the following way:
* The identifier shall be passed as username to SRPAuthHandler.step1
* Seed shall be passed to SRPAuthHandler constructor | [
"Generate",
"a",
"new",
"identifier",
"and",
"seed",
"for",
"authentication",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/srp.py#L48-L57 |
15,353 | postlund/pyatv | pyatv/airplay/srp.py | SRPAuthHandler.initialize | def initialize(self, seed=None):
"""Initialize handler operation.
This method will generate new encryption keys and must be called prior
to doing authentication or verification.
"""
self.seed = seed or os.urandom(32) # Generate new seed if not provided
signing_key = Sig... | python | def initialize(self, seed=None):
"""Initialize handler operation.
This method will generate new encryption keys and must be called prior
to doing authentication or verification.
"""
self.seed = seed or os.urandom(32) # Generate new seed if not provided
signing_key = Sig... | [
"def",
"initialize",
"(",
"self",
",",
"seed",
"=",
"None",
")",
":",
"self",
".",
"seed",
"=",
"seed",
"or",
"os",
".",
"urandom",
"(",
"32",
")",
"# Generate new seed if not provided",
"signing_key",
"=",
"SigningKey",
"(",
"self",
".",
"seed",
")",
"v... | Initialize handler operation.
This method will generate new encryption keys and must be called prior
to doing authentication or verification. | [
"Initialize",
"handler",
"operation",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/srp.py#L86-L100 |
15,354 | postlund/pyatv | pyatv/airplay/srp.py | SRPAuthHandler.verify1 | def verify1(self):
"""First device verification step."""
self._check_initialized()
self._verify_private = curve25519.Private(secret=self.seed)
self._verify_public = self._verify_private.get_public()
log_binary(_LOGGER,
'Verification keys',
Pr... | python | def verify1(self):
"""First device verification step."""
self._check_initialized()
self._verify_private = curve25519.Private(secret=self.seed)
self._verify_public = self._verify_private.get_public()
log_binary(_LOGGER,
'Verification keys',
Pr... | [
"def",
"verify1",
"(",
"self",
")",
":",
"self",
".",
"_check_initialized",
"(",
")",
"self",
".",
"_verify_private",
"=",
"curve25519",
".",
"Private",
"(",
"secret",
"=",
"self",
".",
"seed",
")",
"self",
".",
"_verify_public",
"=",
"self",
".",
"_veri... | First device verification step. | [
"First",
"device",
"verification",
"step",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/srp.py#L102-L112 |
15,355 | postlund/pyatv | pyatv/airplay/srp.py | SRPAuthHandler.verify2 | def verify2(self, atv_public_key, data):
"""Last device verification step."""
self._check_initialized()
log_binary(_LOGGER, 'Verify', PublicSecret=atv_public_key, Data=data)
# Generate a shared secret key
public = curve25519.Public(atv_public_key)
shared = self._verify_p... | python | def verify2(self, atv_public_key, data):
"""Last device verification step."""
self._check_initialized()
log_binary(_LOGGER, 'Verify', PublicSecret=atv_public_key, Data=data)
# Generate a shared secret key
public = curve25519.Public(atv_public_key)
shared = self._verify_p... | [
"def",
"verify2",
"(",
"self",
",",
"atv_public_key",
",",
"data",
")",
":",
"self",
".",
"_check_initialized",
"(",
")",
"log_binary",
"(",
"_LOGGER",
",",
"'Verify'",
",",
"PublicSecret",
"=",
"atv_public_key",
",",
"Data",
"=",
"data",
")",
"# Generate a ... | Last device verification step. | [
"Last",
"device",
"verification",
"step",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/srp.py#L114-L137 |
15,356 | postlund/pyatv | pyatv/airplay/srp.py | SRPAuthHandler.step1 | def step1(self, username, password):
"""First authentication step."""
self._check_initialized()
context = AtvSRPContext(
str(username), str(password),
prime=constants.PRIME_2048,
generator=constants.PRIME_2048_GEN)
self.session = SRPClientSession(
... | python | def step1(self, username, password):
"""First authentication step."""
self._check_initialized()
context = AtvSRPContext(
str(username), str(password),
prime=constants.PRIME_2048,
generator=constants.PRIME_2048_GEN)
self.session = SRPClientSession(
... | [
"def",
"step1",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"self",
".",
"_check_initialized",
"(",
")",
"context",
"=",
"AtvSRPContext",
"(",
"str",
"(",
"username",
")",
",",
"str",
"(",
"password",
")",
",",
"prime",
"=",
"constants",
"... | First authentication step. | [
"First",
"authentication",
"step",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/srp.py#L139-L147 |
15,357 | postlund/pyatv | pyatv/airplay/srp.py | SRPAuthHandler.step2 | def step2(self, pub_key, salt):
"""Second authentication step."""
self._check_initialized()
pk_str = binascii.hexlify(pub_key).decode()
salt = binascii.hexlify(salt).decode()
self.client_session_key, _, _ = self.session.process(pk_str, salt)
_LOGGER.debug('Client session ... | python | def step2(self, pub_key, salt):
"""Second authentication step."""
self._check_initialized()
pk_str = binascii.hexlify(pub_key).decode()
salt = binascii.hexlify(salt).decode()
self.client_session_key, _, _ = self.session.process(pk_str, salt)
_LOGGER.debug('Client session ... | [
"def",
"step2",
"(",
"self",
",",
"pub_key",
",",
"salt",
")",
":",
"self",
".",
"_check_initialized",
"(",
")",
"pk_str",
"=",
"binascii",
".",
"hexlify",
"(",
"pub_key",
")",
".",
"decode",
"(",
")",
"salt",
"=",
"binascii",
".",
"hexlify",
"(",
"s... | Second authentication step. | [
"Second",
"authentication",
"step",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/srp.py#L149-L165 |
15,358 | postlund/pyatv | pyatv/airplay/srp.py | SRPAuthHandler.step3 | def step3(self):
"""Last authentication step."""
self._check_initialized()
# TODO: verify: self.client_session_key same as self.session.key_b64()?
session_key = binascii.unhexlify(self.client_session_key)
aes_key = hash_sha512('Pair-Setup-AES-Key', session_key)[0:16]
tmp... | python | def step3(self):
"""Last authentication step."""
self._check_initialized()
# TODO: verify: self.client_session_key same as self.session.key_b64()?
session_key = binascii.unhexlify(self.client_session_key)
aes_key = hash_sha512('Pair-Setup-AES-Key', session_key)[0:16]
tmp... | [
"def",
"step3",
"(",
"self",
")",
":",
"self",
".",
"_check_initialized",
"(",
")",
"# TODO: verify: self.client_session_key same as self.session.key_b64()?",
"session_key",
"=",
"binascii",
".",
"unhexlify",
"(",
"self",
".",
"client_session_key",
")",
"aes_key",
"=",
... | Last authentication step. | [
"Last",
"authentication",
"step",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/srp.py#L167-L182 |
15,359 | postlund/pyatv | pyatv/airplay/auth.py | DeviceAuthenticator.start_authentication | async def start_authentication(self):
"""Start the authentication process.
This method will show the expected PIN on screen.
"""
_, code = await self.http.post_data(
'pair-pin-start', headers=_AIRPLAY_HEADERS)
if code != 200:
raise DeviceAuthenticationErr... | python | async def start_authentication(self):
"""Start the authentication process.
This method will show the expected PIN on screen.
"""
_, code = await self.http.post_data(
'pair-pin-start', headers=_AIRPLAY_HEADERS)
if code != 200:
raise DeviceAuthenticationErr... | [
"async",
"def",
"start_authentication",
"(",
"self",
")",
":",
"_",
",",
"code",
"=",
"await",
"self",
".",
"http",
".",
"post_data",
"(",
"'pair-pin-start'",
",",
"headers",
"=",
"_AIRPLAY_HEADERS",
")",
"if",
"code",
"!=",
"200",
":",
"raise",
"DeviceAut... | Start the authentication process.
This method will show the expected PIN on screen. | [
"Start",
"the",
"authentication",
"process",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/auth.py#L26-L34 |
15,360 | postlund/pyatv | pyatv/airplay/auth.py | DeviceAuthenticator.finish_authentication | async def finish_authentication(self, username, password):
"""Finish authentication process.
A username (generated by new_credentials) and the PIN code shown on
screen must be provided.
"""
# Step 1
self.srp.step1(username, password)
data = await self._send_plist... | python | async def finish_authentication(self, username, password):
"""Finish authentication process.
A username (generated by new_credentials) and the PIN code shown on
screen must be provided.
"""
# Step 1
self.srp.step1(username, password)
data = await self._send_plist... | [
"async",
"def",
"finish_authentication",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"# Step 1",
"self",
".",
"srp",
".",
"step1",
"(",
"username",
",",
"password",
")",
"data",
"=",
"await",
"self",
".",
"_send_plist",
"(",
"'step1'",
",",
... | Finish authentication process.
A username (generated by new_credentials) and the PIN code shown on
screen must be provided. | [
"Finish",
"authentication",
"process",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/auth.py#L36-L58 |
15,361 | postlund/pyatv | pyatv/airplay/auth.py | AuthenticationVerifier.verify_authed | async def verify_authed(self):
"""Verify if device is allowed to use AirPlau."""
resp = await self._send(self.srp.verify1(), 'verify1')
atv_public_secret = resp[0:32]
data = resp[32:] # TODO: what is this?
await self._send(
self.srp.verify2(atv_public_secret, data),... | python | async def verify_authed(self):
"""Verify if device is allowed to use AirPlau."""
resp = await self._send(self.srp.verify1(), 'verify1')
atv_public_secret = resp[0:32]
data = resp[32:] # TODO: what is this?
await self._send(
self.srp.verify2(atv_public_secret, data),... | [
"async",
"def",
"verify_authed",
"(",
"self",
")",
":",
"resp",
"=",
"await",
"self",
".",
"_send",
"(",
"self",
".",
"srp",
".",
"verify1",
"(",
")",
",",
"'verify1'",
")",
"atv_public_secret",
"=",
"resp",
"[",
"0",
":",
"32",
"]",
"data",
"=",
"... | Verify if device is allowed to use AirPlau. | [
"Verify",
"if",
"device",
"is",
"allowed",
"to",
"use",
"AirPlau",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/auth.py#L86-L94 |
15,362 | postlund/pyatv | pyatv/airplay/api.py | AirPlayAPI.generate_credentials | async def generate_credentials(self):
"""Create new credentials for authentication.
Credentials that have been authenticated shall be saved and loaded with
load_credentials before playing anything. If credentials are lost,
authentication must be performed again.
"""
iden... | python | async def generate_credentials(self):
"""Create new credentials for authentication.
Credentials that have been authenticated shall be saved and loaded with
load_credentials before playing anything. If credentials are lost,
authentication must be performed again.
"""
iden... | [
"async",
"def",
"generate_credentials",
"(",
"self",
")",
":",
"identifier",
",",
"seed",
"=",
"new_credentials",
"(",
")",
"return",
"'{0}:{1}'",
".",
"format",
"(",
"identifier",
",",
"seed",
".",
"decode",
"(",
")",
".",
"upper",
"(",
")",
")"
] | Create new credentials for authentication.
Credentials that have been authenticated shall be saved and loaded with
load_credentials before playing anything. If credentials are lost,
authentication must be performed again. | [
"Create",
"new",
"credentials",
"for",
"authentication",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/api.py#L25-L33 |
15,363 | postlund/pyatv | pyatv/airplay/api.py | AirPlayAPI.load_credentials | async def load_credentials(self, credentials):
"""Load existing credentials."""
split = credentials.split(':')
self.identifier = split[0]
self.srp.initialize(binascii.unhexlify(split[1]))
_LOGGER.debug('Loaded AirPlay credentials: %s', credentials) | python | async def load_credentials(self, credentials):
"""Load existing credentials."""
split = credentials.split(':')
self.identifier = split[0]
self.srp.initialize(binascii.unhexlify(split[1]))
_LOGGER.debug('Loaded AirPlay credentials: %s', credentials) | [
"async",
"def",
"load_credentials",
"(",
"self",
",",
"credentials",
")",
":",
"split",
"=",
"credentials",
".",
"split",
"(",
"':'",
")",
"self",
".",
"identifier",
"=",
"split",
"[",
"0",
"]",
"self",
".",
"srp",
".",
"initialize",
"(",
"binascii",
"... | Load existing credentials. | [
"Load",
"existing",
"credentials",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/airplay/api.py#L35-L40 |
15,364 | postlund/pyatv | pyatv/mrp/connection.py | MrpConnection.enable_encryption | def enable_encryption(self, output_key, input_key):
"""Enable encryption with the specified keys."""
self._chacha = chacha20.Chacha20Cipher(output_key, input_key) | python | def enable_encryption(self, output_key, input_key):
"""Enable encryption with the specified keys."""
self._chacha = chacha20.Chacha20Cipher(output_key, input_key) | [
"def",
"enable_encryption",
"(",
"self",
",",
"output_key",
",",
"input_key",
")",
":",
"self",
".",
"_chacha",
"=",
"chacha20",
".",
"Chacha20Cipher",
"(",
"output_key",
",",
"input_key",
")"
] | Enable encryption with the specified keys. | [
"Enable",
"encryption",
"with",
"the",
"specified",
"keys",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/connection.py#L37-L39 |
15,365 | postlund/pyatv | pyatv/mrp/connection.py | MrpConnection.connect | def connect(self):
"""Connect to device."""
return self.loop.create_connection(lambda: self, self.host, self.port) | python | def connect(self):
"""Connect to device."""
return self.loop.create_connection(lambda: self, self.host, self.port) | [
"def",
"connect",
"(",
"self",
")",
":",
"return",
"self",
".",
"loop",
".",
"create_connection",
"(",
"lambda",
":",
"self",
",",
"self",
".",
"host",
",",
"self",
".",
"port",
")"
] | Connect to device. | [
"Connect",
"to",
"device",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/connection.py#L46-L48 |
15,366 | postlund/pyatv | pyatv/mrp/connection.py | MrpConnection.close | def close(self):
"""Close connection to device."""
if self._transport:
self._transport.close()
self._transport = None
self._chacha = None | python | def close(self):
"""Close connection to device."""
if self._transport:
self._transport.close()
self._transport = None
self._chacha = None | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_transport",
":",
"self",
".",
"_transport",
".",
"close",
"(",
")",
"self",
".",
"_transport",
"=",
"None",
"self",
".",
"_chacha",
"=",
"None"
] | Close connection to device. | [
"Close",
"connection",
"to",
"device",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/connection.py#L50-L55 |
15,367 | postlund/pyatv | pyatv/mrp/connection.py | MrpConnection.send | def send(self, message):
"""Send message to device."""
serialized = message.SerializeToString()
log_binary(_LOGGER, '>> Send', Data=serialized)
if self._chacha:
serialized = self._chacha.encrypt(serialized)
log_binary(_LOGGER, '>> Send', Encrypted=serialized)
... | python | def send(self, message):
"""Send message to device."""
serialized = message.SerializeToString()
log_binary(_LOGGER, '>> Send', Data=serialized)
if self._chacha:
serialized = self._chacha.encrypt(serialized)
log_binary(_LOGGER, '>> Send', Encrypted=serialized)
... | [
"def",
"send",
"(",
"self",
",",
"message",
")",
":",
"serialized",
"=",
"message",
".",
"SerializeToString",
"(",
")",
"log_binary",
"(",
"_LOGGER",
",",
"'>> Send'",
",",
"Data",
"=",
"serialized",
")",
"if",
"self",
".",
"_chacha",
":",
"serialized",
... | Send message to device. | [
"Send",
"message",
"to",
"device",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/connection.py#L57-L68 |
15,368 | postlund/pyatv | pyatv/net.py | HttpSession.get_data | async def get_data(self, path, headers=None, timeout=None):
"""Perform a GET request."""
url = self.base_url + path
_LOGGER.debug('GET URL: %s', url)
resp = None
try:
resp = await self._session.get(
url, headers=headers,
timeout=DEFAULT... | python | async def get_data(self, path, headers=None, timeout=None):
"""Perform a GET request."""
url = self.base_url + path
_LOGGER.debug('GET URL: %s', url)
resp = None
try:
resp = await self._session.get(
url, headers=headers,
timeout=DEFAULT... | [
"async",
"def",
"get_data",
"(",
"self",
",",
"path",
",",
"headers",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"path",
"_LOGGER",
".",
"debug",
"(",
"'GET URL: %s'",
",",
"url",
")",
"resp",
"=",
... | Perform a GET request. | [
"Perform",
"a",
"GET",
"request",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/net.py#L20-L40 |
15,369 | postlund/pyatv | pyatv/net.py | HttpSession.post_data | async def post_data(self, path, data=None, headers=None, timeout=None):
"""Perform a POST request."""
url = self.base_url + path
_LOGGER.debug('POST URL: %s', url)
self._log_data(data, False)
resp = None
try:
resp = await self._session.post(
u... | python | async def post_data(self, path, data=None, headers=None, timeout=None):
"""Perform a POST request."""
url = self.base_url + path
_LOGGER.debug('POST URL: %s', url)
self._log_data(data, False)
resp = None
try:
resp = await self._session.post(
u... | [
"async",
"def",
"post_data",
"(",
"self",
",",
"path",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"path",
"_LOGGER",
".",
"debug",
"(",
"'POST URL: %s'",
","... | Perform a POST request. | [
"Perform",
"a",
"POST",
"request",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/net.py#L42-L65 |
15,370 | postlund/pyatv | pyatv/dmap/tags.py | read_uint | def read_uint(data, start, length):
"""Extract a uint from a position in a sequence."""
return int.from_bytes(data[start:start+length], byteorder='big') | python | def read_uint(data, start, length):
"""Extract a uint from a position in a sequence."""
return int.from_bytes(data[start:start+length], byteorder='big') | [
"def",
"read_uint",
"(",
"data",
",",
"start",
",",
"length",
")",
":",
"return",
"int",
".",
"from_bytes",
"(",
"data",
"[",
"start",
":",
"start",
"+",
"length",
"]",
",",
"byteorder",
"=",
"'big'",
")"
] | Extract a uint from a position in a sequence. | [
"Extract",
"a",
"uint",
"from",
"a",
"position",
"in",
"a",
"sequence",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/tags.py#L11-L13 |
15,371 | postlund/pyatv | pyatv/dmap/tags.py | read_bplist | def read_bplist(data, start, length):
"""Extract a binary plist from a position in a sequence."""
# TODO: pylint doesn't find FMT_BINARY, why?
# pylint: disable=no-member
return plistlib.loads(data[start:start+length],
fmt=plistlib.FMT_BINARY) | python | def read_bplist(data, start, length):
"""Extract a binary plist from a position in a sequence."""
# TODO: pylint doesn't find FMT_BINARY, why?
# pylint: disable=no-member
return plistlib.loads(data[start:start+length],
fmt=plistlib.FMT_BINARY) | [
"def",
"read_bplist",
"(",
"data",
",",
"start",
",",
"length",
")",
":",
"# TODO: pylint doesn't find FMT_BINARY, why?",
"# pylint: disable=no-member",
"return",
"plistlib",
".",
"loads",
"(",
"data",
"[",
"start",
":",
"start",
"+",
"length",
"]",
",",
"fmt",
... | Extract a binary plist from a position in a sequence. | [
"Extract",
"a",
"binary",
"plist",
"from",
"a",
"position",
"in",
"a",
"sequence",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/tags.py#L21-L26 |
15,372 | postlund/pyatv | pyatv/dmap/tags.py | raw_tag | def raw_tag(name, value):
"""Create a DMAP tag with raw data."""
return name.encode('utf-8') + \
len(value).to_bytes(4, byteorder='big') + \
value | python | def raw_tag(name, value):
"""Create a DMAP tag with raw data."""
return name.encode('utf-8') + \
len(value).to_bytes(4, byteorder='big') + \
value | [
"def",
"raw_tag",
"(",
"name",
",",
"value",
")",
":",
"return",
"name",
".",
"encode",
"(",
"'utf-8'",
")",
"+",
"len",
"(",
"value",
")",
".",
"to_bytes",
"(",
"4",
",",
"byteorder",
"=",
"'big'",
")",
"+",
"value"
] | Create a DMAP tag with raw data. | [
"Create",
"a",
"DMAP",
"tag",
"with",
"raw",
"data",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/tags.py#L69-L73 |
15,373 | postlund/pyatv | pyatv/dmap/tags.py | string_tag | def string_tag(name, value):
"""Create a DMAP tag with string data."""
return name.encode('utf-8') + \
len(value).to_bytes(4, byteorder='big') + \
value.encode('utf-8') | python | def string_tag(name, value):
"""Create a DMAP tag with string data."""
return name.encode('utf-8') + \
len(value).to_bytes(4, byteorder='big') + \
value.encode('utf-8') | [
"def",
"string_tag",
"(",
"name",
",",
"value",
")",
":",
"return",
"name",
".",
"encode",
"(",
"'utf-8'",
")",
"+",
"len",
"(",
"value",
")",
".",
"to_bytes",
"(",
"4",
",",
"byteorder",
"=",
"'big'",
")",
"+",
"value",
".",
"encode",
"(",
"'utf-8... | Create a DMAP tag with string data. | [
"Create",
"a",
"DMAP",
"tag",
"with",
"string",
"data",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/tags.py#L76-L80 |
15,374 | postlund/pyatv | pyatv/mrp/messages.py | create | def create(message_type, priority=0):
"""Create a ProtocolMessage."""
message = protobuf.ProtocolMessage()
message.type = message_type
message.priority = priority
return message | python | def create(message_type, priority=0):
"""Create a ProtocolMessage."""
message = protobuf.ProtocolMessage()
message.type = message_type
message.priority = priority
return message | [
"def",
"create",
"(",
"message_type",
",",
"priority",
"=",
"0",
")",
":",
"message",
"=",
"protobuf",
".",
"ProtocolMessage",
"(",
")",
"message",
".",
"type",
"=",
"message_type",
"message",
".",
"priority",
"=",
"priority",
"return",
"message"
] | Create a ProtocolMessage. | [
"Create",
"a",
"ProtocolMessage",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L9-L14 |
15,375 | postlund/pyatv | pyatv/mrp/messages.py | device_information | def device_information(name, identifier):
"""Create a new DEVICE_INFO_MESSAGE."""
# pylint: disable=no-member
message = create(protobuf.DEVICE_INFO_MESSAGE)
info = message.inner()
info.uniqueIdentifier = identifier
info.name = name
info.localizedModelName = 'iPhone'
info.systemBuildVersi... | python | def device_information(name, identifier):
"""Create a new DEVICE_INFO_MESSAGE."""
# pylint: disable=no-member
message = create(protobuf.DEVICE_INFO_MESSAGE)
info = message.inner()
info.uniqueIdentifier = identifier
info.name = name
info.localizedModelName = 'iPhone'
info.systemBuildVersi... | [
"def",
"device_information",
"(",
"name",
",",
"identifier",
")",
":",
"# pylint: disable=no-member",
"message",
"=",
"create",
"(",
"protobuf",
".",
"DEVICE_INFO_MESSAGE",
")",
"info",
"=",
"message",
".",
"inner",
"(",
")",
"info",
".",
"uniqueIdentifier",
"="... | Create a new DEVICE_INFO_MESSAGE. | [
"Create",
"a",
"new",
"DEVICE_INFO_MESSAGE",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L18-L32 |
15,376 | postlund/pyatv | pyatv/mrp/messages.py | set_connection_state | def set_connection_state():
"""Create a new SET_CONNECTION_STATE."""
message = create(protobuf.ProtocolMessage.SET_CONNECTION_STATE_MESSAGE)
message.inner().state = protobuf.SetConnectionStateMessage.Connected
return message | python | def set_connection_state():
"""Create a new SET_CONNECTION_STATE."""
message = create(protobuf.ProtocolMessage.SET_CONNECTION_STATE_MESSAGE)
message.inner().state = protobuf.SetConnectionStateMessage.Connected
return message | [
"def",
"set_connection_state",
"(",
")",
":",
"message",
"=",
"create",
"(",
"protobuf",
".",
"ProtocolMessage",
".",
"SET_CONNECTION_STATE_MESSAGE",
")",
"message",
".",
"inner",
"(",
")",
".",
"state",
"=",
"protobuf",
".",
"SetConnectionStateMessage",
".",
"C... | Create a new SET_CONNECTION_STATE. | [
"Create",
"a",
"new",
"SET_CONNECTION_STATE",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L40-L44 |
15,377 | postlund/pyatv | pyatv/mrp/messages.py | crypto_pairing | def crypto_pairing(pairing_data):
"""Create a new CRYPTO_PAIRING_MESSAGE."""
message = create(protobuf.CRYPTO_PAIRING_MESSAGE)
crypto = message.inner()
crypto.status = 0
crypto.pairingData = tlv8.write_tlv(pairing_data)
return message | python | def crypto_pairing(pairing_data):
"""Create a new CRYPTO_PAIRING_MESSAGE."""
message = create(protobuf.CRYPTO_PAIRING_MESSAGE)
crypto = message.inner()
crypto.status = 0
crypto.pairingData = tlv8.write_tlv(pairing_data)
return message | [
"def",
"crypto_pairing",
"(",
"pairing_data",
")",
":",
"message",
"=",
"create",
"(",
"protobuf",
".",
"CRYPTO_PAIRING_MESSAGE",
")",
"crypto",
"=",
"message",
".",
"inner",
"(",
")",
"crypto",
".",
"status",
"=",
"0",
"crypto",
".",
"pairingData",
"=",
"... | Create a new CRYPTO_PAIRING_MESSAGE. | [
"Create",
"a",
"new",
"CRYPTO_PAIRING_MESSAGE",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L47-L53 |
15,378 | postlund/pyatv | pyatv/mrp/messages.py | client_updates_config | def client_updates_config(artwork=True, now_playing=True,
volume=True, keyboard=True):
"""Create a new CLIENT_UPDATES_CONFIG_MESSAGE."""
message = create(protobuf.CLIENT_UPDATES_CONFIG_MESSAGE)
config = message.inner()
config.artworkUpdates = artwork
config.nowPlayingUpdate... | python | def client_updates_config(artwork=True, now_playing=True,
volume=True, keyboard=True):
"""Create a new CLIENT_UPDATES_CONFIG_MESSAGE."""
message = create(protobuf.CLIENT_UPDATES_CONFIG_MESSAGE)
config = message.inner()
config.artworkUpdates = artwork
config.nowPlayingUpdate... | [
"def",
"client_updates_config",
"(",
"artwork",
"=",
"True",
",",
"now_playing",
"=",
"True",
",",
"volume",
"=",
"True",
",",
"keyboard",
"=",
"True",
")",
":",
"message",
"=",
"create",
"(",
"protobuf",
".",
"CLIENT_UPDATES_CONFIG_MESSAGE",
")",
"config",
... | Create a new CLIENT_UPDATES_CONFIG_MESSAGE. | [
"Create",
"a",
"new",
"CLIENT_UPDATES_CONFIG_MESSAGE",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L56-L65 |
15,379 | postlund/pyatv | pyatv/mrp/messages.py | register_hid_device | def register_hid_device(screen_width, screen_height,
absolute=False, integrated_display=False):
"""Create a new REGISTER_HID_DEVICE_MESSAGE."""
message = create(protobuf.REGISTER_HID_DEVICE_MESSAGE)
descriptor = message.inner().deviceDescriptor
descriptor.absolute = 1 if absolute... | python | def register_hid_device(screen_width, screen_height,
absolute=False, integrated_display=False):
"""Create a new REGISTER_HID_DEVICE_MESSAGE."""
message = create(protobuf.REGISTER_HID_DEVICE_MESSAGE)
descriptor = message.inner().deviceDescriptor
descriptor.absolute = 1 if absolute... | [
"def",
"register_hid_device",
"(",
"screen_width",
",",
"screen_height",
",",
"absolute",
"=",
"False",
",",
"integrated_display",
"=",
"False",
")",
":",
"message",
"=",
"create",
"(",
"protobuf",
".",
"REGISTER_HID_DEVICE_MESSAGE",
")",
"descriptor",
"=",
"messa... | Create a new REGISTER_HID_DEVICE_MESSAGE. | [
"Create",
"a",
"new",
"REGISTER_HID_DEVICE_MESSAGE",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L73-L82 |
15,380 | postlund/pyatv | pyatv/mrp/messages.py | send_packed_virtual_touch_event | def send_packed_virtual_touch_event(xpos, ypos, phase, device_id, finger):
"""Create a new WAKE_DEVICE_MESSAGE."""
message = create(protobuf.SEND_PACKED_VIRTUAL_TOUCH_EVENT_MESSAGE)
event = message.inner()
# The packed version of VirtualTouchEvent contains X, Y, phase, deviceID
# and finger stored ... | python | def send_packed_virtual_touch_event(xpos, ypos, phase, device_id, finger):
"""Create a new WAKE_DEVICE_MESSAGE."""
message = create(protobuf.SEND_PACKED_VIRTUAL_TOUCH_EVENT_MESSAGE)
event = message.inner()
# The packed version of VirtualTouchEvent contains X, Y, phase, deviceID
# and finger stored ... | [
"def",
"send_packed_virtual_touch_event",
"(",
"xpos",
",",
"ypos",
",",
"phase",
",",
"device_id",
",",
"finger",
")",
":",
"message",
"=",
"create",
"(",
"protobuf",
".",
"SEND_PACKED_VIRTUAL_TOUCH_EVENT_MESSAGE",
")",
"event",
"=",
"message",
".",
"inner",
"(... | Create a new WAKE_DEVICE_MESSAGE. | [
"Create",
"a",
"new",
"WAKE_DEVICE_MESSAGE",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L85-L99 |
15,381 | postlund/pyatv | pyatv/mrp/messages.py | send_hid_event | def send_hid_event(use_page, usage, down):
"""Create a new SEND_HID_EVENT_MESSAGE."""
message = create(protobuf.SEND_HID_EVENT_MESSAGE)
event = message.inner()
# TODO: This should be generated somehow. I guess it's mach AbsoluteTime
# which is tricky to generate. The device does not seem to care mu... | python | def send_hid_event(use_page, usage, down):
"""Create a new SEND_HID_EVENT_MESSAGE."""
message = create(protobuf.SEND_HID_EVENT_MESSAGE)
event = message.inner()
# TODO: This should be generated somehow. I guess it's mach AbsoluteTime
# which is tricky to generate. The device does not seem to care mu... | [
"def",
"send_hid_event",
"(",
"use_page",
",",
"usage",
",",
"down",
")",
":",
"message",
"=",
"create",
"(",
"protobuf",
".",
"SEND_HID_EVENT_MESSAGE",
")",
"event",
"=",
"message",
".",
"inner",
"(",
")",
"# TODO: This should be generated somehow. I guess it's mac... | Create a new SEND_HID_EVENT_MESSAGE. | [
"Create",
"a",
"new",
"SEND_HID_EVENT_MESSAGE",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L102-L124 |
15,382 | postlund/pyatv | pyatv/mrp/messages.py | command | def command(cmd):
"""Playback command request."""
message = create(protobuf.SEND_COMMAND_MESSAGE)
send_command = message.inner()
send_command.command = cmd
return message | python | def command(cmd):
"""Playback command request."""
message = create(protobuf.SEND_COMMAND_MESSAGE)
send_command = message.inner()
send_command.command = cmd
return message | [
"def",
"command",
"(",
"cmd",
")",
":",
"message",
"=",
"create",
"(",
"protobuf",
".",
"SEND_COMMAND_MESSAGE",
")",
"send_command",
"=",
"message",
".",
"inner",
"(",
")",
"send_command",
".",
"command",
"=",
"cmd",
"return",
"message"
] | Playback command request. | [
"Playback",
"command",
"request",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L127-L132 |
15,383 | postlund/pyatv | pyatv/mrp/messages.py | repeat | def repeat(mode):
"""Change repeat mode of current player."""
message = command(protobuf.CommandInfo_pb2.ChangeShuffleMode)
send_command = message.inner()
send_command.options.externalPlayerCommand = True
send_command.options.repeatMode = mode
return message | python | def repeat(mode):
"""Change repeat mode of current player."""
message = command(protobuf.CommandInfo_pb2.ChangeShuffleMode)
send_command = message.inner()
send_command.options.externalPlayerCommand = True
send_command.options.repeatMode = mode
return message | [
"def",
"repeat",
"(",
"mode",
")",
":",
"message",
"=",
"command",
"(",
"protobuf",
".",
"CommandInfo_pb2",
".",
"ChangeShuffleMode",
")",
"send_command",
"=",
"message",
".",
"inner",
"(",
")",
"send_command",
".",
"options",
".",
"externalPlayerCommand",
"="... | Change repeat mode of current player. | [
"Change",
"repeat",
"mode",
"of",
"current",
"player",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L135-L141 |
15,384 | postlund/pyatv | pyatv/mrp/messages.py | shuffle | def shuffle(enable):
"""Change shuffle mode of current player."""
message = command(protobuf.CommandInfo_pb2.ChangeShuffleMode)
send_command = message.inner()
send_command.options.shuffleMode = 3 if enable else 1
return message | python | def shuffle(enable):
"""Change shuffle mode of current player."""
message = command(protobuf.CommandInfo_pb2.ChangeShuffleMode)
send_command = message.inner()
send_command.options.shuffleMode = 3 if enable else 1
return message | [
"def",
"shuffle",
"(",
"enable",
")",
":",
"message",
"=",
"command",
"(",
"protobuf",
".",
"CommandInfo_pb2",
".",
"ChangeShuffleMode",
")",
"send_command",
"=",
"message",
".",
"inner",
"(",
")",
"send_command",
".",
"options",
".",
"shuffleMode",
"=",
"3"... | Change shuffle mode of current player. | [
"Change",
"shuffle",
"mode",
"of",
"current",
"player",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L144-L149 |
15,385 | postlund/pyatv | pyatv/mrp/messages.py | seek_to_position | def seek_to_position(position):
"""Seek to an absolute position in stream."""
message = command(protobuf.CommandInfo_pb2.SeekToPlaybackPosition)
send_command = message.inner()
send_command.options.playbackPosition = position
return message | python | def seek_to_position(position):
"""Seek to an absolute position in stream."""
message = command(protobuf.CommandInfo_pb2.SeekToPlaybackPosition)
send_command = message.inner()
send_command.options.playbackPosition = position
return message | [
"def",
"seek_to_position",
"(",
"position",
")",
":",
"message",
"=",
"command",
"(",
"protobuf",
".",
"CommandInfo_pb2",
".",
"SeekToPlaybackPosition",
")",
"send_command",
"=",
"message",
".",
"inner",
"(",
")",
"send_command",
".",
"options",
".",
"playbackPo... | Seek to an absolute position in stream. | [
"Seek",
"to",
"an",
"absolute",
"position",
"in",
"stream",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L152-L157 |
15,386 | postlund/pyatv | examples/pairing.py | pair_with_device | async def pair_with_device(loop):
"""Make it possible to pair with device."""
my_zeroconf = Zeroconf()
details = conf.AppleTV('127.0.0.1', 'Apple TV')
details.add_service(conf.DmapService('login_id'))
atv = pyatv.connect_to_apple_tv(details, loop)
atv.pairing.pin(PIN_CODE)
await atv.pairing... | python | async def pair_with_device(loop):
"""Make it possible to pair with device."""
my_zeroconf = Zeroconf()
details = conf.AppleTV('127.0.0.1', 'Apple TV')
details.add_service(conf.DmapService('login_id'))
atv = pyatv.connect_to_apple_tv(details, loop)
atv.pairing.pin(PIN_CODE)
await atv.pairing... | [
"async",
"def",
"pair_with_device",
"(",
"loop",
")",
":",
"my_zeroconf",
"=",
"Zeroconf",
"(",
")",
"details",
"=",
"conf",
".",
"AppleTV",
"(",
"'127.0.0.1'",
",",
"'Apple TV'",
")",
"details",
".",
"add_service",
"(",
"conf",
".",
"DmapService",
"(",
"'... | Make it possible to pair with device. | [
"Make",
"it",
"possible",
"to",
"pair",
"with",
"device",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/examples/pairing.py#L17-L40 |
15,387 | postlund/pyatv | pyatv/mrp/variant.py | read_variant | def read_variant(variant):
"""Read and parse a binary protobuf variant value."""
result = 0
cnt = 0
for data in variant:
result |= (data & 0x7f) << (7 * cnt)
cnt += 1
if not data & 0x80:
return result, variant[cnt:]
raise Exception('invalid variant') | python | def read_variant(variant):
"""Read and parse a binary protobuf variant value."""
result = 0
cnt = 0
for data in variant:
result |= (data & 0x7f) << (7 * cnt)
cnt += 1
if not data & 0x80:
return result, variant[cnt:]
raise Exception('invalid variant') | [
"def",
"read_variant",
"(",
"variant",
")",
":",
"result",
"=",
"0",
"cnt",
"=",
"0",
"for",
"data",
"in",
"variant",
":",
"result",
"|=",
"(",
"data",
"&",
"0x7f",
")",
"<<",
"(",
"7",
"*",
"cnt",
")",
"cnt",
"+=",
"1",
"if",
"not",
"data",
"&... | Read and parse a binary protobuf variant value. | [
"Read",
"and",
"parse",
"a",
"binary",
"protobuf",
"variant",
"value",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/variant.py#L4-L13 |
15,388 | postlund/pyatv | examples/manual_connect.py | print_what_is_playing | async def print_what_is_playing(loop):
"""Connect to device and print what is playing."""
details = conf.AppleTV(ADDRESS, NAME)
details.add_service(conf.DmapService(HSGID))
print('Connecting to {}'.format(details.address))
atv = pyatv.connect_to_apple_tv(details, loop)
try:
print((awai... | python | async def print_what_is_playing(loop):
"""Connect to device and print what is playing."""
details = conf.AppleTV(ADDRESS, NAME)
details.add_service(conf.DmapService(HSGID))
print('Connecting to {}'.format(details.address))
atv = pyatv.connect_to_apple_tv(details, loop)
try:
print((awai... | [
"async",
"def",
"print_what_is_playing",
"(",
"loop",
")",
":",
"details",
"=",
"conf",
".",
"AppleTV",
"(",
"ADDRESS",
",",
"NAME",
")",
"details",
".",
"add_service",
"(",
"conf",
".",
"DmapService",
"(",
"HSGID",
")",
")",
"print",
"(",
"'Connecting to ... | Connect to device and print what is playing. | [
"Connect",
"to",
"device",
"and",
"print",
"what",
"is",
"playing",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/examples/manual_connect.py#L16-L28 |
15,389 | postlund/pyatv | pyatv/mrp/protocol.py | MrpProtocol.add_listener | def add_listener(self, listener, message_type, data=None, one_shot=False):
"""Add a listener that will receice incoming messages."""
lst = self._one_shots if one_shot else self._listeners
if message_type not in lst:
lst[message_type] = []
lst[message_type].append(Listener(l... | python | def add_listener(self, listener, message_type, data=None, one_shot=False):
"""Add a listener that will receice incoming messages."""
lst = self._one_shots if one_shot else self._listeners
if message_type not in lst:
lst[message_type] = []
lst[message_type].append(Listener(l... | [
"def",
"add_listener",
"(",
"self",
",",
"listener",
",",
"message_type",
",",
"data",
"=",
"None",
",",
"one_shot",
"=",
"False",
")",
":",
"lst",
"=",
"self",
".",
"_one_shots",
"if",
"one_shot",
"else",
"self",
".",
"_listeners",
"if",
"message_type",
... | Add a listener that will receice incoming messages. | [
"Add",
"a",
"listener",
"that",
"will",
"receice",
"incoming",
"messages",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/protocol.py#L43-L50 |
15,390 | postlund/pyatv | pyatv/mrp/protocol.py | MrpProtocol.start | async def start(self):
"""Connect to device and listen to incoming messages."""
if self.connection.connected:
return
await self.connection.connect()
# In case credentials have been given externally (i.e. not by pairing
# with a device), then use that client id
... | python | async def start(self):
"""Connect to device and listen to incoming messages."""
if self.connection.connected:
return
await self.connection.connect()
# In case credentials have been given externally (i.e. not by pairing
# with a device), then use that client id
... | [
"async",
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"connection",
".",
"connected",
":",
"return",
"await",
"self",
".",
"connection",
".",
"connect",
"(",
")",
"# In case credentials have been given externally (i.e. not by pairing",
"# with a device), ... | Connect to device and listen to incoming messages. | [
"Connect",
"to",
"device",
"and",
"listen",
"to",
"incoming",
"messages",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/protocol.py#L53-L99 |
15,391 | postlund/pyatv | pyatv/mrp/protocol.py | MrpProtocol.stop | def stop(self):
"""Disconnect from device."""
if self._outstanding:
_LOGGER.warning('There were %d outstanding requests',
len(self._outstanding))
self._initial_message_sent = False
self._outstanding = {}
self._one_shots = {}
self.c... | python | def stop(self):
"""Disconnect from device."""
if self._outstanding:
_LOGGER.warning('There were %d outstanding requests',
len(self._outstanding))
self._initial_message_sent = False
self._outstanding = {}
self._one_shots = {}
self.c... | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"_outstanding",
":",
"_LOGGER",
".",
"warning",
"(",
"'There were %d outstanding requests'",
",",
"len",
"(",
"self",
".",
"_outstanding",
")",
")",
"self",
".",
"_initial_message_sent",
"=",
"False",
... | Disconnect from device. | [
"Disconnect",
"from",
"device",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/protocol.py#L101-L110 |
15,392 | postlund/pyatv | pyatv/mrp/protocol.py | MrpProtocol.send_and_receive | async def send_and_receive(self, message,
generate_identifier=True, timeout=5):
"""Send a message and wait for a response."""
await self._connect_and_encrypt()
# Some messages will respond with the same identifier as used in the
# corresponding request. Ot... | python | async def send_and_receive(self, message,
generate_identifier=True, timeout=5):
"""Send a message and wait for a response."""
await self._connect_and_encrypt()
# Some messages will respond with the same identifier as used in the
# corresponding request. Ot... | [
"async",
"def",
"send_and_receive",
"(",
"self",
",",
"message",
",",
"generate_identifier",
"=",
"True",
",",
"timeout",
"=",
"5",
")",
":",
"await",
"self",
".",
"_connect_and_encrypt",
"(",
")",
"# Some messages will respond with the same identifier as used in the",
... | Send a message and wait for a response. | [
"Send",
"a",
"message",
"and",
"wait",
"for",
"a",
"response",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/protocol.py#L134-L153 |
15,393 | postlund/pyatv | pyatv/dmap/__init__.py | BaseDmapAppleTV.playstatus | async def playstatus(self, use_revision=False, timeout=None):
"""Request raw data about what is currently playing.
If use_revision=True, this command will "block" until playstatus
changes on the device.
Must be logged in.
"""
cmd_url = _PSU_CMD.format(
self.... | python | async def playstatus(self, use_revision=False, timeout=None):
"""Request raw data about what is currently playing.
If use_revision=True, this command will "block" until playstatus
changes on the device.
Must be logged in.
"""
cmd_url = _PSU_CMD.format(
self.... | [
"async",
"def",
"playstatus",
"(",
"self",
",",
"use_revision",
"=",
"False",
",",
"timeout",
"=",
"None",
")",
":",
"cmd_url",
"=",
"_PSU_CMD",
".",
"format",
"(",
"self",
".",
"playstatus_revision",
"if",
"use_revision",
"else",
"0",
")",
"resp",
"=",
... | Request raw data about what is currently playing.
If use_revision=True, this command will "block" until playstatus
changes on the device.
Must be logged in. | [
"Request",
"raw",
"data",
"about",
"what",
"is",
"currently",
"playing",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/__init__.py#L31-L43 |
15,394 | postlund/pyatv | pyatv/dmap/__init__.py | BaseDmapAppleTV.ctrl_int_cmd | def ctrl_int_cmd(self, cmd):
"""Perform a "ctrl-int" command."""
cmd_url = 'ctrl-int/1/{}?[AUTH]&prompt-id=0'.format(cmd)
return self.daap.post(cmd_url) | python | def ctrl_int_cmd(self, cmd):
"""Perform a "ctrl-int" command."""
cmd_url = 'ctrl-int/1/{}?[AUTH]&prompt-id=0'.format(cmd)
return self.daap.post(cmd_url) | [
"def",
"ctrl_int_cmd",
"(",
"self",
",",
"cmd",
")",
":",
"cmd_url",
"=",
"'ctrl-int/1/{}?[AUTH]&prompt-id=0'",
".",
"format",
"(",
"cmd",
")",
"return",
"self",
".",
"daap",
".",
"post",
"(",
"cmd_url",
")"
] | Perform a "ctrl-int" command. | [
"Perform",
"a",
"ctrl",
"-",
"int",
"command",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/__init__.py#L65-L68 |
15,395 | postlund/pyatv | pyatv/dmap/__init__.py | BaseDmapAppleTV.controlprompt_cmd | def controlprompt_cmd(self, cmd):
"""Perform a "controlpromptentry" command."""
data = tags.string_tag('cmbe', cmd) + tags.uint8_tag('cmcc', 0)
return self.daap.post(_CTRL_PROMPT_CMD, data=data) | python | def controlprompt_cmd(self, cmd):
"""Perform a "controlpromptentry" command."""
data = tags.string_tag('cmbe', cmd) + tags.uint8_tag('cmcc', 0)
return self.daap.post(_CTRL_PROMPT_CMD, data=data) | [
"def",
"controlprompt_cmd",
"(",
"self",
",",
"cmd",
")",
":",
"data",
"=",
"tags",
".",
"string_tag",
"(",
"'cmbe'",
",",
"cmd",
")",
"+",
"tags",
".",
"uint8_tag",
"(",
"'cmcc'",
",",
"0",
")",
"return",
"self",
".",
"daap",
".",
"post",
"(",
"_C... | Perform a "controlpromptentry" command. | [
"Perform",
"a",
"controlpromptentry",
"command",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/__init__.py#L70-L73 |
15,396 | postlund/pyatv | pyatv/dmap/__init__.py | DmapRemoteControl.up | async def up(self):
"""Press key up."""
await self._send_commands(
self._move('Down', 0, 20, 275),
self._move('Move', 1, 20, 270),
self._move('Move', 2, 20, 265),
self._move('Move', 3, 20, 260),
self._move('Move', 4, 20, 255),
self.... | python | async def up(self):
"""Press key up."""
await self._send_commands(
self._move('Down', 0, 20, 275),
self._move('Move', 1, 20, 270),
self._move('Move', 2, 20, 265),
self._move('Move', 3, 20, 260),
self._move('Move', 4, 20, 255),
self.... | [
"async",
"def",
"up",
"(",
"self",
")",
":",
"await",
"self",
".",
"_send_commands",
"(",
"self",
".",
"_move",
"(",
"'Down'",
",",
"0",
",",
"20",
",",
"275",
")",
",",
"self",
".",
"_move",
"(",
"'Move'",
",",
"1",
",",
"20",
",",
"270",
")",... | Press key up. | [
"Press",
"key",
"up",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/__init__.py#L94-L103 |
15,397 | postlund/pyatv | pyatv/dmap/__init__.py | DmapRemoteControl.down | async def down(self):
"""Press key down."""
await self._send_commands(
self._move('Down', 0, 20, 250),
self._move('Move', 1, 20, 255),
self._move('Move', 2, 20, 260),
self._move('Move', 3, 20, 265),
self._move('Move', 4, 20, 270),
s... | python | async def down(self):
"""Press key down."""
await self._send_commands(
self._move('Down', 0, 20, 250),
self._move('Move', 1, 20, 255),
self._move('Move', 2, 20, 260),
self._move('Move', 3, 20, 265),
self._move('Move', 4, 20, 270),
s... | [
"async",
"def",
"down",
"(",
"self",
")",
":",
"await",
"self",
".",
"_send_commands",
"(",
"self",
".",
"_move",
"(",
"'Down'",
",",
"0",
",",
"20",
",",
"250",
")",
",",
"self",
".",
"_move",
"(",
"'Move'",
",",
"1",
",",
"20",
",",
"255",
")... | Press key down. | [
"Press",
"key",
"down",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/__init__.py#L105-L114 |
15,398 | postlund/pyatv | pyatv/dmap/__init__.py | DmapRemoteControl.left | async def left(self):
"""Press key left."""
await self._send_commands(
self._move('Down', 0, 75, 100),
self._move('Move', 1, 70, 100),
self._move('Move', 3, 65, 100),
self._move('Move', 4, 60, 100),
self._move('Move', 5, 55, 100),
s... | python | async def left(self):
"""Press key left."""
await self._send_commands(
self._move('Down', 0, 75, 100),
self._move('Move', 1, 70, 100),
self._move('Move', 3, 65, 100),
self._move('Move', 4, 60, 100),
self._move('Move', 5, 55, 100),
s... | [
"async",
"def",
"left",
"(",
"self",
")",
":",
"await",
"self",
".",
"_send_commands",
"(",
"self",
".",
"_move",
"(",
"'Down'",
",",
"0",
",",
"75",
",",
"100",
")",
",",
"self",
".",
"_move",
"(",
"'Move'",
",",
"1",
",",
"70",
",",
"100",
")... | Press key left. | [
"Press",
"key",
"left",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/__init__.py#L116-L125 |
15,399 | postlund/pyatv | pyatv/dmap/__init__.py | DmapRemoteControl.right | async def right(self):
"""Press key right."""
await self._send_commands(
self._move('Down', 0, 50, 100),
self._move('Move', 1, 55, 100),
self._move('Move', 3, 60, 100),
self._move('Move', 4, 65, 100),
self._move('Move', 5, 70, 100),
... | python | async def right(self):
"""Press key right."""
await self._send_commands(
self._move('Down', 0, 50, 100),
self._move('Move', 1, 55, 100),
self._move('Move', 3, 60, 100),
self._move('Move', 4, 65, 100),
self._move('Move', 5, 70, 100),
... | [
"async",
"def",
"right",
"(",
"self",
")",
":",
"await",
"self",
".",
"_send_commands",
"(",
"self",
".",
"_move",
"(",
"'Down'",
",",
"0",
",",
"50",
",",
"100",
")",
",",
"self",
".",
"_move",
"(",
"'Move'",
",",
"1",
",",
"55",
",",
"100",
"... | Press key right. | [
"Press",
"key",
"right",
"."
] | 655dfcda4e2f9d1c501540e18da4f480d8bf0e70 | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/dmap/__init__.py#L127-L136 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.