mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-16 02:02:53 -07:00
Switched our config class to configObj.
nzbToMedia now fully performs manual runs for all autoProcessing scripts. autoProcessing categories are now sub-sections in the autoProcessingMedia.cfg file which allows you to have a unlimited amount of categories for your liking. nzbToMedia supports categories for all autoProcessing scripts now. Minor bug fixes and code cleanup performed during the re-code. Auto-migration code will convert old-style cfg files to new-style cfg format.
This commit is contained in:
parent
027c3e5a43
commit
b7fc74b3fd
22 changed files with 4473 additions and 572 deletions
|
@ -10,6 +10,7 @@ import logging
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
|
from itertools import chain
|
||||||
from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics
|
from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics
|
||||||
from nzbtomedia.autoProcess.autoProcessGames import autoProcessGames
|
from nzbtomedia.autoProcess.autoProcessGames import autoProcessGames
|
||||||
from nzbtomedia.autoProcess.autoProcessMovie import autoProcessMovie
|
from nzbtomedia.autoProcess.autoProcessMovie import autoProcessMovie
|
||||||
|
@ -48,21 +49,9 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
|
|
||||||
Logger.debug("MAIN: Determined Directory: %s | Name: %s | Category: %s", inputDirectory, inputName, inputCategory)
|
Logger.debug("MAIN: Determined Directory: %s | Name: %s | Category: %s", inputDirectory, inputName, inputCategory)
|
||||||
|
|
||||||
# init autoFork
|
if inputCategory in sections["SickBeard"]:
|
||||||
if inputCategory in sbCategory:
|
fork, fork_params = autoFork("SickBeard", inputCategory)
|
||||||
fork, fork_params = autoFork("SickBeard")
|
Torrent_NoLink = int(config()["SickBeard"][inputCategory]["Torrent_NoLink"]) # 0
|
||||||
elif inputCategory in cpsCategory:
|
|
||||||
fork, fork_params = autoFork("CouchPotato")
|
|
||||||
elif inputCategory in hpCategory:
|
|
||||||
fork, fork_params = autoFork("HeadPhones")
|
|
||||||
elif inputCategory in gzCategory:
|
|
||||||
fork, fork_params = autoFork("Gamez")
|
|
||||||
elif inputCategory in mlCategory:
|
|
||||||
fork, fork_params = autoFork("Mylar")
|
|
||||||
else:
|
|
||||||
fork = config.FORKS.items()[config.FORKS.keys().index(config.FORK_DEFAULT)][0]
|
|
||||||
|
|
||||||
if inputCategory in sbCategory:
|
|
||||||
if fork in config.SICKBEARD_TORRENT and Torrent_NoLink != 1:
|
if fork in config.SICKBEARD_TORRENT and Torrent_NoLink != 1:
|
||||||
Logger.info("MAIN: Calling SickBeard's %s branch to post-process: %s",fork ,inputName)
|
Logger.info("MAIN: Calling SickBeard's %s branch to post-process: %s",fork ,inputName)
|
||||||
result = autoProcessTV().processEpisode(inputDirectory, inputName, 0)
|
result = autoProcessTV().processEpisode(inputDirectory, inputName, 0)
|
||||||
|
@ -72,7 +61,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
outputDestination = ""
|
outputDestination = ""
|
||||||
for category in categories:
|
for section, category in sections.items():
|
||||||
if category == inputCategory:
|
if category == inputCategory:
|
||||||
if os.path.basename(inputDirectory) == inputName and os.path.isdir(inputDirectory):
|
if os.path.basename(inputDirectory) == inputName and os.path.isdir(inputDirectory):
|
||||||
Logger.info("MAIN: Download is a directory")
|
Logger.info("MAIN: Download is a directory")
|
||||||
|
@ -95,7 +84,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
outputDestination = os.path.normpath(os.path.join(outputDirectory, inputCategory, os.path.splitext(safeName(inputName))[0]))
|
outputDestination = os.path.normpath(os.path.join(outputDirectory, inputCategory, os.path.splitext(safeName(inputName))[0]))
|
||||||
Logger.info("MAIN: Output directory set to: %s", outputDestination)
|
Logger.info("MAIN: Output directory set to: %s", outputDestination)
|
||||||
|
|
||||||
processOnly = cpsCategory + sbCategory + hpCategory + mlCategory + gzCategory
|
processOnly = list(chain.from_iterable(sections.values()))
|
||||||
if not "NONE" in user_script_categories: # if None, we only process the 5 listed.
|
if not "NONE" in user_script_categories: # if None, we only process the 5 listed.
|
||||||
if "ALL" in user_script_categories: # All defined categories
|
if "ALL" in user_script_categories: # All defined categories
|
||||||
processOnly = categories
|
processOnly = categories
|
||||||
|
@ -142,7 +131,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
|
|
||||||
Logger.debug("MAIN: Scanning files in directory: %s", inputDirectory)
|
Logger.debug("MAIN: Scanning files in directory: %s", inputDirectory)
|
||||||
|
|
||||||
noFlatten.extend(hpCategory) # Make sure we preserve folder structure for HeadPhones.
|
noFlatten.extend(config.get_categories(["HeadPhones"]).values()) # Make sure we preserve folder structure for HeadPhones.
|
||||||
|
|
||||||
outputDestinationMaster = outputDestination # Save the original, so we can change this within the loop below, and reset afterwards.
|
outputDestinationMaster = outputDestination # Save the original, so we can change this within the loop below, and reset afterwards.
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
|
@ -184,7 +173,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
continue # This file has not been recently moved or created, skip it
|
continue # This file has not been recently moved or created, skip it
|
||||||
|
|
||||||
if fileExtension in mediaContainer: # If the file is a video file
|
if fileExtension in mediaContainer: # If the file is a video file
|
||||||
if is_sample(filePath, inputName, minSampleSize, SampleIDs) and not inputCategory in hpCategory: # Ignore samples
|
if is_sample(filePath, inputName, minSampleSize, SampleIDs) and not inputCategory in config.get_categories(["HeadPhones"]).values(): # Ignore samples
|
||||||
Logger.info("MAIN: Ignoring sample file: %s ", filePath)
|
Logger.info("MAIN: Ignoring sample file: %s ", filePath)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
@ -220,7 +209,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
except:
|
except:
|
||||||
Logger.exception("MAIN: Extraction failed for: %s", file)
|
Logger.exception("MAIN: Extraction failed for: %s", file)
|
||||||
continue
|
continue
|
||||||
elif not inputCategory in cpsCategory + sbCategory: #process all for non-video categories.
|
elif not inputCategory in list(chain.from_iterable(config.get_categories(['CouchPotato','SickBeard']).values())): #process all for non-video categories.
|
||||||
Logger.info("MAIN: Found file %s for category %s", filePath, inputCategory)
|
Logger.info("MAIN: Found file %s for category %s", filePath, inputCategory)
|
||||||
copy_link(filePath, targetDirectory, useLink, outputDestination)
|
copy_link(filePath, targetDirectory, useLink, outputDestination)
|
||||||
copy_list.append([filePath, os.path.join(outputDestination, file)])
|
copy_list.append([filePath, os.path.join(outputDestination, file)])
|
||||||
|
@ -234,7 +223,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
flatten(outputDestination)
|
flatten(outputDestination)
|
||||||
|
|
||||||
# Now check if movie files exist in destination:
|
# Now check if movie files exist in destination:
|
||||||
if inputCategory in cpsCategory + sbCategory:
|
if inputCategory in list(chain.from_iterable(config.get_categories(['CouchPotato','SickBeard']).values())):
|
||||||
for dirpath, dirnames, filenames in os.walk(outputDestination):
|
for dirpath, dirnames, filenames in os.walk(outputDestination):
|
||||||
for file in filenames:
|
for file in filenames:
|
||||||
filePath = os.path.join(dirpath, file)
|
filePath = os.path.join(dirpath, file)
|
||||||
|
@ -254,12 +243,12 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
else:
|
else:
|
||||||
Logger.debug("MAIN: Found %s media files in output. %s were found in input", str(video2), str(video))
|
Logger.debug("MAIN: Found %s media files in output. %s were found in input", str(video2), str(video))
|
||||||
|
|
||||||
processCategories = cpsCategory + sbCategory + hpCategory + mlCategory + gzCategory
|
processCategories = list(chain.from_iterable(sections.values()))
|
||||||
|
|
||||||
if (inputCategory in user_script_categories and not "NONE" in user_script_categories) or ("ALL" in user_script_categories and not inputCategory in processCategories):
|
if (inputCategory in user_script_categories and not "NONE" in user_script_categories) or ("ALL" in user_script_categories and not inputCategory in processCategories):
|
||||||
Logger.info("MAIN: Processing user script %s.", user_script)
|
Logger.info("MAIN: Processing user script %s.", user_script)
|
||||||
result = external_script(outputDestination,inputName,inputCategory)
|
result = external_script(outputDestination,inputName,inputCategory)
|
||||||
elif status == int(0) or (inputCategory in hpCategory + mlCategory + gzCategory): # if movies linked/extracted or for other categories.
|
elif status == int(0) or (inputCategory in list(chain.from_iterable(config.get_categories(['HeadPhones','Mylar','Gamez']).values()))): # if movies linked/extracted or for other categories.
|
||||||
Logger.debug("MAIN: Calling autoProcess script for successful download.")
|
Logger.debug("MAIN: Calling autoProcess script for successful download.")
|
||||||
status = int(0) # hp, my, gz don't support failed.
|
status = int(0) # hp, my, gz don't support failed.
|
||||||
else:
|
else:
|
||||||
|
@ -267,20 +256,20 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
result = 0
|
result = 0
|
||||||
if inputCategory in cpsCategory:
|
if inputCategory in sections['CouchPotato'].values():
|
||||||
Logger.info("MAIN: Calling CouchPotatoServer to post-process: %s", inputName)
|
Logger.info("MAIN: Calling CouchPotatoServer to post-process: %s", inputName)
|
||||||
download_id = inputHash
|
download_id = inputHash
|
||||||
result = autoProcessMovie().process(outputDestination, inputName, status, clientAgent, download_id, inputCategory)
|
result = autoProcessMovie().process(outputDestination, inputName, status, clientAgent, download_id, inputCategory)
|
||||||
elif inputCategory in sbCategory:
|
elif inputCategory in sections['SickBeard'].values():
|
||||||
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName)
|
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName)
|
||||||
result = autoProcessTV().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
result = autoProcessTV().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
||||||
elif inputCategory in hpCategory:
|
elif inputCategory in sections['HeadPhones'].values():
|
||||||
Logger.info("MAIN: Calling HeadPhones to post-process: %s", inputName)
|
Logger.info("MAIN: Calling HeadPhones to post-process: %s", inputName)
|
||||||
result = autoProcessMusic().process(inputDirectory, inputName, status, clientAgent, inputCategory)
|
result = autoProcessMusic().process(inputDirectory, inputName, status, clientAgent, inputCategory)
|
||||||
elif inputCategory in mlCategory:
|
elif inputCategory in sections['Mylar'].values():
|
||||||
Logger.info("MAIN: Calling Mylar to post-process: %s", inputName)
|
Logger.info("MAIN: Calling Mylar to post-process: %s", inputName)
|
||||||
result = autoProcessComics().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
result = autoProcessComics().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
||||||
elif inputCategory in gzCategory:
|
elif inputCategory in sections['Gamez'].values():
|
||||||
Logger.info("MAIN: Calling Gamez to post-process: %s", inputName)
|
Logger.info("MAIN: Calling Gamez to post-process: %s", inputName)
|
||||||
result = autoProcessGames().process(outputDestination, inputName, status, clientAgent, inputCategory)
|
result = autoProcessGames().process(outputDestination, inputName, status, clientAgent, inputCategory)
|
||||||
|
|
||||||
|
@ -417,58 +406,49 @@ if __name__ == "__main__":
|
||||||
WakeUp()
|
WakeUp()
|
||||||
|
|
||||||
# EXAMPLE VALUES:
|
# EXAMPLE VALUES:
|
||||||
clientAgent = config().get("Torrent", "clientAgent") # utorrent | deluge | transmission | rtorrent | other
|
clientAgent = config()["Torrent"]["clientAgent"] # utorrent | deluge | transmission | rtorrent | other
|
||||||
useLink_in = config().get("Torrent", "useLink") # no | hard | sym
|
useLink_in = config()["Torrent"]["useLink"] # no | hard | sym
|
||||||
outputDirectory = config().get("Torrent", "outputDirectory") # /abs/path/to/complete/
|
outputDirectory = config()["Torrent"]["outputDirectory"] # /abs/path/to/complete/
|
||||||
categories = (config().get("Torrent", "categories")).split(',') # music,music_videos,pictures,software
|
categories = (config()["Torrent"]["categories"]) # music,music_videos,pictures,software
|
||||||
noFlatten = (config().get("Torrent", "noFlatten")).split(',')
|
noFlatten = (config()["Torrent"]["noFlatten"])
|
||||||
|
|
||||||
uTorrentWEBui = config().get("Torrent", "uTorrentWEBui") # http://localhost:8090/gui/
|
uTorrentWEBui = config()["Torrent"]["uTorrentWEBui"] # http://localhost:8090/gui/
|
||||||
uTorrentUSR = config().get("Torrent", "uTorrentUSR") # mysecretusr
|
uTorrentUSR = config()["Torrent"]["uTorrentUSR"] # mysecretusr
|
||||||
uTorrentPWD = config().get("Torrent", "uTorrentPWD") # mysecretpwr
|
uTorrentPWD = config()["Torrent"]["uTorrentPWD"] # mysecretpwr
|
||||||
|
|
||||||
TransmissionHost = config().get("Torrent", "TransmissionHost") # localhost
|
TransmissionHost = config()["Torrent"]["TransmissionHost"] # localhost
|
||||||
TransmissionPort = config().get("Torrent", "TransmissionPort") # 8084
|
TransmissionPort = config()["Torrent"]["TransmissionPort"] # 8084
|
||||||
TransmissionUSR = config().get("Torrent", "TransmissionUSR") # mysecretusr
|
TransmissionUSR = config()["Torrent"]["TransmissionUSR"] # mysecretusr
|
||||||
TransmissionPWD = config().get("Torrent", "TransmissionPWD") # mysecretpwr
|
TransmissionPWD = config()["Torrent"]["TransmissionPWD"] # mysecretpwr
|
||||||
|
|
||||||
DelugeHost = config().get("Torrent", "DelugeHost") # localhost
|
DelugeHost = config()["Torrent"]["DelugeHost"] # localhost
|
||||||
DelugePort = config().get("Torrent", "DelugePort") # 8084
|
DelugePort = config()["Torrent"]["DelugePort"] # 8084
|
||||||
DelugeUSR = config().get("Torrent", "DelugeUSR") # mysecretusr
|
DelugeUSR = config()["Torrent"]["DelugeUSR"] # mysecretusr
|
||||||
DelugePWD = config().get("Torrent", "DelugePWD") # mysecretpwr
|
DelugePWD = config()["Torrent"]["DelugePWD"] # mysecretpwr
|
||||||
|
|
||||||
deleteOriginal = int(config().get("Torrent", "deleteOriginal")) # 0
|
deleteOriginal = int(config()["Torrent"]["deleteOriginal"]) # 0
|
||||||
forceClean = int(config().get("Torrent", "forceClean")) # 0
|
forceClean = int(config()["Torrent"]["forceClean"]) # 0
|
||||||
|
|
||||||
compressedContainer = (config().get("Extensions", "compressedExtensions")).split(',') # .zip,.rar,.7z
|
compressedContainer = (config()["Extensions"]["compressedExtensions"]) # .zip,.rar,.7z
|
||||||
mediaContainer = (config().get("Extensions", "mediaExtensions")).split(',') # .mkv,.avi,.divx
|
mediaContainer = (config()["Extensions"]["mediaExtensions"]) # .mkv,.avi,.divx
|
||||||
metaContainer = (config().get("Extensions", "metaExtensions")).split(',') # .nfo,.sub,.srt
|
metaContainer = (config()["Extensions"]["metaExtensions"]) # .nfo,.sub,.srt
|
||||||
minSampleSize = int(config().get("Extensions", "minSampleSize")) # 200 (in MB)
|
minSampleSize = int(config()["Extensions"]["minSampleSize"]) # 200 (in MB)
|
||||||
SampleIDs = (config().get("Extensions", "SampleIDs")).split(',') # sample,-s.
|
SampleIDs = (config()["Extensions"]["SampleIDs"]) # sample,-s.
|
||||||
|
|
||||||
Torrent_NoLink = int(config().get("SickBeard", "Torrent_NoLink")) # 0
|
sections = config.get_categories(["CouchPotato", "SickBeard", "HeadPhones", "Mylar", "Gamez"])
|
||||||
cpsCategory = (config().get("CouchPotato", "cpsCategory")).split(',') # movie
|
categories += list(chain.from_iterable(sections.values()))
|
||||||
sbCategory = (config().get("SickBeard", "sbCategory")).split(',') # tv
|
|
||||||
hpCategory = (config().get("HeadPhones", "hpCategory")).split(',') # music
|
|
||||||
mlCategory = (config().get("Mylar", "mlCategory")).split(',') # comics
|
|
||||||
gzCategory = (config().get("Gamez", "gzCategory")).split(',') # games
|
|
||||||
categories.extend(cpsCategory)
|
|
||||||
categories.extend(sbCategory)
|
|
||||||
categories.extend(hpCategory)
|
|
||||||
categories.extend(mlCategory)
|
|
||||||
categories.extend(gzCategory)
|
|
||||||
|
|
||||||
user_script_categories = config().get("UserScript", "user_script_categories").split(',') # NONE
|
user_script_categories = config()["UserScript"]["user_script_categories"] # NONE
|
||||||
if not "NONE" in user_script_categories:
|
if not "NONE" in user_script_categories:
|
||||||
user_script_mediaExtensions = (config().get("UserScript", "user_script_mediaExtensions")).split(',')
|
user_script_mediaExtensions = (config()["UserScript"]["user_script_mediaExtensions"])
|
||||||
user_script = config().get("UserScript", "user_script_path")
|
user_script = config()["UserScript"]["user_script_path"]
|
||||||
user_script_param = (config().get("UserScript", "user_script_param")).split(',')
|
user_script_param = (config()["UserScript"]["user_script_param"])
|
||||||
user_script_successCodes = (config().get("UserScript", "user_script_successCodes")).split(',')
|
user_script_successCodes = (config()["UserScript"]["user_script_successCodes"])
|
||||||
user_script_clean = int(config().get("UserScript", "user_script_clean"))
|
user_script_clean = int(config()["UserScript"]["user_script_clean"])
|
||||||
user_delay = int(config().get("UserScript", "delay"))
|
user_delay = int(config()["UserScript"]["delay"])
|
||||||
user_script_runOnce = int(config().get("UserScript", "user_script_runOnce"))
|
user_script_runOnce = int(config()["UserScript"]["user_script_runOnce"])
|
||||||
|
|
||||||
transcode = int(config().get("Transcoder", "transcode"))
|
transcode = int(config()["Transcoder"]["transcode"])
|
||||||
|
|
||||||
n = 0
|
n = 0
|
||||||
for arg in sys.argv:
|
for arg in sys.argv:
|
||||||
|
|
|
@ -2,199 +2,174 @@
|
||||||
# For more information, visit https://github.com/clinton-hall/nzbToMedia/wiki
|
# For more information, visit https://github.com/clinton-hall/nzbToMedia/wiki
|
||||||
|
|
||||||
[CouchPotato]
|
[CouchPotato]
|
||||||
#### autoProcessing for Movies
|
#### autoProcessing for Movies
|
||||||
#### cpsCategory - category that gets called for post-processing with CPS
|
#### movie - category that gets called for post-processing with CPS
|
||||||
cpsCategory = movie
|
[[movie]]
|
||||||
apikey =
|
apikey =
|
||||||
host = localhost
|
host = localhost
|
||||||
port = 5050
|
port = 5050
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
ssl = 0
|
ssl = 0
|
||||||
web_root =
|
web_root =
|
||||||
delay = 65
|
delay = 65
|
||||||
TimePerGiB = 60
|
TimePerGiB = 60
|
||||||
method = renamer
|
method = renamer
|
||||||
delete_failed = 0
|
delete_failed = 0
|
||||||
wait_for = 2
|
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
|
||||||
watch_dir =
|
watch_dir =
|
||||||
|
|
||||||
[SickBeard]
|
[SickBeard]
|
||||||
#### autoProcessing for TV Series
|
#### autoProcessing for TV Series
|
||||||
#### sbCategory - category that gets called for post-processing with SB
|
#### tv - category that gets called for post-processing with SB
|
||||||
sbCategory = tv
|
[[tv]]
|
||||||
host = localhost
|
host = localhost
|
||||||
port = 8081
|
port = 8081
|
||||||
username =
|
username =
|
||||||
password =
|
password =
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
web_root =
|
web_root =
|
||||||
ssl = 0
|
ssl = 0
|
||||||
delay = 0
|
delay = 0
|
||||||
TimePerGiB = 60
|
TimePerGiB = 60
|
||||||
watch_dir =
|
watch_dir =
|
||||||
fork = auto
|
fork = auto
|
||||||
delete_failed = 0
|
delete_failed = 0
|
||||||
nzbExtractionBy = Downloader
|
nzbExtractionBy = Downloader
|
||||||
Torrent_NoLink = 0
|
Torrent_NoLink = 0
|
||||||
process_method =
|
process_method =
|
||||||
|
|
||||||
[HeadPhones]
|
[HeadPhones]
|
||||||
#### autoProcessing for Music
|
#### autoProcessing for Music
|
||||||
#### hpCategory - category that gets called for post-processing with HP
|
#### music - category that gets called for post-processing with HP
|
||||||
hpCategory = music
|
[[music]]
|
||||||
apikey =
|
apikey =
|
||||||
host = localhost
|
host = localhost
|
||||||
port = 8181
|
port = 8181
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
ssl = 0
|
ssl = 0
|
||||||
web_root =
|
web_root =
|
||||||
delay = 65
|
delay = 65
|
||||||
TimePerGiB = 60
|
TimePerGiB = 60
|
||||||
watch_dir =
|
watch_dir =
|
||||||
|
|
||||||
[Mylar]
|
[Mylar]
|
||||||
#### autoProcessing for Comics
|
#### autoProcessing for Comics
|
||||||
#### mlCategory - category that gets called for post-processing with Mylar
|
#### comics - category that gets called for post-processing with Mylar
|
||||||
mlCategory = comics
|
[[comics]]
|
||||||
host = localhost
|
host = localhost
|
||||||
port= 8090
|
port= 8090
|
||||||
username=
|
username=
|
||||||
password=
|
password=
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
web_root=
|
web_root=
|
||||||
ssl=0
|
ssl=0
|
||||||
watch_dir =
|
watch_dir =
|
||||||
|
|
||||||
[Gamez]
|
[Gamez]
|
||||||
#### autoProcessing for Games
|
#### autoProcessing for Games
|
||||||
#### gzCategory - category that gets called for post-processing with Gamez
|
#### games - category that gets called for post-processing with Gamez
|
||||||
gzCategory = games
|
[[games]]
|
||||||
apikey =
|
apikey =
|
||||||
host = localhost
|
host = localhost
|
||||||
port = 8085
|
port = 8085
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
ssl = 0
|
ssl = 0
|
||||||
web_root =
|
web_root =
|
||||||
watch_dir =
|
watch_dir =
|
||||||
|
|
||||||
[Torrent]
|
[Torrent]
|
||||||
###### clientAgent - Supported clients: utorrent, transmission, deluge, rtorrent, other
|
###### clientAgent - Supported clients: utorrent, transmission, deluge, rtorrent, other
|
||||||
clientAgent = other
|
clientAgent = other
|
||||||
###### useLink - Set to hard for physical links, sym for symbolic links, move to move, and no to not use links (copy)
|
###### useLink - Set to hard for physical links, sym for symbolic links, move to move, and no to not use links (copy)
|
||||||
useLink = hard
|
useLink = hard
|
||||||
###### outputDirectory - Default output directory (categories will be appended as sub directory to outputDirectory)
|
###### outputDirectory - Default output directory (categories will be appended as sub directory to outputDirectory)
|
||||||
outputDirectory = /abs/path/to/complete/
|
outputDirectory = /abs/path/to/complete/
|
||||||
###### Other categories/labels defined for your downloader. Does not include CouchPotato, SickBeard, HeadPhones, Mylar categories.
|
###### Other categories/labels defined for your downloader. Does not include CouchPotato, SickBeard, HeadPhones, Mylar categories.
|
||||||
categories = music_videos,pictures,software,manual
|
categories = music_videos,pictures,software,manual
|
||||||
###### A list of categories that you don't want to be flattened (i.e preserve the directory structure when copying/linking.
|
###### A list of categories that you don't want to be flattened (i.e preserve the directory structure when copying/linking.
|
||||||
noFlatten = pictures,manual
|
noFlatten = pictures,manual
|
||||||
###### uTorrent Hardlink solution (You must edit this if your using TorrentToMedia.py with uTorrent)
|
###### uTorrent Hardlink solution (You must edit this if your using TorrentToMedia.py with uTorrent)
|
||||||
uTorrentWEBui = http://localhost:8090/gui/
|
uTorrentWEBui = http://localhost:8090/gui/
|
||||||
uTorrentUSR = your username
|
uTorrentUSR = your username
|
||||||
uTorrentPWD = your password
|
uTorrentPWD = your password
|
||||||
###### Transmission (You must edit this if your using TorrentToMedia.py with uTorrent)
|
###### Transmission (You must edit this if your using TorrentToMedia.py with uTorrent)
|
||||||
TransmissionHost = localhost
|
TransmissionHost = localhost
|
||||||
TransmissionPort = 8084
|
TransmissionPort = 8084
|
||||||
TransmissionUSR = your username
|
TransmissionUSR = your username
|
||||||
TransmissionPWD = your password
|
TransmissionPWD = your password
|
||||||
#### Deluge (You must edit this if your using TorrentToMedia.py with deluge. Note that the host/port is for the deluge daemon, not the webui)
|
#### Deluge (You must edit this if your using TorrentToMedia.py with deluge. Note that the host/port is for the deluge daemon, not the webui)
|
||||||
DelugeHost = localhost
|
DelugeHost = localhost
|
||||||
DelugePort = 58846
|
DelugePort = 58846
|
||||||
DelugeUSR = your username
|
DelugeUSR = your username
|
||||||
DelugePWD = your password
|
DelugePWD = your password
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
deleteOriginal = 0
|
deleteOriginal = 0
|
||||||
forceClean = 0
|
forceClean = 0
|
||||||
|
|
||||||
[Extensions]
|
[Extensions]
|
||||||
compressedExtensions = .zip,.rar,.7z,.gz,.bz,.tar,.arj,.1,.01,.001
|
compressedExtensions = .zip,.rar,.7z,.gz,.bz,.tar,.arj,.1,.01,.001
|
||||||
mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.m4v
|
mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.m4v
|
||||||
metaExtensions = .nfo,.sub,.srt,.jpg,.gif
|
metaExtensions = .nfo,.sub,.srt,.jpg,.gif
|
||||||
###### minSampleSize - Minimum required size to consider a media file not a sample file (in MB, eg 200mb)
|
###### minSampleSize - Minimum required size to consider a media file not a sample file (in MB, eg 200mb)
|
||||||
minSampleSize = 200
|
minSampleSize = 200
|
||||||
###### SampleIDs - a list of common sample identifiers. Use SizeOnly to ignore this and delete all media files less than minSampleSize
|
###### SampleIDs - a list of common sample identifiers. Use SizeOnly to ignore this and delete all media files less than minSampleSize
|
||||||
SampleIDs = sample,-s.
|
SampleIDs = sample,-s.
|
||||||
|
|
||||||
[Transcoder]
|
[Transcoder]
|
||||||
transcode = 0
|
transcode = 0
|
||||||
###### duplicate =1 will cretae a new file. =0 will replace the original
|
###### duplicate =1 will cretae a new file. =0 will replace the original
|
||||||
duplicate = 1
|
duplicate = 1
|
||||||
# Only works on Linux. Highest priority is -20, lowest priority is 19.
|
# Only works on Linux. Highest priority is -20, lowest priority is 19.
|
||||||
niceness = 0
|
niceness = 0
|
||||||
ignoreExtensions = .avi,.mkv,.mp4
|
ignoreExtensions = .avi,.mkv,.mp4
|
||||||
outputVideoExtension = .mp4
|
outputVideoExtension = .mp4
|
||||||
outputVideoCodec = libx264
|
outputVideoCodec = libx264
|
||||||
outputVideoPreset = medium
|
outputVideoPreset = medium
|
||||||
outputVideoFramerate = 24
|
outputVideoFramerate = 24
|
||||||
outputVideoBitrate = 800k
|
outputVideoBitrate = 800k
|
||||||
outputAudioCodec = libmp3lame
|
outputAudioCodec = libmp3lame
|
||||||
outputAudioBitrate = 128k
|
outputAudioBitrate = 128k
|
||||||
outputSubtitleCodec =
|
outputSubtitleCodec =
|
||||||
# outputFastStart. 1 will use -movflags + faststart. 0 will disable this from being used.
|
# outputFastStart. 1 will use -movflags + faststart. 0 will disable this from being used.
|
||||||
outputFastStart = 0
|
outputFastStart = 0
|
||||||
# outputQualityPercent. used as -q:a value. 0 will disable this from being used.
|
# outputQualityPercent. used as -q:a value. 0 will disable this from being used.
|
||||||
outputQualityPercent = 0
|
outputQualityPercent = 0
|
||||||
|
|
||||||
[WakeOnLan]
|
[WakeOnLan]
|
||||||
###### set wake = 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) the host and port specified.
|
###### set wake = 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) the host and port specified.
|
||||||
wake = 0
|
wake = 0
|
||||||
host = 192.168.1.37
|
host = 192.168.1.37
|
||||||
port = 80
|
port = 80
|
||||||
mac = 00:01:2e:2D:64:e1
|
mac = 00:01:2e:2D:64:e1
|
||||||
|
|
||||||
[UserScript]
|
[UserScript]
|
||||||
#Use user_script for uncategorized download?
|
#Use user_script for uncategorized download?
|
||||||
#Set the categories to use external script, comma separated.
|
#Set the categories to use external script, comma separated.
|
||||||
#Use "UNCAT" to process non-category downloads, and "ALL" for all. Set to "NONE" to disable external script.
|
#Use "UNCAT" to process non-category downloads, and "ALL" for all. Set to "NONE" to disable external script.
|
||||||
user_script_categories = NONE
|
user_script_categories = NONE
|
||||||
#What extension do you want to process? Specify all the extension, or use "ALL" to process all files.
|
#What extension do you want to process? Specify all the extension, or use "ALL" to process all files.
|
||||||
user_script_mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg
|
user_script_mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg
|
||||||
#Specify the path of the script
|
#Specify the path of the script
|
||||||
user_script_path = /media/test/script/script.sh
|
user_script_path = /media/test/script/script.sh
|
||||||
#Specify the argument(s) passed to script, comma separated in order.
|
#Specify the argument(s) passed to script, comma separated in order.
|
||||||
#for example FP,FN,DN, TN, TL for file path (absolute file name with path), file name, absolute directory name (with path), Torrent Name, Torrent Label/Category.
|
#for example FP,FN,DN, TN, TL for file path (absolute file name with path), file name, absolute directory name (with path), Torrent Name, Torrent Label/Category.
|
||||||
#So the result is /media/test/script/script.sh FP FN DN TN TL. Add other arguments as needed eg -f, -r
|
#So the result is /media/test/script/script.sh FP FN DN TN TL. Add other arguments as needed eg -f, -r
|
||||||
user_script_param = FN
|
user_script_param = FN
|
||||||
#Set user_script_runOnce = 0 to run for each file, or 1 to only run once (presumably on teh entire directory).
|
#Set user_script_runOnce = 0 to run for each file, or 1 to only run once (presumably on teh entire directory).
|
||||||
user_script_runOnce = 0
|
user_script_runOnce = 0
|
||||||
#Specify the successcodes returned by the user script as a comma separated list. Linux default is 0
|
#Specify the successcodes returned by the user script as a comma separated list. Linux default is 0
|
||||||
user_script_successCodes = 0
|
user_script_successCodes = 0
|
||||||
#Clean after? Note that delay function is used to prevent possible mistake :) Delay is intended as seconds
|
#Clean after? Note that delay function is used to prevent possible mistake :) Delay is intended as seconds
|
||||||
user_script_clean = 1
|
user_script_clean = 1
|
||||||
delay = 120
|
delay = 120
|
||||||
|
|
||||||
[ASCII]
|
[ASCII]
|
||||||
#Set convert =1 if you want to convert any "foreign" characters to ASCII before passing to SB/CP etc. Default is disabled (0).
|
#Set convert =1 if you want to convert any "foreign" characters to ASCII before passing to SB/CP etc. Default is disabled (0).
|
||||||
convert = 0
|
convert = 0
|
||||||
|
|
||||||
[passwords]
|
[passwords]
|
||||||
# enter the full path to a text file containing passwords to be used for extraction attempts.
|
# enter the full path to a text file containing passwords to be used for extraction attempts.
|
||||||
# In the passwords file, every password should be on a new line
|
# In the passwords file, every password should be on a new line
|
||||||
PassWordFile =
|
PassWordFile =
|
||||||
|
|
||||||
# Logging configuration
|
|
||||||
[loggers]
|
|
||||||
keys = root
|
|
||||||
|
|
||||||
[handlers]
|
|
||||||
keys = console
|
|
||||||
|
|
||||||
[formatters]
|
|
||||||
keys = generic
|
|
||||||
|
|
||||||
[logger_root]
|
|
||||||
level = NOTSET
|
|
||||||
handlers = console
|
|
||||||
qualname =
|
|
||||||
|
|
||||||
[handler_console]
|
|
||||||
class = StreamHandler
|
|
||||||
args = (sys.stdout,)
|
|
||||||
level = INFO
|
|
||||||
formatter = generic
|
|
||||||
|
|
||||||
[formatter_generic]
|
|
||||||
format = %(asctime)s|%(levelname)-7.7s %(message)s
|
|
||||||
datefmt = %H:%M:%S
|
|
2477
lib/configobj.py
Normal file
2477
lib/configobj.py
Normal file
File diff suppressed because it is too large
Load diff
1472
lib/validate.py
Normal file
1472
lib/validate.py
Normal file
File diff suppressed because it is too large
Load diff
23
logging.cfg
Normal file
23
logging.cfg
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
[loggers]
|
||||||
|
keys = root
|
||||||
|
|
||||||
|
[handlers]
|
||||||
|
keys = console
|
||||||
|
|
||||||
|
[formatters]
|
||||||
|
keys = generic
|
||||||
|
|
||||||
|
[logger_root]
|
||||||
|
level = NOTSET
|
||||||
|
handlers = console
|
||||||
|
qualname =
|
||||||
|
|
||||||
|
[handler_console]
|
||||||
|
class = StreamHandler
|
||||||
|
args = (sys.stdout,)
|
||||||
|
level = INFO
|
||||||
|
formatter = generic
|
||||||
|
|
||||||
|
[formatter_generic]
|
||||||
|
format = %(asctime)s|%(levelname)-7.7s %(message)s
|
||||||
|
datefmt = %H:%M:%S
|
|
@ -148,8 +148,8 @@ if migratecfg().migrate():
|
||||||
else:
|
else:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# couchpotato category
|
# setup sections and categories
|
||||||
cpsCategory = (config().get("CouchPotato", "cpsCategory")).split(',') # movie
|
categories = config.get_categories(["CouchPotato"])
|
||||||
|
|
||||||
WakeUp()
|
WakeUp()
|
||||||
|
|
||||||
|
@ -239,10 +239,13 @@ else:
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||||
Logger.info("MAIN: Running autoProcessMovie as a manual run...")
|
Logger.info("MAIN: Running autoProcessMovie as a manual run...")
|
||||||
|
|
||||||
for dirName in get_dirnames("CouchPotato", cpsCategory[0]):
|
for section, category in categories.items():
|
||||||
Logger.info("MAIN: Calling CouchPotato to post-process: %s", dirName)
|
for dirName in get_dirnames(section, category):
|
||||||
result = autoProcessMovie().process(dirName, dirName, 0)
|
Logger.info("MAIN: Calling " + section + ":" + category + " to post-process: %s", dirName)
|
||||||
if result != 0: break
|
results = autoProcessMovie().process(dirName, dirName, 0)
|
||||||
|
if results != 0:
|
||||||
|
result = 1
|
||||||
|
Logger.info("MAIN: A problem was reported in the autoProcessMovie script.")
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
Logger.info("MAIN: The autoProcessMovie script completed successfully.")
|
Logger.info("MAIN: The autoProcessMovie script completed successfully.")
|
||||||
|
|
|
@ -84,7 +84,7 @@ else:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# gamez category
|
# gamez category
|
||||||
gzCategory = (config().get("Gamez", "gzCategory")).split(',') # gamez
|
categories = config.get_categories(['Gamez'])
|
||||||
|
|
||||||
WakeUp()
|
WakeUp()
|
||||||
|
|
||||||
|
@ -162,13 +162,17 @@ elif len(sys.argv) >= config.SABNZB_0717_NO_OF_ARGUMENTS:
|
||||||
result = autoProcessGames().process(sys.argv[1], sys.argv[3], sys.argv[7])
|
result = autoProcessGames().process(sys.argv[1], sys.argv[3], sys.argv[7])
|
||||||
else:
|
else:
|
||||||
result = 0
|
result = 0
|
||||||
|
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client. Exiting")
|
Logger.warn("MAIN: Invalid number of arguments received from client. Exiting")
|
||||||
Logger.info("MAIN: Running autoProcessGames as a manual run...")
|
Logger.info("MAIN: Running autoProcessGames as a manual run...")
|
||||||
|
|
||||||
for dirName in get_dirnames("Gamez", gzCategory[0]):
|
for section, category in categories.items():
|
||||||
Logger.info("MAIN: Calling Gamez to post-process: %s", dirName)
|
for dirName in get_dirnames(section, category):
|
||||||
result = autoProcessGames().process(dirName, dirName, 0)
|
Logger.info("MAIN: Calling " + section + ":" + category + " to post-process: %s", dirName)
|
||||||
if result != 0: break
|
results = autoProcessGames().process(dirName, dirName, 0)
|
||||||
|
if results != 0:
|
||||||
|
result = 1
|
||||||
|
Logger.info("MAIN: A problem was reported in the autoProcessGames script.")
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
Logger.info("MAIN: The autoProcessGames script completed successfully.")
|
Logger.info("MAIN: The autoProcessGames script completed successfully.")
|
||||||
|
|
|
@ -95,8 +95,9 @@ if migratecfg().migrate():
|
||||||
Logger.info("MAIN: Loading config from %s", config.CONFIG_FILE)
|
Logger.info("MAIN: Loading config from %s", config.CONFIG_FILE)
|
||||||
else:
|
else:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# headphones category
|
# headphones category
|
||||||
hpCategory = (config().get("HeadPhones", "hpCategory")).split(',') # music
|
categories = config.get_categories(["HeadPhones"])
|
||||||
|
|
||||||
WakeUp()
|
WakeUp()
|
||||||
|
|
||||||
|
@ -178,10 +179,13 @@ else:
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||||
Logger.info("MAIN: Running autoProcessMusic as a manual run...")
|
Logger.info("MAIN: Running autoProcessMusic as a manual run...")
|
||||||
|
|
||||||
for dirName in get_dirnames("HeadPhones", hpCategory[0]):
|
for section, category in categories.items():
|
||||||
Logger.info("MAIN: Calling Headphones to post-process: %s", dirName)
|
for dirName in get_dirnames(section, category):
|
||||||
result = result = autoProcessMusic().process(dirName, dirName, 0)
|
Logger.info("MAIN: Calling " + section + ":" + category + " to post-process: %s", dirName)
|
||||||
if result != 0: break
|
results = autoProcessMusic().process(dirName, dirName, 0)
|
||||||
|
if results != 0:
|
||||||
|
result = 1
|
||||||
|
Logger.info("MAIN: A problem was reported in the autoProcessMusic script.")
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
Logger.info("MAIN: The autoProcessMusic script completed successfully.")
|
Logger.info("MAIN: The autoProcessMusic script completed successfully.")
|
||||||
|
|
|
@ -288,7 +288,7 @@ from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_
|
||||||
|
|
||||||
# post-processing
|
# post-processing
|
||||||
def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=None, inputCategory=None):
|
def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=None, inputCategory=None):
|
||||||
if inputCategory in cpsCategory:
|
if inputCategory in sections["CouchPotato"]:
|
||||||
if isinstance(nzbDir, list):
|
if isinstance(nzbDir, list):
|
||||||
for dirName in nzbDir:
|
for dirName in nzbDir:
|
||||||
Logger.info("MAIN: Calling CouchPotatoServer to post-process: %s", inputName)
|
Logger.info("MAIN: Calling CouchPotatoServer to post-process: %s", inputName)
|
||||||
|
@ -298,7 +298,7 @@ def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=
|
||||||
else:
|
else:
|
||||||
Logger.info("MAIN: Calling CouchPotatoServer to post-process: %s", inputName)
|
Logger.info("MAIN: Calling CouchPotatoServer to post-process: %s", inputName)
|
||||||
return autoProcessMovie().process(nzbDir, inputName, status, clientAgent, download_id, inputCategory)
|
return autoProcessMovie().process(nzbDir, inputName, status, clientAgent, download_id, inputCategory)
|
||||||
elif inputCategory in sbCategory:
|
elif inputCategory in sections["SickBeard"]:
|
||||||
if isinstance(nzbDir, list):
|
if isinstance(nzbDir, list):
|
||||||
for dirName in nzbDir:
|
for dirName in nzbDir:
|
||||||
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName)
|
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName)
|
||||||
|
@ -308,7 +308,7 @@ def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=
|
||||||
else:
|
else:
|
||||||
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName)
|
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName)
|
||||||
return autoProcessTV().processEpisode(nzbDir, inputName, status, clientAgent, inputCategory)
|
return autoProcessTV().processEpisode(nzbDir, inputName, status, clientAgent, inputCategory)
|
||||||
elif inputCategory in hpCategory:
|
elif inputCategory in sections["HeadPhones"]:
|
||||||
if isinstance(nzbDir, list):
|
if isinstance(nzbDir, list):
|
||||||
for dirName in nzbDir:
|
for dirName in nzbDir:
|
||||||
Logger.info("MAIN: Calling Headphones to post-process: %s", dirName)
|
Logger.info("MAIN: Calling Headphones to post-process: %s", dirName)
|
||||||
|
@ -318,7 +318,7 @@ def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=
|
||||||
else:
|
else:
|
||||||
Logger.info("MAIN: Calling HeadPhones to post-process: %s", inputName)
|
Logger.info("MAIN: Calling HeadPhones to post-process: %s", inputName)
|
||||||
return autoProcessMusic().process(nzbDir, inputName, status, clientAgent, inputCategory)
|
return autoProcessMusic().process(nzbDir, inputName, status, clientAgent, inputCategory)
|
||||||
elif inputCategory in mlCategory:
|
elif inputCategory in sections["Mylar"]:
|
||||||
if isinstance(nzbDir, list):
|
if isinstance(nzbDir, list):
|
||||||
for dirName in nzbDir:
|
for dirName in nzbDir:
|
||||||
Logger.info("MAIN: Calling Mylar to post-process: %s", dirName)
|
Logger.info("MAIN: Calling Mylar to post-process: %s", dirName)
|
||||||
|
@ -328,7 +328,7 @@ def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=
|
||||||
else:
|
else:
|
||||||
Logger.info("MAIN: Calling Mylar to post-process: %s", inputName)
|
Logger.info("MAIN: Calling Mylar to post-process: %s", inputName)
|
||||||
return autoProcessComics().processEpisode(nzbDir, inputName, status, clientAgent, inputCategory)
|
return autoProcessComics().processEpisode(nzbDir, inputName, status, clientAgent, inputCategory)
|
||||||
elif inputCategory in gzCategory:
|
elif inputCategory in sections["Gamez"]:
|
||||||
if isinstance(nzbDir, list):
|
if isinstance(nzbDir, list):
|
||||||
for dirName in nzbDir:
|
for dirName in nzbDir:
|
||||||
Logger.info("MAIN: Calling Gamez to post-process: %s", dirName)
|
Logger.info("MAIN: Calling Gamez to post-process: %s", dirName)
|
||||||
|
@ -361,12 +361,8 @@ else:
|
||||||
print("Unable to find " + config.CONFIG_FILE + " or " + config.SAMPLE_CONFIG_FILE)
|
print("Unable to find " + config.CONFIG_FILE + " or " + config.SAMPLE_CONFIG_FILE)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# setup categories
|
# setup sections and categories
|
||||||
cpsCategory = (config().get("CouchPotato", "cpsCategory")).split(',') or []
|
sections = config.get_categories(["CouchPotato","SickBeard","HeadPhones","Mylar","Gamez"])
|
||||||
sbCategory = (config().get("SickBeard", "sbCategory")).split(',') or []
|
|
||||||
hpCategory = (config().get("HeadPhones", "hpCategory")).split(',') or []
|
|
||||||
mlCategory = (config().get("Mylar", "mlCategory")).split(',') or []
|
|
||||||
gzCategory = (config().get("Gamez", "gzCategory")).split(',') or []
|
|
||||||
|
|
||||||
WakeUp()
|
WakeUp()
|
||||||
|
|
||||||
|
@ -453,31 +449,16 @@ elif len(sys.argv) >= config.SABNZB_0717_NO_OF_ARGUMENTS:
|
||||||
result = process(sys.argv[1], inputName=sys.argv[2], status=sys.argv[7], inputCategory=sys.argv[5], clientAgent = "sabnzbd", download_id='')
|
result = process(sys.argv[1], inputName=sys.argv[2], status=sys.argv[7], inputCategory=sys.argv[5], clientAgent = "sabnzbd", download_id='')
|
||||||
if result != 0:Logger.info("MAIN: A problem was reported in the autoProcess* script.")
|
if result != 0:Logger.info("MAIN: A problem was reported in the autoProcess* script.")
|
||||||
else:
|
else:
|
||||||
# only CPS and SB supports this manual run for now.
|
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
|
||||||
|
|
||||||
Logger.info("MAIN: Running autoProcessMovie as a manual run...")
|
|
||||||
if process(get_dirnames("CouchPotato", cpsCategory[0]), inputName=get_dirnames("CouchPotato", cpsCategory[0]), status=0, inputCategory=cpsCategory[0], clientAgent = "manual", download_id='') != 0:
|
|
||||||
Logger.info("MAIN: A problem was reported in the autoProcessMovie script.")
|
|
||||||
|
|
||||||
Logger.info("MAIN: Running autoProcessTV as a manual run...")
|
|
||||||
if process(get_dirnames("SickBeard", sbCategory[0]), inputName=get_dirnames("SickBeard", sbCategory[0]), status=0, clientAgent = "manual", inputCategory=sbCategory[0]) != 0:
|
|
||||||
Logger.info("MAIN: A problem was reported in the autoProcessTV script.")
|
|
||||||
|
|
||||||
Logger.info("MAIN: Running autoProcessMusic as a manual run...")
|
|
||||||
if process(get_dirnames("HeadPhones", hpCategory[0]), inputName=get_dirnames("HeadPhones", hpCategory[0]), status=0, clientAgent = "manual", inputCategory=hpCategory[0]) != 0:
|
|
||||||
Logger.info("MAIN: A problem was reported in the autoProcessMusic script.")
|
|
||||||
|
|
||||||
Logger.info("MAIN: Running autoProcessComics as a manual run...")
|
|
||||||
if process(get_dirnames("Mylar", mlCategory[0]), inputName=get_dirnames("Mylar", mlCategory[0]), status=0,clientAgent="manual", inputCategory=mlCategory[0]) != 0:
|
|
||||||
Logger.info("MAIN: A problem was reported in the autoProcessComics script.")
|
|
||||||
|
|
||||||
Logger.info("MAIN: Running autoProcessGames as a manual run...")
|
|
||||||
if process(get_dirnames("Gamez", gzCategory[0]), inputName=get_dirnames("Gamez", gzCategory[0]), status=0,clientAgent="manual", inputCategory=gzCategory[0]) != 0:
|
|
||||||
Logger.info("MAIN: A problem was reported in the autoProcessGames script.")
|
|
||||||
|
|
||||||
result = 0
|
result = 0
|
||||||
|
|
||||||
|
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||||
|
for section, categories in sections.items():
|
||||||
|
for category in categories:
|
||||||
|
dirnames = get_dirnames(section, category)
|
||||||
|
Logger.info("MAIN: Running " + section + ":" + category + " as a manual run...")
|
||||||
|
if process(dirnames, inputName=dirnames, status=0, inputCategory=category, clientAgent = "manual") != 0:
|
||||||
|
Logger.info("MAIN: A problem was reported when trying to manually run " + section + ":" + category + ".")
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
Logger.info("MAIN: The nzbToMedia script completed successfully.")
|
Logger.info("MAIN: The nzbToMedia script completed successfully.")
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'): # return code for nzbget v11
|
if os.environ.has_key('NZBOP_SCRIPTDIR'): # return code for nzbget v11
|
||||||
|
|
|
@ -89,7 +89,7 @@ else:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# mylar category
|
# mylar category
|
||||||
mlCategory = (config().get("Mylar", "mlCategory")).split(',') # tv
|
categories = config.get_categories(["Mylar"])
|
||||||
|
|
||||||
WakeUp()
|
WakeUp()
|
||||||
|
|
||||||
|
@ -171,10 +171,13 @@ else:
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||||
Logger.info("MAIN: Running autoProcessComics as a manual run...")
|
Logger.info("MAIN: Running autoProcessComics as a manual run...")
|
||||||
|
|
||||||
for dirName in get_dirnames("Mylar", mlCategory[0]):
|
for section, category in categories.items():
|
||||||
Logger.info("MAIN: Calling Mylar to post-process: %s", dirName)
|
for dirName in get_dirnames(section, category):
|
||||||
result = autoProcessComics().processEpisode(dirName, dirName, 0)
|
Logger.info("MAIN: Calling " + section + ":" + category + " to post-process: %s", dirName)
|
||||||
if result != 0: break
|
results = autoProcessComics().processEpisode(dirName, dirName, 0)
|
||||||
|
if results != 0:
|
||||||
|
result = 1
|
||||||
|
Logger.info("MAIN: A problem was reported in the autoProcessComics script.")
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
Logger.info("MAIN: The autoProcessComics script completed successfully.")
|
Logger.info("MAIN: The autoProcessComics script completed successfully.")
|
||||||
|
|
|
@ -151,7 +151,7 @@ else:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# sickbeard category
|
# sickbeard category
|
||||||
sbCategory = (config().get("SickBeard", "sbCategory")).split(',') # tv
|
categories = config.get_categories(["SickBeard"])
|
||||||
|
|
||||||
WakeUp()
|
WakeUp()
|
||||||
|
|
||||||
|
@ -231,15 +231,18 @@ elif len(sys.argv) >= config.SABNZB_0717_NO_OF_ARGUMENTS:
|
||||||
clientAgent = "sabnzbd"
|
clientAgent = "sabnzbd"
|
||||||
result = autoProcessTV().processEpisode(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent, sys.argv[5])
|
result = autoProcessTV().processEpisode(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent, sys.argv[5])
|
||||||
else:
|
else:
|
||||||
|
result = 0
|
||||||
|
|
||||||
Logger.debug("MAIN: Invalid number of arguments received from client.")
|
Logger.debug("MAIN: Invalid number of arguments received from client.")
|
||||||
Logger.info("MAIN: Running autoProcessTV as a manual run...")
|
Logger.info("MAIN: Running autoProcessTV as a manual run...")
|
||||||
|
|
||||||
sbCategory = (config().get("SickBeard", "sbCategory")).split(',') # tv
|
for section, category in categories.items():
|
||||||
result = 1
|
for dirName in get_dirnames(section, category):
|
||||||
for dirName in get_dirnames("SickBeard", sbCategory[0]):
|
Logger.info("MAIN: Calling " + section + ":" + category + " to post-process: %s", dirName)
|
||||||
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", dirName)
|
results = autoProcessTV().processEpisode(dirName, dirName, 0)
|
||||||
result = autoProcessTV().processEpisode(dirName, dirName, 0)
|
if results != 0:
|
||||||
if result != 0: break
|
result = 1
|
||||||
|
Logger.info("MAIN: A problem was reported in the autoProcessTV script.")
|
||||||
|
|
||||||
if result == 0:
|
if result == 0:
|
||||||
Logger.info("MAIN: The autoProcessTV script completed successfully.")
|
Logger.info("MAIN: The autoProcessTV script completed successfully.")
|
||||||
|
|
|
@ -36,22 +36,22 @@ class Transcoder:
|
||||||
Logger.error("You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
|
Logger.error("You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
|
||||||
mediaContainer = (config().get("Extensions", "mediaExtensions")).split(',')
|
mediaContainer = (config()["Transcoder"]["duplicate"])
|
||||||
duplicate = int(config().get("Transcoder", "duplicate"))
|
duplicate = int(config()["Transcoder"]["duplicate"])
|
||||||
ignoreExtensions = (config().get("Transcoder", "ignoreExtensions")).split(',')
|
ignoreExtensions = (config()["Transcoder"]["ignoreExtensions"])
|
||||||
outputVideoExtension = config().get("Transcoder", "outputVideoExtension").strip()
|
outputVideoExtension = config()["Transcoder"]["outputVideoExtension"].strip()
|
||||||
outputVideoCodec = config().get("Transcoder", "outputVideoCodec").strip()
|
outputVideoCodec = config()["Transcoder"]["outputVideoCodec"].strip()
|
||||||
outputVideoPreset = config().get("Transcoder", "outputVideoPreset").strip()
|
outputVideoPreset = config()["Transcoder"]["outputVideoPreset"].strip()
|
||||||
outputVideoFramerate = config().get("Transcoder", "outputVideoFramerate").strip()
|
outputVideoFramerate = config()["Transcoder"]["outputVideoFramerate"].strip()
|
||||||
outputVideoBitrate = config().get("Transcoder", "outputVideoBitrate").strip()
|
outputVideoBitrate = config()["Transcoder"]["outputVideoBitrate"].strip()
|
||||||
outputAudioCodec = config().get("Transcoder", "outputAudioCodec").strip()
|
outputAudioCodec = config()["Transcoder"]["outputAudioCodec"].strip()
|
||||||
outputAudioBitrate = config().get("Transcoder", "outputAudioBitrate").strip()
|
outputAudioBitrate = config()["Transcoder"]["outputAudioBitrate"].strip()
|
||||||
outputSubtitleCodec = config().get("Transcoder", "outputSubtitleCodec").strip()
|
outputSubtitleCodec = config()["Transcoder"]["outputSubtitleCodec"].strip()
|
||||||
outputFastStart = int(config().get("Transcoder", "outputFastStart"))
|
outputFastStart = int(config()["Transcoder"]["outputFastStart"])
|
||||||
outputQualityPercent = int(config().get("Transcoder", "outputQualityPercent"))
|
outputQualityPercent = int(config()["Transcoder"]["outputQualityPercent"])
|
||||||
|
|
||||||
niceness = None
|
niceness = None
|
||||||
if useNiceness:niceness = int(config().get("Transcoder", "niceness"))
|
if useNiceness:niceness = int(config()["Transcoder"]["niceness"])
|
||||||
|
|
||||||
map(lambda ext: ext.strip(), mediaContainer)
|
map(lambda ext: ext.strip(), mediaContainer)
|
||||||
map(lambda ext: ext.strip(), ignoreExtensions)
|
map(lambda ext: ext.strip(), ignoreExtensions)
|
||||||
|
|
|
@ -19,25 +19,23 @@ class autoProcessComics:
|
||||||
Logger.info("Loading config from %s", config.CONFIG_FILE)
|
Logger.info("Loading config from %s", config.CONFIG_FILE)
|
||||||
|
|
||||||
section = "Mylar"
|
section = "Mylar"
|
||||||
if inputCategory != None and config().has_section(inputCategory):
|
host = config()[section][inputCategory]["host"]
|
||||||
section = inputCategory
|
port = config()[section][inputCategory]["port"]
|
||||||
host = config().get(section, "host")
|
username = config()[section][inputCategory]["username"]
|
||||||
port = config().get(section, "port")
|
password = config()[section][inputCategory]["password"]
|
||||||
username = config().get(section, "username")
|
|
||||||
password = config().get(section, "password")
|
|
||||||
try:
|
try:
|
||||||
ssl = int(config().get(section, "ssl"))
|
ssl = int(config()[section][inputCategory]["ssl"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = config().get(section, "web_root")
|
web_root = config()[section][inputCategory]["web_root"]
|
||||||
except config.NoOptionError:
|
except:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
watch_dir = config().get(section, "watch_dir")
|
watch_dir = config()[section][inputCategory]["watch_dir"]
|
||||||
except config.NoOptionError:
|
except:
|
||||||
watch_dir = ""
|
watch_dir = ""
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
|
|
|
@ -20,21 +20,18 @@ class autoProcessGames:
|
||||||
status = int(status)
|
status = int(status)
|
||||||
|
|
||||||
section = "Gamez"
|
section = "Gamez"
|
||||||
if inputCategory != None and config().has_section(inputCategory):
|
host = config()[section][inputCategory]["host"]
|
||||||
section = inputCategory
|
port = config()[section][inputCategory]["port"]
|
||||||
|
apikey = config()[section][inputCategory]["apikey"]
|
||||||
host = config().get(section, "host")
|
|
||||||
port = config().get(section, "port")
|
|
||||||
apikey = config().get(section, "apikey")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ssl = int(config().get(section, "ssl"))
|
ssl = int(config()[section][inputCategory]["ssl"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = config().get(section, "web_root")
|
web_root = config()[section][inputCategory]["web_root"]
|
||||||
except config.NoOptionError:
|
except:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
if ssl:
|
if ssl:
|
||||||
|
|
|
@ -173,35 +173,32 @@ class autoProcessMovie:
|
||||||
status = int(status)
|
status = int(status)
|
||||||
|
|
||||||
section = "CouchPotato"
|
section = "CouchPotato"
|
||||||
if inputCategory != None and config().has_section(inputCategory):
|
host = config()[section][inputCategory]["host"]
|
||||||
section = inputCategory
|
port = config()[section][inputCategory]["port"]
|
||||||
|
apikey = config()[section][inputCategory]["apikey"]
|
||||||
host = config().get(section, "host")
|
delay = float(config()[section][inputCategory]["delay"])
|
||||||
port = config().get(section, "port")
|
method = config()[section][inputCategory]["method"]
|
||||||
apikey = config().get(section, "apikey")
|
delete_failed = int(config()[section][inputCategory]["delete_failed"])
|
||||||
delay = float(config().get(section, "delay"))
|
wait_for = int(config()[section][inputCategory]["wait_for"])
|
||||||
method = config().get(section, "method")
|
|
||||||
delete_failed = int(config().get(section, "delete_failed"))
|
|
||||||
wait_for = int(config().get(section, "wait_for"))
|
|
||||||
try:
|
try:
|
||||||
TimePerGiB = int(config().get(section, "TimePerGiB"))
|
TimePerGiB = int(config()[section][inputCategory]["TimePerGiB"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
TimePerGiB = 60 # 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:
|
||||||
ssl = int(config().get(section, "ssl"))
|
ssl = int(config()[section][inputCategory]["ssl"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
ssl = 0
|
ssl = 0
|
||||||
try:
|
try:
|
||||||
web_root = config().get(section, "web_root")
|
web_root = config()[section][inputCategory]["web_root"]
|
||||||
except config.NoOptionError:
|
except:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
try:
|
try:
|
||||||
transcode = int(config().get("Transcoder", "transcode"))
|
transcode = int(config()["Transcoder"]["transcode"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
transcode = 0
|
transcode = 0
|
||||||
try:
|
try:
|
||||||
remoteCPS = int(config().get(section, "remoteCPS"))
|
remoteCPS = int(config()[section][inputCategory]["remoteCPS"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
remoteCPS = 0
|
remoteCPS = 0
|
||||||
|
|
||||||
nzbName = str(nzbName) # make sure it is a string
|
nzbName = str(nzbName) # make sure it is a string
|
||||||
|
|
|
@ -21,25 +21,22 @@ class autoProcessMusic:
|
||||||
status = int(status)
|
status = int(status)
|
||||||
|
|
||||||
section = "HeadPhones"
|
section = "HeadPhones"
|
||||||
if inputCategory != None and config().has_section(inputCategory):
|
host = config()[section][inputCategory]["host"]
|
||||||
section = inputCategory
|
port = config()[section][inputCategory]["port"]
|
||||||
|
apikey = config()[section][inputCategory]["apikey"]
|
||||||
host = config().get(section, "host")
|
delay = float(config()[section][inputCategory]["delay"])
|
||||||
port = config().get(section, "port")
|
|
||||||
apikey = config().get(section, "apikey")
|
|
||||||
delay = float(config().get(section, "delay"))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ssl = int(config().get(section, "ssl"))
|
ssl = int(config()[section][inputCategory]["ssl"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
ssl = 0
|
ssl = 0
|
||||||
try:
|
try:
|
||||||
web_root = config().get(section, "web_root")
|
web_root = config()[section][inputCategory]["web_root"]
|
||||||
except config.NoOptionError:
|
except:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
try:
|
try:
|
||||||
TimePerGiB = int(config().get(section, "TimePerGiB"))
|
TimePerGiB = int(config()[section][inputCategory]["TimePerGiB"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
TimePerGiB = 60 # 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.
|
||||||
if ssl:
|
if ssl:
|
||||||
protocol = "https://"
|
protocol = "https://"
|
||||||
|
|
|
@ -26,62 +26,59 @@ class autoProcessTV:
|
||||||
status = int(failed)
|
status = int(failed)
|
||||||
|
|
||||||
section = "SickBeard"
|
section = "SickBeard"
|
||||||
if inputCategory != None and config().has_section(inputCategory):
|
host = config()[section][inputCategory]["host"]
|
||||||
section = inputCategory
|
port = config()[section][inputCategory]["port"]
|
||||||
|
username = config()[section][inputCategory]["username"]
|
||||||
host = config().get(section, "host")
|
password = config()[section][inputCategory]["password"]
|
||||||
port = config().get(section, "port")
|
|
||||||
username = config().get(section, "username")
|
|
||||||
password = config().get(section, "password")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ssl = int(config().get(section, "ssl"))
|
ssl = int(config()[section][inputCategory]["ssl"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
ssl = 0
|
ssl = 0
|
||||||
try:
|
try:
|
||||||
web_root = config().get(section, "web_root")
|
web_root = config()[section][inputCategory]["web_root"]
|
||||||
except config.NoOptionError:
|
except:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
try:
|
try:
|
||||||
watch_dir = config().get(section, "watch_dir")
|
watch_dir = config()[section][inputCategory]["watch_dir"]
|
||||||
except config.NoOptionError:
|
except:
|
||||||
watch_dir = ""
|
watch_dir = ""
|
||||||
try:
|
try:
|
||||||
transcode = int(config().get("Transcoder", "transcode"))
|
transcode = int(config()["Transcoder"]["transcode"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
transcode = 0
|
transcode = 0
|
||||||
try:
|
try:
|
||||||
delete_failed = int(config().get(section, "delete_failed"))
|
delete_failed = int(config()[section][inputCategory]["delete_failed"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
delete_failed = 0
|
delete_failed = 0
|
||||||
try:
|
try:
|
||||||
delay = float(config().get(section, "delay"))
|
delay = float(config()[section][inputCategory]["delay"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
delay = 0
|
delay = 0
|
||||||
try:
|
try:
|
||||||
TimePerGiB = int(config().get(section, "TimePerGiB"))
|
TimePerGiB = int(config()[section][inputCategory]["TimePerGiB"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
TimePerGiB = 60 # 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()["Extensions"]["SampleIDs"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
SampleIDs = ['sample','-s.']
|
SampleIDs = ['sample','-s.']
|
||||||
try:
|
try:
|
||||||
nzbExtractionBy = config().get(section, "nzbExtractionBy")
|
nzbExtractionBy = config()[section][inputCategory]["nzbExtractionBy"]
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
nzbExtractionBy = "Downloader"
|
nzbExtractionBy = "Downloader"
|
||||||
try:
|
try:
|
||||||
process_method = config().get(section, "process_method")
|
process_method = config()[section][inputCategory]["process_method"]
|
||||||
except config.NoOptionError:
|
except:
|
||||||
process_method = None
|
process_method = None
|
||||||
try:
|
try:
|
||||||
Torrent_NoLink = int(config().get(section, "Torrent_NoLink"))
|
Torrent_NoLink = int(config()[section][inputCategory]["Torrent_NoLink"])
|
||||||
except (config.NoOptionError, ValueError):
|
except:
|
||||||
Torrent_NoLink = 0
|
Torrent_NoLink = 0
|
||||||
|
|
||||||
|
|
||||||
mediaContainer = (config().get("Extensions", "mediaExtensions")).split(',')
|
mediaContainer = (config()["Extensions"]["mediaExtensions"])
|
||||||
minSampleSize = int(config().get("Extensions", "minSampleSize"))
|
minSampleSize = int(config()["Extensions"]["minSampleSize"])
|
||||||
|
|
||||||
if not os.path.isdir(dirName) and os.path.isfile(dirName): # If the input directory is a file, assume single file download and split dir/name.
|
if not os.path.isdir(dirName) and os.path.isfile(dirName): # If the input directory is a file, assume single file download and split dir/name.
|
||||||
dirName = os.path.split(os.path.normpath(dirName))[0]
|
dirName = os.path.split(os.path.normpath(dirName))[0]
|
||||||
|
@ -94,7 +91,7 @@ class autoProcessTV:
|
||||||
dirName = SpecificPath
|
dirName = SpecificPath
|
||||||
|
|
||||||
# auto-detect fork type
|
# auto-detect fork type
|
||||||
fork, params = autoFork(section)
|
fork, params = autoFork(section, inputCategory)
|
||||||
|
|
||||||
if fork not in config.SICKBEARD_TORRENT or (clientAgent in ['nzbget','sabnzbd'] and nzbExtractionBy != "Destination"):
|
if fork not in config.SICKBEARD_TORRENT or (clientAgent in ['nzbget','sabnzbd'] and nzbExtractionBy != "Destination"):
|
||||||
if nzbName:
|
if nzbName:
|
||||||
|
@ -141,7 +138,7 @@ class autoProcessTV:
|
||||||
params[param] = dirName
|
params[param] = dirName
|
||||||
|
|
||||||
if param == "process_method":
|
if param == "process_method":
|
||||||
if fork in SICKBEARD_TORRENT and Torrent_NoLink == 1 and not clientAgent in ['nzbget','sabnzbd']: #use default SickBeard settings here.
|
if fork in config.SICKBEARD_TORRENT and Torrent_NoLink == 1 and not clientAgent in ['nzbget','sabnzbd']: #use default SickBeard settings here.
|
||||||
del params[param]
|
del params[param]
|
||||||
if process_method:
|
if process_method:
|
||||||
params[param] = process_method
|
params[param] = process_method
|
||||||
|
|
|
@ -113,7 +113,7 @@ def extract(filePath, outputDestination):
|
||||||
|
|
||||||
Logger.info("MAIN: Loading config from %s", config.CONFIG_FILE)
|
Logger.info("MAIN: Loading config from %s", config.CONFIG_FILE)
|
||||||
|
|
||||||
passwordsfile = config().get("passwords", "PassWordFile")
|
passwordsfile = config()["passwords"]["PassWordFile"]
|
||||||
if passwordsfile != "" and os.path.isfile(os.path.normpath(passwordsfile)):
|
if passwordsfile != "" and os.path.isfile(os.path.normpath(passwordsfile)):
|
||||||
passwords = [line.strip() for line in open(os.path.normpath(passwordsfile))]
|
passwords = [line.strip() for line in open(os.path.normpath(passwordsfile))]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from nzbtomedia.nzbToMediaConfig import config
|
from nzbtomedia.nzbToMediaConfig import config
|
||||||
|
from itertools import chain
|
||||||
|
|
||||||
class migratecfg:
|
class migratecfg:
|
||||||
def migrate(self):
|
def migrate(self):
|
||||||
categories = []
|
categories = {}
|
||||||
confignew = None
|
confignew = None
|
||||||
configold = None
|
configold = None
|
||||||
|
|
||||||
|
@ -26,123 +27,93 @@ class migratecfg:
|
||||||
if not config() and not config(config.SAMPLE_CONFIG_FILE) or not confignew or not configold:
|
if not config() and not config(config.SAMPLE_CONFIG_FILE) or not confignew or not configold:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
section = "CouchPotato"
|
for section in configold.sections:
|
||||||
for option, value in configold.items(section) or config(config.MOVIE_CONFIG_FILE).items(section):
|
for option, value in configold[section].items():
|
||||||
if option == "category": # change this old format
|
if section == "CouchPotato":
|
||||||
option = "cpsCategory"
|
if option == "category": # change this old format
|
||||||
if option == "outputDirectory": # move this to new location format
|
option = "cpsCategory"
|
||||||
value = os.path.split(os.path.normpath(value))[0]
|
if section == "SickBeard":
|
||||||
confignew.set("Torrent", option, value)
|
if option == "category": # change this old format
|
||||||
continue
|
option = "sbCategory"
|
||||||
if option in ["username", "password" ]: # these are no-longer needed.
|
if option in ["cpsCategory","sbCategory","hpCategory","mlCategory","gzCategory"]:
|
||||||
continue
|
if not isinstance(value, list):
|
||||||
if option == "cpsCategory":
|
value = [value]
|
||||||
categories.extend(value.split(','))
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "SickBeard"
|
categories.update({section: value})
|
||||||
for option, value in configold.items(section) or config(config.TV_CONFIG_FILE).items(section):
|
continue
|
||||||
if option == "category": # change this old format
|
|
||||||
option = "sbCategory"
|
try:
|
||||||
if option == "wait_for": # remove old format
|
for section in configold.sections:
|
||||||
continue
|
subsection = None
|
||||||
if option == "failed_fork": # change this old format
|
if section in list(chain.from_iterable(categories.values())):
|
||||||
option = "fork"
|
subsection = section
|
||||||
if value not in ["default", "failed", "failed-torrent", "auto"]:
|
section = ''.join([k for k, v in categories.iteritems() if subsection in v])
|
||||||
value = "auto"
|
elif section in categories.keys():
|
||||||
if option == "fork" and value not in ["default", "failed", "failed-torrent", "auto"]:
|
subsection = categories[section][0]
|
||||||
value = "auto"
|
|
||||||
if option == "Torrent_ForceLink":
|
# create subsection if it does not exist
|
||||||
continue
|
if subsection and subsection not in confignew[section].sections:
|
||||||
if option == "outputDirectory": # move this to new location format
|
confignew[section][subsection] = {}
|
||||||
value = os.path.split(os.path.normpath(value))[0]
|
|
||||||
confignew.set("Torrent", option, value)
|
for option, value in configold[section].items():
|
||||||
continue
|
if section == "CouchPotato":
|
||||||
if option == "sbCategory":
|
if option == "outputDirectory": # move this to new location format
|
||||||
categories.extend(value.split(','))
|
value = os.path.split(os.path.normpath(value))[0]
|
||||||
confignew.set(section, option, value)
|
confignew['Torrent'][option] = value
|
||||||
|
continue
|
||||||
|
if option in ["username", "password"]: # these are no-longer needed.
|
||||||
|
continue
|
||||||
|
if option in ["category","cpsCategory"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if section == "SickBeard":
|
||||||
|
if option == "wait_for": # remove old format
|
||||||
|
continue
|
||||||
|
if option == "failed_fork": # change this old format
|
||||||
|
option = "fork"
|
||||||
|
value = "auto"
|
||||||
|
if option == "Torrent_ForceLink":
|
||||||
|
continue
|
||||||
|
if option == "outputDirectory": # move this to new location format
|
||||||
|
value = os.path.split(os.path.normpath(value))[0]
|
||||||
|
confignew['Torrent'][option] = value
|
||||||
|
continue
|
||||||
|
if option in ["category", "sbCategory"]:
|
||||||
|
continue
|
||||||
|
|
||||||
for section in configold.sections():
|
|
||||||
try:
|
|
||||||
for option, value in configold.items(section):
|
|
||||||
if section == "HeadPhones":
|
if section == "HeadPhones":
|
||||||
if option in ["username", "password" ]:
|
if option in ["username", "password" ]:
|
||||||
continue
|
continue
|
||||||
if option == "hpCategory":
|
if option == "hpCategory":
|
||||||
categories.extend(value.split(','))
|
continue
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "Mylar":
|
if section == "Mylar":
|
||||||
if option in "mlCategory":
|
if option in "mlCategory":
|
||||||
categories.extend(value.split(','))
|
continue
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "Gamez":
|
if section == "Gamez":
|
||||||
if option in ["username", "password" ]: # these are no-longer needed.
|
if option in ["username", "password"]: # these are no-longer needed.
|
||||||
continue
|
continue
|
||||||
if option == "gzCategory":
|
if option == "gzCategory":
|
||||||
categories.extend(value.split(','))
|
continue
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "Torrent":
|
if section == "Torrent":
|
||||||
if option in ["compressedExtensions", "mediaExtensions", "metaExtensions", "minSampleSize"]:
|
if option in ["compressedExtensions", "mediaExtensions", "metaExtensions", "minSampleSize"]:
|
||||||
section = "Extensions" # these were moved
|
section = "Extensions" # these were moved
|
||||||
if option == "useLink": # Sym links supported now as well.
|
if option == "useLink": # Sym links supported now as well.
|
||||||
if isinstance(value, int):
|
if isinstance(value, int):
|
||||||
num_value = int(value)
|
num_value = int(value)
|
||||||
if num_value == 1:
|
if num_value == 1:
|
||||||
value = "hard"
|
value = "hard"
|
||||||
else:
|
else:
|
||||||
value = "no"
|
value = "no"
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "Extensions":
|
if subsection:
|
||||||
confignew.set(section, option, value)
|
confignew[section][subsection][option] = value
|
||||||
|
else:
|
||||||
if section == "Transcoder":
|
confignew[section][option] = value
|
||||||
confignew.set(section, option, value)
|
except:
|
||||||
|
return False
|
||||||
if section == "WakeOnLan":
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "UserScript":
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "ASCII":
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "passwords":
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "loggers":
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "handlers":
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "formatters":
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "logger_root":
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "handler_console":
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
if section == "formatter_generic":
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
except config.InterpolationMissingOptionError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
for section in categories:
|
|
||||||
try:
|
|
||||||
if configold.items(section):
|
|
||||||
confignew.add_section(section)
|
|
||||||
|
|
||||||
for option, value in configold.items(section):
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
except config.NoSectionError:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# create a backup of our old config
|
# create a backup of our old config
|
||||||
if os.path.isfile(config.CONFIG_FILE):
|
if os.path.isfile(config.CONFIG_FILE):
|
||||||
|
@ -160,55 +131,65 @@ class migratecfg:
|
||||||
def addnzbget(self):
|
def addnzbget(self):
|
||||||
confignew = config()
|
confignew = config()
|
||||||
section = "CouchPotato"
|
section = "CouchPotato"
|
||||||
envKeys = ['CATEGORY', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'METHOD', 'DELETE_FAILED', 'REMOTECPS', 'WAIT_FOR', 'TIMEPERGIB']
|
envCatKey = 'NZBPO_CPSCATEGORY'
|
||||||
cfgKeys = ['cpsCategory', 'apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'method', 'delete_failed', 'remoteCPS', 'wait_for', 'TimePerGiB']
|
envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'METHOD', 'DELETE_FAILED', 'REMOTECPS', 'WAIT_FOR', 'TIMEPERGIB']
|
||||||
|
cfgKeys = ['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):
|
||||||
option = cfgKeys[index]
|
option = cfgKeys[index]
|
||||||
value = os.environ[key]
|
value = os.environ[key]
|
||||||
confignew.set(section, option, value)
|
if confignew[section].has_key(os.environ[envCatKey]) and option not in confignew[section].sections:
|
||||||
|
confignew[section][envCatKey][option] = value
|
||||||
|
|
||||||
|
|
||||||
section = "SickBeard"
|
section = "SickBeard"
|
||||||
envKeys = ['CATEGORY', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 'DELAY', 'TIMEPERGIB', 'PROCESS_METHOD']
|
envCatKey = 'NZBPO_SBCATEGORY'
|
||||||
cfgKeys = ['sbCategory', 'host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 'delay', 'TimePerGiB', 'process_method']
|
envKeys = ['HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 'DELAY', 'TIMEPERGIB', 'PROCESS_METHOD']
|
||||||
|
cfgKeys = ['host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 'delay', 'TimePerGiB', 'process_method']
|
||||||
for index in range(len(envKeys)):
|
for index in range(len(envKeys)):
|
||||||
key = 'NZBPO_SB' + envKeys[index]
|
key = 'NZBPO_SB' + envKeys[index]
|
||||||
if os.environ.has_key(key):
|
if os.environ.has_key(key):
|
||||||
option = cfgKeys[index]
|
option = cfgKeys[index]
|
||||||
value = os.environ[key]
|
value = os.environ[key]
|
||||||
confignew.set(section, option, value)
|
if confignew[section].has_key(os.environ[envCatKey]) and option not in confignew[section].sections:
|
||||||
|
confignew[section][envCatKey][option] = value
|
||||||
|
|
||||||
section = "HeadPhones"
|
section = "HeadPhones"
|
||||||
envKeys = ['CATEGORY', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'TIMEPERGIB']
|
envCatKey = 'NZBPO_HPCATEGORY'
|
||||||
cfgKeys = ['hpCategory', 'apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'TimePerGiB']
|
envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'TIMEPERGIB']
|
||||||
|
cfgKeys = ['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):
|
||||||
option = cfgKeys[index]
|
option = cfgKeys[index]
|
||||||
value = os.environ[key]
|
value = os.environ[key]
|
||||||
confignew.set(section, option, value)
|
if confignew[section].has_key(os.environ[envCatKey]) and option not in confignew[section].sections:
|
||||||
|
confignew[section][envCatKey][option] = value
|
||||||
|
|
||||||
section = "Mylar"
|
section = "Mylar"
|
||||||
envKeys = ['CATEGORY', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT']
|
envCatKey = 'NZBPO_MYCATEGORY'
|
||||||
cfgKeys = ['mlCategory', 'host', 'port', 'username', 'password', 'ssl', 'web_root']
|
envKeys = ['HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT']
|
||||||
|
cfgKeys = ['host', 'port', 'username', 'password', 'ssl', 'web_root']
|
||||||
for index in range(len(envKeys)):
|
for index in range(len(envKeys)):
|
||||||
key = 'NZBPO_MY' + envKeys[index]
|
key = 'NZBPO_MY' + envKeys[index]
|
||||||
if os.environ.has_key(key):
|
if os.environ.has_key(key):
|
||||||
option = cfgKeys[index]
|
option = cfgKeys[index]
|
||||||
value = os.environ[key]
|
value = os.environ[key]
|
||||||
confignew.set(section, option, value)
|
if confignew[section].has_key(os.environ[envCatKey]) and option not in confignew[section].sections:
|
||||||
|
confignew[section][envCatKey][option] = value
|
||||||
|
|
||||||
section = "Gamez"
|
section = "Gamez"
|
||||||
envKeys = ['CATEGORY', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT']
|
envCatKey = 'NZBPO_GZCATEGORY'
|
||||||
cfgKeys = ['gzCategory', 'apikey', 'host', 'port', 'ssl', 'web_root']
|
envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT']
|
||||||
|
cfgKeys = ['apikey', 'host', 'port', 'ssl', 'web_root']
|
||||||
for index in range(len(envKeys)):
|
for index in range(len(envKeys)):
|
||||||
key = 'NZBPO_GZ' + envKeys[index]
|
key = 'NZBPO_GZ' + envKeys[index]
|
||||||
if os.environ.has_key(key):
|
if os.environ.has_key(key):
|
||||||
option = cfgKeys[index]
|
option = cfgKeys[index]
|
||||||
value = os.environ[key]
|
value = os.environ[key]
|
||||||
confignew.set(section, option, value)
|
if confignew[section].has_key(os.environ[envCatKey]) and option not in confignew[section].sections:
|
||||||
|
confignew[section][envCatKey][option] = value
|
||||||
|
|
||||||
section = "Extensions"
|
section = "Extensions"
|
||||||
envKeys = ['COMPRESSEDEXTENSIONS', 'MEDIAEXTENSIONS', 'METAEXTENSIONS']
|
envKeys = ['COMPRESSEDEXTENSIONS', 'MEDIAEXTENSIONS', 'METAEXTENSIONS']
|
||||||
|
@ -218,7 +199,7 @@ class migratecfg:
|
||||||
if os.environ.has_key(key):
|
if os.environ.has_key(key):
|
||||||
option = cfgKeys[index]
|
option = cfgKeys[index]
|
||||||
value = os.environ[key]
|
value = os.environ[key]
|
||||||
confignew.set(section, option, value)
|
confignew[section][option] = value
|
||||||
|
|
||||||
section = "Transcoder"
|
section = "Transcoder"
|
||||||
envKeys = ['TRANSCODE', 'DUPLICATE', 'IGNOREEXTENSIONS', 'OUTPUTVIDEOEXTENSION', 'OUTPUTVIDEOCODEC', 'OUTPUTVIDEOPRESET', 'OUTPUTVIDEOFRAMERATE', 'OUTPUTVIDEOBITRATE', 'OUTPUTAUDIOCODEC', 'OUTPUTAUDIOBITRATE', 'OUTPUTSUBTITLECODEC']
|
envKeys = ['TRANSCODE', 'DUPLICATE', 'IGNOREEXTENSIONS', 'OUTPUTVIDEOEXTENSION', 'OUTPUTVIDEOCODEC', 'OUTPUTVIDEOPRESET', 'OUTPUTVIDEOFRAMERATE', 'OUTPUTVIDEOBITRATE', 'OUTPUTAUDIOCODEC', 'OUTPUTAUDIOBITRATE', 'OUTPUTSUBTITLECODEC']
|
||||||
|
@ -228,7 +209,7 @@ class migratecfg:
|
||||||
if os.environ.has_key(key):
|
if os.environ.has_key(key):
|
||||||
option = cfgKeys[index]
|
option = cfgKeys[index]
|
||||||
value = os.environ[key]
|
value = os.environ[key]
|
||||||
confignew.set(section, option, value)
|
confignew[section][option] = value
|
||||||
|
|
||||||
section = "WakeOnLan"
|
section = "WakeOnLan"
|
||||||
envKeys = ['WAKE', 'HOST', 'PORT', 'MAC']
|
envKeys = ['WAKE', 'HOST', 'PORT', 'MAC']
|
||||||
|
@ -238,7 +219,7 @@ class migratecfg:
|
||||||
if os.environ.has_key(key):
|
if os.environ.has_key(key):
|
||||||
option = cfgKeys[index]
|
option = cfgKeys[index]
|
||||||
value = os.environ[key]
|
value = os.environ[key]
|
||||||
confignew.set(section, option, value)
|
confignew[section][option] = value
|
||||||
|
|
||||||
# create a backup of our old config
|
# create a backup of our old config
|
||||||
if os.path.isfile(config.CONFIG_FILE):
|
if os.path.isfile(config.CONFIG_FILE):
|
||||||
|
|
|
@ -5,33 +5,37 @@ from lib import requests
|
||||||
|
|
||||||
from nzbToMediaConfig import config
|
from nzbToMediaConfig import config
|
||||||
|
|
||||||
def autoFork(section):
|
def autoFork(section, category):
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
Logger = logging.getLogger()
|
||||||
|
|
||||||
# config settings
|
# config settings
|
||||||
host = config().get(section, "host")
|
try:
|
||||||
port = config().get(section, "port")
|
host = config()[section][category]["host"]
|
||||||
|
port = config()[section][category]["port"]
|
||||||
|
except:
|
||||||
|
host = None
|
||||||
|
port = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
username = config().get(section, "username")
|
username = config()[section][category]["username"]
|
||||||
password = config().get(section, "password")
|
password = config()[section][category]["password"]
|
||||||
except:
|
except:
|
||||||
username = None
|
username = None
|
||||||
password = None
|
password = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ssl = int(config().get(section, "ssl"))
|
ssl = int(config()[section][category]["ssl"])
|
||||||
except (config.NoOptionError, ValueError):
|
except (config, ValueError):
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = config().get(section, "web_root")
|
web_root = config()[section][category]["web_root"]
|
||||||
except config.NoOptionError:
|
except config:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fork = config.FORKS.items()[config.FORKS.keys().index(config().get(section, "fork"))]
|
fork = config.FORKS.items()[config.FORKS.keys().index(config()[section][category]["fork"])]
|
||||||
except:
|
except:
|
||||||
fork = "auto"
|
fork = "auto"
|
||||||
|
|
||||||
|
@ -53,7 +57,7 @@ def autoFork(section):
|
||||||
else:
|
else:
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
Logger.info("Could not connect to " + section + " to perform auto-fork detection!")
|
Logger.info("Could not connect to " + section + ":" + category + " to perform auto-fork detection!")
|
||||||
break
|
break
|
||||||
|
|
||||||
if r.ok:
|
if r.ok:
|
||||||
|
@ -61,10 +65,10 @@ def autoFork(section):
|
||||||
break
|
break
|
||||||
|
|
||||||
if detected:
|
if detected:
|
||||||
Logger.info("" + section + " fork auto-detection successful ...")
|
Logger.info("" + section + ":" + category + " fork auto-detection successful ...")
|
||||||
else:
|
else:
|
||||||
Logger.info("" + section + " fork auto-detection failed")
|
Logger.info("" + section + ":" + category + " fork auto-detection failed")
|
||||||
fork = config.FORKS.items()[config.FORKS.keys().index(config.FORK_DEFAULT)]
|
fork = config.FORKS.items()[config.FORKS.keys().index(config.FORK_DEFAULT)]
|
||||||
|
|
||||||
Logger.info("" + section + " fork set to %s", fork[0])
|
Logger.info("" + section + ":" + category + " fork set to %s", fork[0])
|
||||||
return fork[0], fork[1]
|
return fork[0], fork[1]
|
|
@ -1,5 +1,5 @@
|
||||||
import os
|
import os
|
||||||
import ConfigParser
|
from lib import configobj
|
||||||
|
|
||||||
class config(object):
|
class config(object):
|
||||||
# constants for nzbtomedia
|
# constants for nzbtomedia
|
||||||
|
@ -34,28 +34,32 @@ class config(object):
|
||||||
MOVIE_CONFIG_FILE = os.path.join(PROGRAM_DIR, "autoProcessMovie.cfg")
|
MOVIE_CONFIG_FILE = os.path.join(PROGRAM_DIR, "autoProcessMovie.cfg")
|
||||||
TV_CONFIG_FILE = os.path.join(PROGRAM_DIR, "autoProcessTv.cfg")
|
TV_CONFIG_FILE = os.path.join(PROGRAM_DIR, "autoProcessTv.cfg")
|
||||||
LOG_FILE = os.path.join(PROGRAM_DIR, "postprocess.log")
|
LOG_FILE = os.path.join(PROGRAM_DIR, "postprocess.log")
|
||||||
|
LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg")
|
||||||
|
|
||||||
# config error handling classes
|
def __new__(cls, *config_file):
|
||||||
Error = ConfigParser.Error
|
try:
|
||||||
NoSectionError = ConfigParser.NoSectionError
|
# load config
|
||||||
NoOptionError = ConfigParser.NoOptionError
|
if not config_file:
|
||||||
DuplicateSectionError = ConfigParser.DuplicateSectionError
|
return configobj.ConfigObj(cls.CONFIG_FILE)
|
||||||
InterpolationError = ConfigParser.InterpolationError
|
else:
|
||||||
InterpolationMissingOptionError = ConfigParser.InterpolationMissingOptionError
|
return configobj.ConfigObj(*config_file)
|
||||||
InterpolationSyntaxError = ConfigParser.InterpolationSyntaxError
|
except Exception, e:
|
||||||
InterpolationDepthError = ConfigParser.InterpolationDepthError
|
return
|
||||||
ParsingError = ConfigParser.ParsingError
|
|
||||||
MissingSectionHeaderError = ConfigParser.MissingSectionHeaderError
|
|
||||||
|
|
||||||
def __new__(cls, *file):
|
|
||||||
if not file:
|
|
||||||
file = cls.CONFIG_FILE
|
|
||||||
return cls.loadConfig(file)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def loadConfig(file):
|
def get_categories(section):
|
||||||
# load config
|
sections = {}
|
||||||
config = ConfigParser.ConfigParser()
|
|
||||||
config.optionxform = str
|
# check and return categories if section does exist
|
||||||
if config.read(file):
|
if not isinstance(section, list):
|
||||||
return config
|
section = [section]
|
||||||
|
|
||||||
|
for x in section:
|
||||||
|
if config().has_key(x):
|
||||||
|
sections.update({x: config()[x].sections})
|
||||||
|
return sections
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def gather_subsection(section, key):
|
||||||
|
if section.depth > 1:
|
||||||
|
return section.name
|
|
@ -32,7 +32,8 @@ def safeName(name):
|
||||||
def nzbtomedia_configure_logging(logfile=None):
|
def nzbtomedia_configure_logging(logfile=None):
|
||||||
if not logfile:
|
if not logfile:
|
||||||
logfile = config.LOG_FILE
|
logfile = config.LOG_FILE
|
||||||
logging.config.fileConfig(config.CONFIG_FILE)
|
|
||||||
|
logging.config.fileConfig(config.LOG_CONFIG)
|
||||||
fileHandler = logging.handlers.RotatingFileHandler(logfile, mode='a', maxBytes=1048576, backupCount=1, encoding='utf-8', delay=True)
|
fileHandler = logging.handlers.RotatingFileHandler(logfile, mode='a', maxBytes=1048576, backupCount=1, encoding='utf-8', delay=True)
|
||||||
fileHandler.formatter = logging.Formatter('%(asctime)s|%(levelname)-7.7s %(message)s', '%H:%M:%S')
|
fileHandler.formatter = logging.Formatter('%(asctime)s|%(levelname)-7.7s %(message)s', '%H:%M:%S')
|
||||||
fileHandler.level = logging.DEBUG
|
fileHandler.level = logging.DEBUG
|
||||||
|
@ -329,14 +330,14 @@ def WakeUp():
|
||||||
Logger.error("You need an autoProcessMedia.config() file - did you rename and edit the .sample?")
|
Logger.error("You need an autoProcessMedia.config() file - did you rename and edit the .sample?")
|
||||||
return
|
return
|
||||||
|
|
||||||
wake = int(config().get("WakeOnLan", "wake"))
|
wake = int(config()["WakeOnLan"]["wake"])
|
||||||
if wake == 0: # just return if we don't need to wake anything.
|
if wake == 0: # just return if we don't need to wake anything.
|
||||||
return
|
return
|
||||||
Logger.info("Loading WakeOnLan config from %s", config.CONFIG_FILE)
|
Logger.info("Loading WakeOnLan config from %s", config.CONFIG_FILE)
|
||||||
config().get("WakeOnLan", "host")
|
config()["WakeOnLan"]["host"]
|
||||||
host = config().get("WakeOnLan", "host")
|
host = config()["WakeOnLan"]["host"]
|
||||||
port = int(config().get("WakeOnLan", "port"))
|
port = int(config()["WakeOnLan"]["port"])
|
||||||
mac = config().get("WakeOnLan", "mac")
|
mac = config()["WakeOnLan"]["mac"]
|
||||||
|
|
||||||
i=1
|
i=1
|
||||||
while TestCon(host, port) == "Down" and i < 4:
|
while TestCon(host, port) == "Down" and i < 4:
|
||||||
|
@ -355,7 +356,7 @@ def convert_to_ascii(nzbName, dirName):
|
||||||
Logger.error("You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
|
Logger.error("You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
|
||||||
return nzbName, dirName
|
return nzbName, dirName
|
||||||
|
|
||||||
ascii_convert = int(config().get("ASCII", "convert"))
|
ascii_convert = int(config()["ASCII"]["convert"])
|
||||||
if ascii_convert == 0 or os.name == 'nt': # just return if we don't want to convert or on windows os and "\" is replaced!.
|
if ascii_convert == 0 or os.name == 'nt': # just return if we don't want to convert or on windows os and "\" is replaced!.
|
||||||
return nzbName, dirName
|
return nzbName, dirName
|
||||||
|
|
||||||
|
@ -452,12 +453,12 @@ def parse_args(clientAgent):
|
||||||
|
|
||||||
def get_dirnames(section, category):
|
def get_dirnames(section, category):
|
||||||
try:
|
try:
|
||||||
watch_dir = config().get(section, "watch_dir")
|
watch_dir = config()[section][inputCategory]["watch_dir"]
|
||||||
except config.NoOptionError:
|
except:
|
||||||
watch_dir = ""
|
watch_dir = ""
|
||||||
try:
|
try:
|
||||||
outputDirectory = os.path.join(config().get("Torrent", "outputDirectory"), category)
|
outputDirectory = os.path.join(config()["Torrent"]["outputDirectory"], category)
|
||||||
except config.NoOptionError:
|
except:
|
||||||
outputDirectory = ""
|
outputDirectory = ""
|
||||||
|
|
||||||
# set dirName
|
# set dirName
|
||||||
|
@ -481,4 +482,4 @@ def delete(dirName):
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(dirName, True)
|
shutil.rmtree(dirName, True)
|
||||||
except:
|
except:
|
||||||
Logger.exception("Unable to delete folder %s", dirName)
|
Logger.exception("Unable to delete folder %s", dirName)
|
Loading…
Add table
Add a link
Reference in a new issue