-
-
Save thunsaker/d79218b297e0692066d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from pyquery import PyQuery | |
import settings | |
if __name__ == '__main__': | |
# Log in to Alarm.com page | |
payload = { | |
'JavaScriptTest': '1', | |
'cookieTest': '1', | |
'loginFolder': settings.ALARM_LOGIN_URL, | |
'IsFromNewSite': '1', | |
'txtUserName': settings.ALARM_USERNAME, | |
'txtPassword': settings.ALARM_PASSWORD, | |
'submit': '', | |
} | |
r = requests.post(settings.ALARM_LOGIN_URL, data=payload) | |
d = PyQuery(r.text) | |
if d('img[src*="armed_away_text.png"]').size() == 1: | |
away = True | |
else: | |
away = False | |
# Log in to Dropcam page | |
payload = { | |
'username': settings.DROPCAM_USERNAME, | |
'password': settings.DROPCAM_PASSWORD, | |
'submit': '', | |
} | |
r = requests.post(settings.DROPCAM_LOGIN_URL, data=payload) | |
cookies = r.cookies | |
for uuid in settings.DROPCAM_UUIDS: | |
payload = { | |
'uuid': uuid, | |
'key': 'streaming.enabled', | |
'value': away, | |
} | |
# Post update to Dropcam status | |
r = requests.post(settings.DROPCAM_API_URL, data=payload, cookies=cookies) | |
if r.status_code == 200: | |
print 'Success for UUID %s' % (uuid,) | |
else: | |
print 'Error for UUID %s (%s)' % (uuid, r.status_code,) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cssselect | |
lxml | |
pyquery | |
requests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALARM_LOGIN_URL = 'https://www.myfrontpoint.com/web/Default.aspx' | |
DROPCAM_LOGIN_URL = 'https://www.dropcam.com/login/submit' | |
DROPCAM_API_URL = 'https://www.dropcam.com/api/v1/dropcams.set_property' | |
ALARM_USERNAME = '' | |
ALARM_PASSWORD = '' | |
DROPCAM_USERNAME = '' | |
DROPCAM_PASSWORD = '' | |
DROPCAM_UUIDS = [''] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment