mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-11 15:56:03 -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
|
import core
|
||||||
|
from core import logger
|
||||||
|
|
||||||
|
|
||||||
def configure_plex(config):
|
def configure_plex(config):
|
||||||
|
@ -17,3 +20,27 @@ def configure_plex(config):
|
||||||
]
|
]
|
||||||
|
|
||||||
core.PLEX_SECTION = plex_section
|
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')
|
||||||
|
|
|
@ -19,7 +19,6 @@ from core.utils.identification import category_search, find_imdbid
|
||||||
from core.utils.links import copy_link, replace_links
|
from core.utils.links import copy_link, replace_links
|
||||||
from core.utils.naming import clean_file_name, is_sample, sanitize_name
|
from core.utils.naming import clean_file_name, is_sample, sanitize_name
|
||||||
from core.utils.network import find_download, server_responding, test_connection, wake_on_lan, wake_up
|
from core.utils.network import find_download, server_responding, test_connection, wake_on_lan, wake_up
|
||||||
from core.utils.notifications import plex_update
|
|
||||||
from core.utils.parsers import (
|
from core.utils.parsers import (
|
||||||
parse_args,
|
parse_args,
|
||||||
parse_deluge,
|
parse_deluge,
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
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.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