mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-10 15:32:35 -07:00
Refactor utils.notifications.plex_update to plugins.plex.plex_update
This commit is contained in:
parent
e12f2724e6
commit
76b5c06a33
3 changed files with 27 additions and 31 deletions
|
@ -1,4 +1,7 @@
|
|||
import requests
|
||||
|
||||
import core
|
||||
from core import logger
|
||||
|
||||
|
||||
def configure_plex(config):
|
||||
|
@ -17,3 +20,27 @@ def configure_plex(config):
|
|||
]
|
||||
|
||||
core.PLEX_SECTION = plex_section
|
||||
|
||||
|
||||
def plex_update(category):
|
||||
if core.FAILED:
|
||||
return
|
||||
url = '{scheme}://{host}:{port}/library/sections/'.format(
|
||||
scheme='https' if core.PLEX_SSL else 'http',
|
||||
host=core.PLEX_HOST,
|
||||
port=core.PLEX_PORT,
|
||||
)
|
||||
section = None
|
||||
if not core.PLEX_SECTION:
|
||||
return
|
||||
logger.debug('Attempting to update Plex Library for category {0}.'.format(category), 'PLEX')
|
||||
for item in core.PLEX_SECTION:
|
||||
if item[0] == category:
|
||||
section = item[1]
|
||||
|
||||
if section:
|
||||
url = '{url}{section}/refresh?X-Plex-Token={token}'.format(url=url, section=section, token=core.PLEX_TOKEN)
|
||||
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