mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
add plex library update. Fixes #566
This commit is contained in:
parent
3600c224d3
commit
042fcce6b7
5 changed files with 51 additions and 3 deletions
|
@ -8,7 +8,7 @@ import core
|
||||||
|
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
from core import logger, nzbToMediaDB
|
from core import logger, nzbToMediaDB
|
||||||
from core.nzbToMediaUtil import convert_to_ascii, CharReplace
|
from core.nzbToMediaUtil import convert_to_ascii, CharReplace, plex_update
|
||||||
from core.nzbToMediaUserScript import external_script
|
from core.nzbToMediaUserScript import external_script
|
||||||
|
|
||||||
def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, clientAgent):
|
def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, clientAgent):
|
||||||
|
@ -217,6 +217,8 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
elif sectionName == 'Gamez':
|
elif sectionName == 'Gamez':
|
||||||
result = core.autoProcessGames().process(sectionName,outputDestination, inputName, status, clientAgent, inputCategory)
|
result = core.autoProcessGames().process(sectionName,outputDestination, inputName, status, clientAgent, inputCategory)
|
||||||
|
|
||||||
|
plex_update(inputCategory)
|
||||||
|
|
||||||
if result[0] != 0:
|
if result[0] != 0:
|
||||||
if clientAgent != 'manual':
|
if clientAgent != 'manual':
|
||||||
logger.error(
|
logger.error(
|
||||||
|
|
|
@ -246,6 +246,15 @@
|
||||||
audioExtensions = .mp3, .aac, .ogg, .ape, .m4a, .asf, .wma, .flac
|
audioExtensions = .mp3, .aac, .ogg, .ape, .m4a, .asf, .wma, .flac
|
||||||
metaExtensions = .nfo,.sub,.srt,.jpg,.gif
|
metaExtensions = .nfo,.sub,.srt,.jpg,.gif
|
||||||
|
|
||||||
|
[Plex]
|
||||||
|
plex_host = localhost
|
||||||
|
plex_port = 32400
|
||||||
|
plex_token =
|
||||||
|
plex_ssl = 0
|
||||||
|
# Enter Plex category to section mapping as Category,section and separate each pair with '|'
|
||||||
|
# e.g. plex_sections = movie,3|tv,4
|
||||||
|
plex_sections =
|
||||||
|
|
||||||
[Transcoder]
|
[Transcoder]
|
||||||
# getsubs. enable to download subtitles.
|
# getsubs. enable to download subtitles.
|
||||||
getSubs = 0
|
getSubs = 0
|
||||||
|
|
|
@ -116,6 +116,12 @@ DELUGEPORT = None
|
||||||
DELUGEUSR = None
|
DELUGEUSR = None
|
||||||
DELUGEPWD = None
|
DELUGEPWD = None
|
||||||
|
|
||||||
|
PLEXSSL = None
|
||||||
|
PLEXHOST = None
|
||||||
|
PLEXPORT = None
|
||||||
|
PLEXTOKEN = None
|
||||||
|
PLEXSEC = None
|
||||||
|
|
||||||
EXTCONTAINER = []
|
EXTCONTAINER = []
|
||||||
COMPRESSEDCONTAINER = []
|
COMPRESSEDCONTAINER = []
|
||||||
MEDIACONTAINER = []
|
MEDIACONTAINER = []
|
||||||
|
@ -206,7 +212,8 @@ def initialize(section=None):
|
||||||
NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \
|
NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \
|
||||||
DELETE_ORIGINAL, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \
|
DELETE_ORIGINAL, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \
|
||||||
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \
|
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \
|
||||||
TORRENT_DEFAULTDIR, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3
|
TORRENT_DEFAULTDIR, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \
|
||||||
|
PLEXSSL, PLEXHOST, PLEXPORT, PLEXTOKEN, PLEXSEC
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
return False
|
return False
|
||||||
|
@ -351,6 +358,15 @@ def initialize(section=None):
|
||||||
if isinstance(REMOTEPATHS, list): REMOTEPATHS = ','.join(REMOTEPATHS) # fix in case this imported as list.
|
if isinstance(REMOTEPATHS, list): REMOTEPATHS = ','.join(REMOTEPATHS) # fix in case this imported as list.
|
||||||
REMOTEPATHS = [ tuple(item.split(',')) for item in REMOTEPATHS.split('|') ] # /volume1/Public/,E:\|/volume2/share/,\\NAS\
|
REMOTEPATHS = [ tuple(item.split(',')) for item in REMOTEPATHS.split('|') ] # /volume1/Public/,E:\|/volume2/share/,\\NAS\
|
||||||
|
|
||||||
|
PLEXSSL = int(CFG["Plex"]["plex_ssl"])
|
||||||
|
PLEXHOST = CFG["Plex"]["plex_host"]
|
||||||
|
PLEXPORT = CFG["Plex"]["plex_port"]
|
||||||
|
PLEXTOKEN = CFG["Plex"]["plex_token"]
|
||||||
|
PLEXSEC = CFG["Plex"]["plex_sections"] or None
|
||||||
|
if PLEXSEC:
|
||||||
|
if isinstance(PLEXSEC, list): PLEXSEC = ','.join(PLEXSEC) # fix in case this imported as list.
|
||||||
|
PLEXSEC = [ tuple(item.split(',')) for item in PLEXSEC.split('|') ]
|
||||||
|
|
||||||
devnull = open(os.devnull, 'w')
|
devnull = open(os.devnull, 'w')
|
||||||
try:
|
try:
|
||||||
subprocess.Popen(["nice"], stdout=devnull, stderr=devnull).communicate()
|
subprocess.Popen(["nice"], stdout=devnull, stderr=devnull).communicate()
|
||||||
|
|
|
@ -1053,6 +1053,25 @@ def server_responding(baseURL):
|
||||||
except (requests.ConnectionError, requests.exceptions.Timeout):
|
except (requests.ConnectionError, requests.exceptions.Timeout):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def plex_update(category):
|
||||||
|
logger.debug("Attempting to update Plex Library for category %s." %(category), 'PLEX')
|
||||||
|
if core.PLEXSSL:
|
||||||
|
ulr = 'https://'
|
||||||
|
else:
|
||||||
|
url = 'http://'
|
||||||
|
url = url + core.PLEXHOST + ':' + core.PLEXPORT + '/library/sections/'
|
||||||
|
section = None
|
||||||
|
for item in core.PLEXSEC:
|
||||||
|
if item[0] == category:
|
||||||
|
section = item[1]
|
||||||
|
|
||||||
|
if section:
|
||||||
|
url = url + section + '/refresh?X-Plex-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')
|
||||||
|
|
||||||
def backupVersionedFile(old_file, version):
|
def backupVersionedFile(old_file, version):
|
||||||
numTries = 0
|
numTries = 0
|
||||||
|
|
||||||
|
|
|
@ -506,7 +506,7 @@ from core.autoProcess.autoProcessGames import autoProcessGames
|
||||||
from core.autoProcess.autoProcessMovie import autoProcessMovie
|
from core.autoProcess.autoProcessMovie import autoProcessMovie
|
||||||
from core.autoProcess.autoProcessMusic import autoProcessMusic
|
from core.autoProcess.autoProcessMusic import autoProcessMusic
|
||||||
from core.autoProcess.autoProcessTV import autoProcessTV
|
from core.autoProcess.autoProcessTV import autoProcessTV
|
||||||
from core.nzbToMediaUtil import getDirs, extractFiles, cleanDir, update_downloadInfoStatus, get_downloadInfo, CharReplace, convert_to_ascii, get_nzoid
|
from core.nzbToMediaUtil import getDirs, extractFiles, cleanDir, update_downloadInfoStatus, get_downloadInfo, CharReplace, convert_to_ascii, get_nzoid, plex_update
|
||||||
from core.nzbToMediaUserScript import external_script
|
from core.nzbToMediaUserScript import external_script
|
||||||
from core import logger, nzbToMediaDB
|
from core import logger, nzbToMediaDB
|
||||||
|
|
||||||
|
@ -608,6 +608,8 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
|
||||||
else:
|
else:
|
||||||
result = [-1, ""]
|
result = [-1, ""]
|
||||||
|
|
||||||
|
plex_update(inputCategory)
|
||||||
|
|
||||||
if result[0] == 0:
|
if result[0] == 0:
|
||||||
if clientAgent != 'manual':
|
if clientAgent != 'manual':
|
||||||
# update download status in our DB
|
# update download status in our DB
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue