mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 13:23:18 -07:00
This commit is contained in:
parent
2d57f9c581
commit
08968619ab
12 changed files with 62 additions and 33 deletions
|
@ -67,7 +67,7 @@ def processEpisode(dirName, nzbName=None, status=0, inputCategory=None):
|
||||||
watch_dir = ""
|
watch_dir = ""
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
nzbName, dirName = converto_to_ascii(nzbName, dirName)
|
nzbName, dirName = convert_to_ascii(nzbName, dirName)
|
||||||
|
|
||||||
if dirName == "Manual Run" and watch_dir != "":
|
if dirName == "Manual Run" and watch_dir != "":
|
||||||
dirName = watch_dir
|
dirName = watch_dir
|
||||||
|
|
|
@ -51,7 +51,7 @@ def process(dirName, nzbName=None, status=0, inputCategory=None):
|
||||||
else:
|
else:
|
||||||
protocol = "http://"
|
protocol = "http://"
|
||||||
|
|
||||||
nzbName, dirName = converto_to_ascii(nzbName, dirName)
|
nzbName, dirName = convert_to_ascii(nzbName, dirName)
|
||||||
|
|
||||||
baseURL = protocol + host + ":" + port + web_root + "/api?api_key=" + apikey + "&mode="
|
baseURL = protocol + host + ":" + port + web_root + "/api?api_key=" + apikey + "&mode="
|
||||||
|
|
||||||
|
|
|
@ -188,22 +188,22 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id
|
||||||
method = config.get(section, "method")
|
method = config.get(section, "method")
|
||||||
delete_failed = int(config.get(section, "delete_failed"))
|
delete_failed = int(config.get(section, "delete_failed"))
|
||||||
wait_for = int(config.get(section, "wait_for"))
|
wait_for = int(config.get(section, "wait_for"))
|
||||||
|
try:
|
||||||
|
TimePerGiB = int(config.get(section, "TimePerGiB"))
|
||||||
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
|
TimePerGiB = 60 # note, if using Network to transfer on 100Mbit LAN, expect ~ 600 MB/minute.
|
||||||
try:
|
try:
|
||||||
ssl = int(config.get(section, "ssl"))
|
ssl = int(config.get(section, "ssl"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = config.get(section, "web_root")
|
web_root = config.get(section, "web_root")
|
||||||
except ConfigParser.NoOptionError:
|
except ConfigParser.NoOptionError:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
transcode = int(config.get("Transcoder", "transcode"))
|
transcode = int(config.get("Transcoder", "transcode"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
transcode = 0
|
transcode = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
remoteCPS = int(config.get(section, "remoteCPS"))
|
remoteCPS = int(config.get(section, "remoteCPS"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
|
@ -226,10 +226,7 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id
|
||||||
movie_id, imdbid, download_id, initial_status, initial_release_status = get_movie_info(baseURL, imdbid, download_id) # get the CPS database movie id for this movie.
|
movie_id, imdbid, download_id, initial_status, initial_release_status = get_movie_info(baseURL, imdbid, download_id) # get the CPS database movie id for this movie.
|
||||||
|
|
||||||
process_all_exceptions(nzbName.lower(), dirName)
|
process_all_exceptions(nzbName.lower(), dirName)
|
||||||
nzbName, dirName = converto_to_ascii(nzbName, dirName)
|
nzbName, dirName = convert_to_ascii(nzbName, dirName)
|
||||||
|
|
||||||
TimeOut2 = int(wait_for) * 60 # If transfering files across directories, it now appears CouchPotato can take a while to confirm this url request... Try using wait_for timing.
|
|
||||||
socket.setdefaulttimeout(int(TimeOut2)) #initialize socket timeout. We may now be able to remove the delays from the wait_for section below?
|
|
||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
if transcode == 1:
|
if transcode == 1:
|
||||||
|
@ -249,6 +246,11 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id
|
||||||
else:
|
else:
|
||||||
command = command + "/?media_folder=" + urllib.quote(dirName) + "&downloader=" + clientAgent + "&download_id=" + download_id
|
command = command + "/?media_folder=" + urllib.quote(dirName) + "&downloader=" + clientAgent + "&download_id=" + download_id
|
||||||
|
|
||||||
|
dirSize = getDirectorySize(dirName) # get total directory size to calculate needed processing time.
|
||||||
|
TimeOut2 = int(TimePerGiB) * dirSize # Couchpotato needs to complete all moving and renaming before returning the status.
|
||||||
|
TimeOut2 += 60 # Add an extra minute for over-head/processing/metadata.
|
||||||
|
socket.setdefaulttimeout(int(TimeOut2)) #initialize socket timeout. We may now be able to remove the delays from the wait_for section below? If true, this should exit on first loop.
|
||||||
|
|
||||||
url = baseURL + command
|
url = baseURL + command
|
||||||
|
|
||||||
Logger.info("Waiting for %s seconds to allow CPS to process newly extracted files", str(delay))
|
Logger.info("Waiting for %s seconds to allow CPS to process newly extracted files", str(delay))
|
||||||
|
|
|
@ -13,7 +13,6 @@ from nzbToMediaEnv import *
|
||||||
from nzbToMediaUtil import *
|
from nzbToMediaUtil import *
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
Logger = logging.getLogger()
|
||||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
|
||||||
|
|
||||||
def process(dirName, nzbName=None, status=0, inputCategory=None):
|
def process(dirName, nzbName=None, status=0, inputCategory=None):
|
||||||
|
|
||||||
|
@ -36,17 +35,18 @@ def process(dirName, nzbName=None, status=0, inputCategory=None):
|
||||||
port = config.get(section, "port")
|
port = config.get(section, "port")
|
||||||
apikey = config.get(section, "apikey")
|
apikey = config.get(section, "apikey")
|
||||||
delay = float(config.get(section, "delay"))
|
delay = float(config.get(section, "delay"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ssl = int(config.get(section, "ssl"))
|
ssl = int(config.get(section, "ssl"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = config.get(section, "web_root")
|
web_root = config.get(section, "web_root")
|
||||||
except ConfigParser.NoOptionError:
|
except ConfigParser.NoOptionError:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
try:
|
||||||
|
TimePerGiB = int(config.get(section, "TimePerGiB"))
|
||||||
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
|
TimePerGiB = 60 # note, if using Network to transfer on 100Mbit LAN, expect ~ 600 MB/minute.
|
||||||
if ssl:
|
if ssl:
|
||||||
protocol = "https://"
|
protocol = "https://"
|
||||||
else:
|
else:
|
||||||
|
@ -55,7 +55,12 @@ def process(dirName, nzbName=None, status=0, inputCategory=None):
|
||||||
if nzbName == "Manual Run":
|
if nzbName == "Manual Run":
|
||||||
delay = 0
|
delay = 0
|
||||||
|
|
||||||
nzbName, dirName = converto_to_ascii(nzbName, dirName)
|
nzbName, dirName = convert_to_ascii(nzbName, dirName)
|
||||||
|
|
||||||
|
dirSize = getDirectorySize(dirName) # get total directory size to calculate needed processing time.
|
||||||
|
TimeOut = int(TimePerGiB) * dirSize # HeadPhones needs to complete all moving/transcoding and renaming before returning the status.
|
||||||
|
TimeOut += 60 # Add an extra minute for over-head/processing/metadata.
|
||||||
|
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||||
|
|
||||||
baseURL = protocol + host + ":" + port + web_root + "/api?apikey=" + apikey + "&cmd="
|
baseURL = protocol + host + ":" + port + web_root + "/api?apikey=" + apikey + "&cmd="
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC
|
||||||
try:
|
try:
|
||||||
TimePerGiB = int(config.get(section, "TimePerGiB"))
|
TimePerGiB = int(config.get(section, "TimePerGiB"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
TimePerGiB = 1 # note, if using Network to transfer on 100Mbit LAN, expect ~ 600 MB/minute.
|
TimePerGiB = 60 # note, if using Network to transfer on 100Mbit LAN, expect ~ 600 MB/minute.
|
||||||
try:
|
try:
|
||||||
SampleIDs = (config.get("Extensions", "SampleIDs")).split(',')
|
SampleIDs = (config.get("Extensions", "SampleIDs")).split(',')
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
|
@ -119,7 +119,7 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC
|
||||||
|
|
||||||
if nzbName != "Manual Run" and (not fork in SICKBEARD_TORRENT or (clientAgent in ['nzbget','sabnzbd'] and not nzbExtractionBy == "Destination")):
|
if nzbName != "Manual Run" and (not fork in SICKBEARD_TORRENT or (clientAgent in ['nzbget','sabnzbd'] and not nzbExtractionBy == "Destination")):
|
||||||
process_all_exceptions(nzbName.lower(), dirName)
|
process_all_exceptions(nzbName.lower(), dirName)
|
||||||
nzbName, dirName = converto_to_ascii(nzbName, dirName)
|
nzbName, dirName = convert_to_ascii(nzbName, dirName)
|
||||||
|
|
||||||
# Now check if movie files exist in destination. Eventually extraction may be done here if nzbExtractionBy == TorrentToMedia
|
# Now check if movie files exist in destination. Eventually extraction may be done here if nzbExtractionBy == TorrentToMedia
|
||||||
video = int(0)
|
video = int(0)
|
||||||
|
@ -144,7 +144,7 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC
|
||||||
dirName = watch_dir
|
dirName = watch_dir
|
||||||
|
|
||||||
dirSize = getDirectorySize(dirName) # get total directory size to calculate needed processing time.
|
dirSize = getDirectorySize(dirName) # get total directory size to calculate needed processing time.
|
||||||
TimeOut = 60 * int(TimePerGiB) * dirSize # SickBeard needs to complete all moving and renaming before returning the log sequence via url.
|
TimeOut = int(TimePerGiB) * dirSize # SickBeard needs to complete all moving and renaming before returning the log sequence via url.
|
||||||
TimeOut += 60 # Add an extra minute for over-head/processing/metadata.
|
TimeOut += 60 # Add an extra minute for over-head/processing/metadata.
|
||||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||||
|
|
||||||
|
|
|
@ -296,8 +296,8 @@ def addnzbget():
|
||||||
confignew.read(configFilenamenew)
|
confignew.read(configFilenamenew)
|
||||||
|
|
||||||
section = "CouchPotato"
|
section = "CouchPotato"
|
||||||
envKeys = ['CATEGORY', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'METHOD', 'DELETE_FAILED', 'REMOTECPS', 'WAIT_FOR']
|
envKeys = ['CATEGORY', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'METHOD', 'DELETE_FAILED', 'REMOTECPS', 'WAIT_FOR', 'TIMEPERGIB']
|
||||||
cfgKeys = ['cpsCategory', 'apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'method', 'delete_failed', 'remoteCPS', 'wait_for']
|
cfgKeys = ['cpsCategory', 'apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'method', 'delete_failed', 'remoteCPS', 'wait_for', 'TimePerGiB']
|
||||||
for index in range(len(envKeys)):
|
for index in range(len(envKeys)):
|
||||||
key = 'NZBPO_CPS' + envKeys[index]
|
key = 'NZBPO_CPS' + envKeys[index]
|
||||||
if os.environ.has_key(key):
|
if os.environ.has_key(key):
|
||||||
|
@ -317,8 +317,8 @@ def addnzbget():
|
||||||
confignew.set(section, option, value)
|
confignew.set(section, option, value)
|
||||||
|
|
||||||
section = "HeadPhones"
|
section = "HeadPhones"
|
||||||
envKeys = ['CATEGORY', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY']
|
envKeys = ['CATEGORY', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'TIMEPERGIB']
|
||||||
cfgKeys = ['hpCategory', 'apikey', 'host', 'port', 'ssl', 'web_root', 'delay']
|
cfgKeys = ['hpCategory', 'apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'TimePerGiB']
|
||||||
for index in range(len(envKeys)):
|
for index in range(len(envKeys)):
|
||||||
key = 'NZBPO_HP' + envKeys[index]
|
key = 'NZBPO_HP' + envKeys[index]
|
||||||
if os.environ.has_key(key):
|
if os.environ.has_key(key):
|
||||||
|
|
|
@ -354,7 +354,7 @@ def WakeUp():
|
||||||
else:
|
else:
|
||||||
Logger.info("System with mac: %s has been woken. Continuing with the rest of the script.", mac)
|
Logger.info("System with mac: %s has been woken. Continuing with the rest of the script.", mac)
|
||||||
|
|
||||||
def converto_to_ascii(nzbName, dirName):
|
def convert_to_ascii(nzbName, dirName):
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
||||||
if not os.path.isfile(configFilename):
|
if not os.path.isfile(configFilename):
|
||||||
|
|
|
@ -12,9 +12,10 @@ port = 5050
|
||||||
ssl = 0
|
ssl = 0
|
||||||
web_root =
|
web_root =
|
||||||
delay = 65
|
delay = 65
|
||||||
|
TimePerGiB = 60
|
||||||
method = renamer
|
method = renamer
|
||||||
delete_failed = 0
|
delete_failed = 0
|
||||||
wait_for = 5
|
wait_for = 2
|
||||||
#### Set to 1 if CouchPotatoServer is running on a different server to your NZB client
|
#### Set to 1 if CouchPotatoServer is running on a different server to your NZB client
|
||||||
remoteCPS = 0
|
remoteCPS = 0
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ password =
|
||||||
web_root =
|
web_root =
|
||||||
ssl = 0
|
ssl = 0
|
||||||
delay = 0
|
delay = 0
|
||||||
TimePerGiB = 1
|
TimePerGiB = 60
|
||||||
watch_dir =
|
watch_dir =
|
||||||
fork = auto
|
fork = auto
|
||||||
delete_failed = 0
|
delete_failed = 0
|
||||||
|
@ -51,6 +52,7 @@ port = 8181
|
||||||
ssl = 0
|
ssl = 0
|
||||||
web_root =
|
web_root =
|
||||||
delay = 65
|
delay = 65
|
||||||
|
TimePerGiB = 60
|
||||||
|
|
||||||
|
|
||||||
[Mylar]
|
[Mylar]
|
||||||
|
|
|
@ -53,10 +53,15 @@
|
||||||
# set to 1 to delete failed, or 0 to leave files in place.
|
# set to 1 to delete failed, or 0 to leave files in place.
|
||||||
#cpsdelete_failed=0
|
#cpsdelete_failed=0
|
||||||
|
|
||||||
|
# CouchPotato process Time Per GiB
|
||||||
|
#
|
||||||
|
# Set the number of seconds to wait, for each GiB of data, before timing out. If transfering files across drives or network, increase this value as needed.
|
||||||
|
#cpsTimePerGiB=60
|
||||||
|
|
||||||
# CouchPotato wait_for
|
# CouchPotato wait_for
|
||||||
#
|
#
|
||||||
# Set the number of minutes to wait before timing out. If transfering files across drives or network, increase this to longer than the time it takes to copy a movie.
|
# Set the number of minutes to wait after calling the renamer, to check the movie has changed status.
|
||||||
#cpswait_for=5
|
#cpswait_for=2
|
||||||
|
|
||||||
# CouchPotatoServer and NZBGet are a different system (0, 1).
|
# CouchPotatoServer and NZBGet are a different system (0, 1).
|
||||||
#
|
#
|
||||||
|
|
|
@ -43,6 +43,11 @@
|
||||||
# set as required to ensure correct processing.
|
# set as required to ensure correct processing.
|
||||||
#hpdelay=65
|
#hpdelay=65
|
||||||
|
|
||||||
|
# HeadPhones process Time Per GiB
|
||||||
|
#
|
||||||
|
# Set the number of seconds to wait, for each GiB of data, before timing out. If transfering files across drives or network, increase this value as needed.
|
||||||
|
#hpTimePerGiB=60
|
||||||
|
|
||||||
## WakeOnLan
|
## WakeOnLan
|
||||||
|
|
||||||
# use WOL (0, 1).
|
# use WOL (0, 1).
|
||||||
|
|
|
@ -53,10 +53,15 @@
|
||||||
# set to 1 to delete failed, or 0 to leave files in place.
|
# set to 1 to delete failed, or 0 to leave files in place.
|
||||||
#cpsdelete_failed=0
|
#cpsdelete_failed=0
|
||||||
|
|
||||||
|
# CouchPotato process Time Per GiB
|
||||||
|
#
|
||||||
|
# Set the number of seconds to wait, for each GiB of data, before timing out. If transfering files across drives or network, increase this value as needed.
|
||||||
|
#cpsTimePerGiB=60
|
||||||
|
|
||||||
# CouchPotato wait_for
|
# CouchPotato wait_for
|
||||||
#
|
#
|
||||||
# Set the number of minutes to wait before timing out. If transfering files across drives or network, increase this to longer than the time it takes to copy a movie.
|
# Set the number of minutes to wait after calling the renamer, to check the movie has changed status.
|
||||||
#cpswait_for=5
|
#cpswait_for=2
|
||||||
|
|
||||||
# CouchPotatoServer and NZBGet are a different system (0, 1).
|
# CouchPotatoServer and NZBGet are a different system (0, 1).
|
||||||
#
|
#
|
||||||
|
@ -99,8 +104,8 @@
|
||||||
|
|
||||||
# SickBeard process Time Per GiB
|
# SickBeard process Time Per GiB
|
||||||
#
|
#
|
||||||
# Set the number of minutes to wait, for each GiB of data, before timing out. If transfering files across drives or network, increase this value as needed.
|
# Set the number of seconds to wait, for each GiB of data, before timing out. If transfering files across drives or network, increase this value as needed.
|
||||||
#sbTimePerGiB=1
|
#sbTimePerGiB=60
|
||||||
|
|
||||||
# SickBeard watch directory.
|
# SickBeard watch directory.
|
||||||
#
|
#
|
||||||
|
@ -153,6 +158,11 @@
|
||||||
# set as required to ensure correct processing.
|
# set as required to ensure correct processing.
|
||||||
#hpdelay=65
|
#hpdelay=65
|
||||||
|
|
||||||
|
# HeadPhones process Time Per GiB
|
||||||
|
#
|
||||||
|
# Set the number of seconds to wait, for each GiB of data, before timing out. If transfering files across drives or network, increase this value as needed.
|
||||||
|
#hpTimePerGiB=60
|
||||||
|
|
||||||
## Mylar
|
## Mylar
|
||||||
|
|
||||||
# Mylar script category.
|
# Mylar script category.
|
||||||
|
|
|
@ -48,8 +48,8 @@
|
||||||
|
|
||||||
# SickBeard process Time Per GiB
|
# SickBeard process Time Per GiB
|
||||||
#
|
#
|
||||||
# Set the number of minutes to wait, for each GiB of data, before timing out. If transfering files across drives or network, increase this value as needed.
|
# Set the number of seconds to wait, for each GiB of data, before timing out. If transfering files across drives or network, increase this value as needed.
|
||||||
#sbTimePerGiB=1
|
#sbTimePerGiB=60
|
||||||
|
|
||||||
# SickBeard watch directory.
|
# SickBeard watch directory.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue