mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 05:13:16 -07:00
Refactor notification utils to utils.notifications
This commit is contained in:
parent
f042e014b1
commit
9d43e0d60b
2 changed files with 31 additions and 24 deletions
30
core/utils/notifications.py
Normal file
30
core/utils/notifications.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
import requests
|
||||
|
||||
import core
|
||||
from core import logger
|
||||
|
||||
|
||||
def plex_update(category):
|
||||
if core.FAILED:
|
||||
return
|
||||
url = '{scheme}://{host}:{port}/library/sections/'.format(
|
||||
scheme='https' if core.PLEXSSL else 'http',
|
||||
host=core.PLEXHOST,
|
||||
port=core.PLEXPORT,
|
||||
)
|
||||
section = None
|
||||
if not core.PLEXSEC:
|
||||
return
|
||||
logger.debug('Attempting to update Plex Library for category {0}.'.format(category), 'PLEX')
|
||||
for item in core.PLEXSEC:
|
||||
if item[0] == category:
|
||||
section = item[1]
|
||||
|
||||
if section:
|
||||
url = '{url}{section}/refresh?X-Plex-Token={token}'.format(url=url, section=section, token=core.PLEXTOKEN)
|
||||
requests.get(url, timeout=(60, 120), verify=False)
|
||||
logger.debug('Plex Library has been refreshed.', 'PLEX')
|
||||
else:
|
||||
logger.debug('Could not identify section for plex update', 'PLEX')
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue