Skip to content

Commit b3b255e

Browse files
committed
Pass in specific User-Agent #14
1 parent 2d7fd8a commit b3b255e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

skybellpy/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class Skybell():
3434

3535
def __init__(self, username=None, password=None,
3636
auto_login=False, get_devices=False,
37-
cache_path=CONST.CACHE_PATH, disable_cache=False):
37+
cache_path=CONST.CACHE_PATH, disable_cache=False,
38+
agent_identifier=CONST.DEFAULT_AGENT_IDENTIFIER):
3839
"""Init Abode object."""
3940
self._username = username
4041
self._password = password
@@ -43,6 +44,7 @@ def __init__(self, username=None, password=None,
4344
self._disable_cache = disable_cache
4445
self._devices = None
4546
self._session = requests.session()
47+
self._user_agent = '{} ({})'.format(CONST.USER_AGENT, agent_identifier)
4648

4749
# Create a new cache template
4850
self._cache = {
@@ -171,9 +173,9 @@ def send_request(self, method, url, headers=None,
171173
headers['Authorization'] = 'Bearer ' + \
172174
self.cache(CONST.ACCESS_TOKEN)
173175

174-
headers['user-agent'] = (
175-
'SkyBell/3.4.1 (iPhone9,2; iOS 11.0; loc=en_US; lang=en-US) '
176-
'com.skybell.doorbell/1')
176+
_LOGGER.info("User-Agent: %s", self._user_agent)
177+
178+
headers['user-agent'] = self._user_agent
177179
headers['content-type'] = 'application/json'
178180
headers['accepts'] = '*/*'
179181
headers['x-skybell-app-id'] = self.cache(CONST.APP_ID)

skybellpy/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ def call():
158158
# Create skybellpy instance.
159159
skybell = skybellpy.Skybell(username=args.username,
160160
password=args.password,
161-
get_devices=True)
161+
get_devices=True,
162+
agent_identifier='skybellcl')
162163

163164
# # Set setting
164165
# for setting in args.set or []:

skybellpy/helpers/constants.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33

44
MAJOR_VERSION = 0
5-
MINOR_VERSION = 5
5+
MINOR_VERSION = 6
66
PATCH_VERSION = '0'
77

88
__version__ = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
@@ -40,6 +40,12 @@
4040

4141
CACHE_PATH = './skybell.pickle'
4242

43+
USER_AGENT = 'skybellpy/{}.{}.{}'.format(MAJOR_VERSION,
44+
MINOR_VERSION,
45+
PATCH_VERSION)
46+
47+
DEFAULT_AGENT_IDENTIFIER = 'default'
48+
4349
# URLS
4450
BASE_URL = 'https://cloud.myskybell.com/api/v3/'
4551
BASE_URL_V4 = 'https://cloud.myskybell.com/api/v4/'

0 commit comments

Comments
 (0)