Use the same session for all requests

Use the Session created at the start of the script for all requests, 
instead of creating a new one for some of them (which doesn't inherit 
the settings set on it at the start).
This commit is contained in:
Landon Abney 2018-06-16 22:24:48 -07:00
parent 7b0cc2d2a9
commit 342284173b
No known key found for this signature in database
GPG Key ID: 15320D3C4A506996

View File

@ -86,7 +86,7 @@ def send_notification(subject_text, body_text, notifier_id):
'body': body_text}
try:
r = requests.post(TAUTULLI_URL.rstrip('/') + '/api/v2', params=payload)
r = sess.post(TAUTULLI_URL.rstrip('/') + '/api/v2', params=payload)
response = r.json()
if response['response']['result'] == 'success':
@ -111,8 +111,7 @@ def get_activity():
'cmd': 'get_activity'}
try:
req = requests.get(TAUTULLI_URL.rstrip('/') + '/api/v2',
params=payload)
req = sess.get(TAUTULLI_URL.rstrip('/') + '/api/v2', params=payload)
response = req.json()
res_data = response['response']['data']['sessions']