mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-15 01:32:53 -07:00
Added in a config class to access main config properly and now can be called from anywhere in the code by creating a instance.
Re-coded migratecfg, vast improvements made and code cleanup of unrequired checks. Fixed numerous small bugs throughout nzbToMedia including possible calls to variables that may not have been created do to conditional statements.
This commit is contained in:
parent
08bd4584d8
commit
6d45257035
29 changed files with 348 additions and 543 deletions
|
@ -81,7 +81,7 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
|
||||||
os.utime(filepath, None)
|
os.utime(filepath, None)
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
print "Error: unable to reset time for file", filePath
|
print "Error: unable to reset time for file", file
|
||||||
sys.exit(POSTPROCESS_ERROR)
|
sys.exit(POSTPROCESS_ERROR)
|
||||||
sys.exit(POSTPROCESS_SUCCESS)
|
sys.exit(POSTPROCESS_SUCCESS)
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
#System imports
|
#System imports
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import ConfigParser
|
|
||||||
import shutil
|
|
||||||
import logging
|
import logging
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
from subprocess import Popen
|
||||||
import re
|
|
||||||
from subprocess import call, Popen
|
|
||||||
|
|
||||||
# Custom imports
|
# Custom imports
|
||||||
import autoProcess.migratecfg as migratecfg
|
import autoProcess.migratecfg as migratecfg
|
||||||
|
@ -450,69 +444,65 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
WakeUp()
|
WakeUp()
|
||||||
|
|
||||||
config = ConfigParser.ConfigParser()
|
if not config():
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
|
|
||||||
if not os.path.isfile(configFilename):
|
|
||||||
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?")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# CONFIG FILE
|
# CONFIG FILE
|
||||||
Logger.info("MAIN: Loading config from %s", configFilename)
|
Logger.info("MAIN: Loading config from %s", CONFIG_FILE)
|
||||||
config.read(configFilename)
|
|
||||||
# EXAMPLE VALUES:
|
# EXAMPLE VALUES:
|
||||||
clientAgent = config.get("Torrent", "clientAgent") # utorrent | deluge | transmission | rtorrent | other
|
clientAgent = config().get("Torrent", "clientAgent") # utorrent | deluge | transmission | rtorrent | other
|
||||||
useLink_in = config.get("Torrent", "useLink") # no | hard | sym
|
useLink_in = config().get("Torrent", "useLink") # no | hard | sym
|
||||||
outputDirectory = config.get("Torrent", "outputDirectory") # /abs/path/to/complete/
|
outputDirectory = config().get("Torrent", "outputDirectory") # /abs/path/to/complete/
|
||||||
categories = (config.get("Torrent", "categories")).split(',') # music,music_videos,pictures,software
|
categories = (config().get("Torrent", "categories")).split(',') # music,music_videos,pictures,software
|
||||||
noFlatten = (config.get("Torrent", "noFlatten")).split(',')
|
noFlatten = (config().get("Torrent", "noFlatten")).split(',')
|
||||||
|
|
||||||
uTorrentWEBui = config.get("Torrent", "uTorrentWEBui") # http://localhost:8090/gui/
|
uTorrentWEBui = config().get("Torrent", "uTorrentWEBui") # http://localhost:8090/gui/
|
||||||
uTorrentUSR = config.get("Torrent", "uTorrentUSR") # mysecretusr
|
uTorrentUSR = config().get("Torrent", "uTorrentUSR") # mysecretusr
|
||||||
uTorrentPWD = config.get("Torrent", "uTorrentPWD") # mysecretpwr
|
uTorrentPWD = config().get("Torrent", "uTorrentPWD") # mysecretpwr
|
||||||
|
|
||||||
TransmissionHost = config.get("Torrent", "TransmissionHost") # localhost
|
TransmissionHost = config().get("Torrent", "TransmissionHost") # localhost
|
||||||
TransmissionPort = config.get("Torrent", "TransmissionPort") # 8084
|
TransmissionPort = config().get("Torrent", "TransmissionPort") # 8084
|
||||||
TransmissionUSR = config.get("Torrent", "TransmissionUSR") # mysecretusr
|
TransmissionUSR = config().get("Torrent", "TransmissionUSR") # mysecretusr
|
||||||
TransmissionPWD = config.get("Torrent", "TransmissionPWD") # mysecretpwr
|
TransmissionPWD = config().get("Torrent", "TransmissionPWD") # mysecretpwr
|
||||||
|
|
||||||
DelugeHost = config.get("Torrent", "DelugeHost") # localhost
|
DelugeHost = config().get("Torrent", "DelugeHost") # localhost
|
||||||
DelugePort = config.get("Torrent", "DelugePort") # 8084
|
DelugePort = config().get("Torrent", "DelugePort") # 8084
|
||||||
DelugeUSR = config.get("Torrent", "DelugeUSR") # mysecretusr
|
DelugeUSR = config().get("Torrent", "DelugeUSR") # mysecretusr
|
||||||
DelugePWD = config.get("Torrent", "DelugePWD") # mysecretpwr
|
DelugePWD = config().get("Torrent", "DelugePWD") # mysecretpwr
|
||||||
|
|
||||||
deleteOriginal = int(config.get("Torrent", "deleteOriginal")) # 0
|
deleteOriginal = int(config().get("Torrent", "deleteOriginal")) # 0
|
||||||
forceClean = int(config.get("Torrent", "forceClean")) # 0
|
forceClean = int(config().get("Torrent", "forceClean")) # 0
|
||||||
|
|
||||||
compressedContainer = (config.get("Extensions", "compressedExtensions")).split(',') # .zip,.rar,.7z
|
compressedContainer = (config().get("Extensions", "compressedExtensions")).split(',') # .zip,.rar,.7z
|
||||||
mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',') # .mkv,.avi,.divx
|
mediaContainer = (config().get("Extensions", "mediaExtensions")).split(',') # .mkv,.avi,.divx
|
||||||
metaContainer = (config.get("Extensions", "metaExtensions")).split(',') # .nfo,.sub,.srt
|
metaContainer = (config().get("Extensions", "metaExtensions")).split(',') # .nfo,.sub,.srt
|
||||||
minSampleSize = int(config.get("Extensions", "minSampleSize")) # 200 (in MB)
|
minSampleSize = int(config().get("Extensions", "minSampleSize")) # 200 (in MB)
|
||||||
SampleIDs = (config.get("Extensions", "SampleIDs")).split(',') # sample,-s.
|
SampleIDs = (config().get("Extensions", "SampleIDs")).split(',') # sample,-s.
|
||||||
|
|
||||||
cpsCategory = (config.get("CouchPotato", "cpsCategory")).split(',') # movie
|
cpsCategory = (config().get("CouchPotato", "cpsCategory")).split(',') # movie
|
||||||
sbCategory = (config.get("SickBeard", "sbCategory")).split(',') # tv
|
sbCategory = (config().get("SickBeard", "sbCategory")).split(',') # tv
|
||||||
Torrent_ForceLink = int(config.get("SickBeard", "Torrent_ForceLink")) # 1
|
Torrent_ForceLink = int(config().get("SickBeard", "Torrent_ForceLink")) # 1
|
||||||
hpCategory = (config.get("HeadPhones", "hpCategory")).split(',') # music
|
hpCategory = (config().get("HeadPhones", "hpCategory")).split(',') # music
|
||||||
mlCategory = (config.get("Mylar", "mlCategory")).split(',') # comics
|
mlCategory = (config().get("Mylar", "mlCategory")).split(',') # comics
|
||||||
gzCategory = (config.get("Gamez", "gzCategory")).split(',') # games
|
gzCategory = (config().get("Gamez", "gzCategory")).split(',') # games
|
||||||
categories.extend(cpsCategory)
|
categories.extend(cpsCategory)
|
||||||
categories.extend(sbCategory)
|
categories.extend(sbCategory)
|
||||||
categories.extend(hpCategory)
|
categories.extend(hpCategory)
|
||||||
categories.extend(mlCategory)
|
categories.extend(mlCategory)
|
||||||
categories.extend(gzCategory)
|
categories.extend(gzCategory)
|
||||||
|
|
||||||
user_script_categories = config.get("UserScript", "user_script_categories").split(',') # NONE
|
user_script_categories = config().get("UserScript", "user_script_categories").split(',') # 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().get("UserScript", "user_script_mediaExtensions")).split(',')
|
||||||
user_script = config.get("UserScript", "user_script_path")
|
user_script = config().get("UserScript", "user_script_path")
|
||||||
user_script_param = (config.get("UserScript", "user_script_param")).split(',')
|
user_script_param = (config().get("UserScript", "user_script_param")).split(',')
|
||||||
user_script_successCodes = (config.get("UserScript", "user_script_successCodes")).split(',')
|
user_script_successCodes = (config().get("UserScript", "user_script_successCodes")).split(',')
|
||||||
user_script_clean = int(config.get("UserScript", "user_script_clean"))
|
user_script_clean = int(config().get("UserScript", "user_script_clean"))
|
||||||
user_delay = int(config.get("UserScript", "delay"))
|
user_delay = int(config().get("UserScript", "delay"))
|
||||||
user_script_runOnce = int(config.get("UserScript", "user_script_runOnce"))
|
user_script_runOnce = int(config().get("UserScript", "user_script_runOnce"))
|
||||||
|
|
||||||
transcode = int(config.get("Transcoder", "transcode"))
|
transcode = int(config().get("Transcoder", "transcode"))
|
||||||
|
|
||||||
n = 0
|
n = 0
|
||||||
for arg in sys.argv:
|
for arg in sys.argv:
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
import ConfigParser
|
|
||||||
import logging
|
import logging
|
||||||
import errno
|
import errno
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
|
|
||||||
|
from nzbToMediaConfig import *
|
||||||
|
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
Logger = logging.getLogger()
|
||||||
|
|
||||||
def Transcode_directory(dirName):
|
def Transcode_directory(dirName):
|
||||||
|
@ -29,31 +30,27 @@ def Transcode_directory(dirName):
|
||||||
ffmpeg = 'ffmpeg'
|
ffmpeg = 'ffmpeg'
|
||||||
useNiceness = True
|
useNiceness = True
|
||||||
|
|
||||||
config = ConfigParser.ConfigParser()
|
Logger.info("Loading config from %s", CONFIG_FILE)
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
Logger.info("Loading config from %s", configFilename)
|
|
||||||
|
|
||||||
if not os.path.isfile(configFilename):
|
if not config():
|
||||||
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
|
||||||
|
|
||||||
config.read(configFilename)
|
mediaContainer = (config().get("Extensions", "mediaExtensions")).split(',')
|
||||||
|
duplicate = int(config().get("Transcoder", "duplicate"))
|
||||||
mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',')
|
ignoreExtensions = (config().get("Transcoder", "ignoreExtensions")).split(',')
|
||||||
duplicate = int(config.get("Transcoder", "duplicate"))
|
outputVideoExtension = config().get("Transcoder", "outputVideoExtension").strip()
|
||||||
ignoreExtensions = (config.get("Transcoder", "ignoreExtensions")).split(',')
|
outputVideoCodec = config().get("Transcoder", "outputVideoCodec").strip()
|
||||||
outputVideoExtension = config.get("Transcoder", "outputVideoExtension").strip()
|
outputVideoPreset = config().get("Transcoder", "outputVideoPreset").strip()
|
||||||
outputVideoCodec = config.get("Transcoder", "outputVideoCodec").strip()
|
outputVideoFramerate = config().get("Transcoder", "outputVideoFramerate").strip()
|
||||||
outputVideoPreset = config.get("Transcoder", "outputVideoPreset").strip()
|
outputVideoBitrate = config().get("Transcoder", "outputVideoBitrate").strip()
|
||||||
outputVideoFramerate = config.get("Transcoder", "outputVideoFramerate").strip()
|
outputAudioCodec = config().get("Transcoder", "outputAudioCodec").strip()
|
||||||
outputVideoBitrate = config.get("Transcoder", "outputVideoBitrate").strip()
|
outputAudioBitrate = config().get("Transcoder", "outputAudioBitrate").strip()
|
||||||
outputAudioCodec = config.get("Transcoder", "outputAudioCodec").strip()
|
outputSubtitleCodec = config().get("Transcoder", "outputSubtitleCodec").strip()
|
||||||
outputAudioBitrate = config.get("Transcoder", "outputAudioBitrate").strip()
|
outputFastStart = int(config().get("Transcoder", "outputFastStart"))
|
||||||
outputSubtitleCodec = config.get("Transcoder", "outputSubtitleCodec").strip()
|
outputQualityPercent = int(config().get("Transcoder", "outputQualityPercent"))
|
||||||
outputFastStart = int(config.get("Transcoder", "outputFastStart"))
|
|
||||||
outputQualityPercent = int(config.get("Transcoder", "outputQualityPercent"))
|
|
||||||
if useNiceness:
|
if useNiceness:
|
||||||
niceness = int(config.get("Transcoder", "niceness"))
|
niceness = int(config().get("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)
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
import sys
|
|
||||||
import urllib
|
import urllib
|
||||||
import os.path
|
|
||||||
import time
|
|
||||||
import ConfigParser
|
|
||||||
import logging
|
import logging
|
||||||
import socket
|
|
||||||
|
|
||||||
from nzbToMediaEnv import *
|
from nzbToMediaEnv import *
|
||||||
from nzbToMediaUtil import *
|
from nzbToMediaUtil import *
|
||||||
from nzbToMediaSceneExceptions import process_all_exceptions
|
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
Logger = logging.getLogger()
|
||||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||||
|
@ -34,36 +29,36 @@ class AuthURLOpener(urllib.FancyURLopener):
|
||||||
|
|
||||||
def processEpisode(dirName, nzbName=None, status=0, inputCategory=None):
|
def processEpisode(dirName, nzbName=None, status=0, inputCategory=None):
|
||||||
|
|
||||||
config = ConfigParser.ConfigParser()
|
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
Logger.info("Loading config from %s", configFilename)
|
|
||||||
|
|
||||||
if not os.path.isfile(configFilename):
|
|
||||||
|
Logger.info("Loading config from %s", CONFIG_FILE)
|
||||||
|
|
||||||
|
if not config():
|
||||||
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
|
||||||
|
|
||||||
config.read(configFilename)
|
|
||||||
|
|
||||||
section = "Mylar"
|
section = "Mylar"
|
||||||
if inputCategory != None and config.has_section(inputCategory):
|
if inputCategory != None and config().has_section(inputCategory):
|
||||||
section = inputCategory
|
section = inputCategory
|
||||||
host = config.get(section, "host")
|
host = config().get(section, "host")
|
||||||
port = config.get(section, "port")
|
port = config().get(section, "port")
|
||||||
username = config.get(section, "username")
|
username = config().get(section, "username")
|
||||||
password = config.get(section, "password")
|
password = config().get(section, "password")
|
||||||
try:
|
try:
|
||||||
ssl = int(config.get(section, "ssl"))
|
ssl = int(config().get(section, "ssl"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = config.get(section, "web_root")
|
web_root = config().get(section, "web_root")
|
||||||
except ConfigParser.NoOptionError:
|
except config.NoOptionError:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
watch_dir = config.get(section, "watch_dir")
|
watch_dir = config().get(section, "watch_dir")
|
||||||
except ConfigParser.NoOptionError:
|
except config.NoOptionError:
|
||||||
watch_dir = ""
|
watch_dir = ""
|
||||||
params = {}
|
params = {}
|
||||||
|
|
||||||
|
|
|
@ -1,49 +1,43 @@
|
||||||
import sys
|
|
||||||
import urllib
|
import urllib
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import ConfigParser
|
|
||||||
import datetime
|
|
||||||
import time
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import socket
|
|
||||||
|
|
||||||
from nzbToMediaEnv import *
|
from nzbToMediaEnv import *
|
||||||
from nzbToMediaUtil import *
|
from nzbToMediaUtil import *
|
||||||
|
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
Logger = logging.getLogger()
|
||||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||||
|
|
||||||
def process(dirName, nzbName=None, status=0, inputCategory=None):
|
def process(dirName, nzbName=None, status=0, inputCategory=None):
|
||||||
|
|
||||||
status = int(status)
|
status = int(status)
|
||||||
config = ConfigParser.ConfigParser()
|
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
Logger.info("Loading config from %s", configFilename)
|
|
||||||
|
|
||||||
if not os.path.isfile(configFilename):
|
|
||||||
|
Logger.info("Loading config from %s", CONFIG_FILE)
|
||||||
|
|
||||||
|
if not config():
|
||||||
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
|
||||||
|
|
||||||
config.read(configFilename)
|
|
||||||
|
|
||||||
section = "Gamez"
|
section = "Gamez"
|
||||||
if inputCategory != None and config.has_section(inputCategory):
|
if inputCategory != None and config().has_section(inputCategory):
|
||||||
section = inputCategory
|
section = inputCategory
|
||||||
|
|
||||||
host = config.get(section, "host")
|
host = config().get(section, "host")
|
||||||
port = config.get(section, "port")
|
port = config().get(section, "port")
|
||||||
apikey = config.get(section, "apikey")
|
apikey = config().get(section, "apikey")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ssl = int(config.get(section, "ssl"))
|
ssl = int(config().get(section, "ssl"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = config.get(section, "web_root")
|
web_root = config().get(section, "web_root")
|
||||||
except ConfigParser.NoOptionError:
|
except config.NoOptionError:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
if ssl:
|
if ssl:
|
||||||
|
|
|
@ -1,19 +1,14 @@
|
||||||
import sys
|
|
||||||
import urllib
|
import urllib
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import ConfigParser
|
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import socket
|
|
||||||
|
|
||||||
import Transcoder
|
import Transcoder
|
||||||
from nzbToMediaEnv import *
|
from nzbToMediaEnv import *
|
||||||
from nzbToMediaUtil import *
|
from nzbToMediaUtil import *
|
||||||
from nzbToMediaSceneExceptions import process_all_exceptions
|
from nzbToMediaSceneExceptions import process_all_exceptions
|
||||||
|
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
Logger = logging.getLogger()
|
||||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||||
|
|
||||||
|
@ -130,7 +125,7 @@ def get_movie_info(baseURL, imdbid, download_id):
|
||||||
return movie_id, imdbid, download_id, movie_status, release_status
|
return movie_id, imdbid, download_id, movie_status, release_status
|
||||||
|
|
||||||
def get_status(baseURL, movie_id, download_id):
|
def get_status(baseURL, movie_id, download_id):
|
||||||
|
result = None
|
||||||
movie_status = None
|
movie_status = None
|
||||||
release_status = None
|
release_status = None
|
||||||
if not movie_id:
|
if not movie_id:
|
||||||
|
@ -151,6 +146,7 @@ def get_status(baseURL, movie_id, download_id):
|
||||||
Logger.debug("This movie is marked as status %s in CouchPotatoServer", movie_status)
|
Logger.debug("This movie is marked as status %s in CouchPotatoServer", movie_status)
|
||||||
except:
|
except:
|
||||||
Logger.exception("Could not find a status for this movie")
|
Logger.exception("Could not find a status for this movie")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if len(result["media"]["releases"]) == 1 and result["media"]["releases"][0]["status"] == "done":
|
if len(result["media"]["releases"]) == 1 and result["media"]["releases"][0]["status"] == "done":
|
||||||
release_status = result["media"]["releases"][0]["status"]
|
release_status = result["media"]["releases"][0]["status"]
|
||||||
|
@ -167,46 +163,43 @@ def get_status(baseURL, movie_id, download_id):
|
||||||
def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id = "", inputCategory=None):
|
def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id = "", inputCategory=None):
|
||||||
|
|
||||||
status = int(status)
|
status = int(status)
|
||||||
config = ConfigParser.ConfigParser()
|
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
Logger.info("Loading config from %s", configFilename)
|
|
||||||
|
|
||||||
if not os.path.isfile(configFilename):
|
Logger.info("Loading config from %s", CONFIG_FILE)
|
||||||
|
|
||||||
|
if not config():
|
||||||
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
|
||||||
|
|
||||||
config.read(configFilename)
|
|
||||||
|
|
||||||
section = "CouchPotato"
|
section = "CouchPotato"
|
||||||
if inputCategory != None and config.has_section(inputCategory):
|
if inputCategory != None and config().has_section(inputCategory):
|
||||||
section = inputCategory
|
section = inputCategory
|
||||||
|
|
||||||
host = config.get(section, "host")
|
host = config().get(section, "host")
|
||||||
port = config.get(section, "port")
|
port = config().get(section, "port")
|
||||||
apikey = config.get(section, "apikey")
|
apikey = config().get(section, "apikey")
|
||||||
delay = float(config.get(section, "delay"))
|
delay = float(config().get(section, "delay"))
|
||||||
method = config.get(section, "method")
|
method = config().get(section, "method")
|
||||||
delete_failed = int(config.get(section, "delete_failed"))
|
delete_failed = int(config().get(section, "delete_failed"))
|
||||||
wait_for = int(config.get(section, "wait_for"))
|
wait_for = int(config().get(section, "wait_for"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ssl = int(config.get(section, "ssl"))
|
ssl = int(config().get(section, "ssl"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = config.get(section, "web_root")
|
web_root = config().get(section, "web_root")
|
||||||
except ConfigParser.NoOptionError:
|
except config.NoOptionError:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
transcode = int(config.get("Transcoder", "transcode"))
|
transcode = int(config().get("Transcoder", "transcode"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
transcode = 0
|
transcode = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
remoteCPS = int(config.get(section, "remoteCPS"))
|
remoteCPS = int(config().get(section, "remoteCPS"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
remoteCPS = 0
|
remoteCPS = 0
|
||||||
|
|
||||||
nzbName = str(nzbName) # make sure it is a string
|
nzbName = str(nzbName) # make sure it is a string
|
||||||
|
@ -312,6 +305,7 @@ def process(dirName, nzbName=None, status=0, clientAgent = "manual", download_id
|
||||||
# we will now check to see if CPS has finished renaming before returning to TorrentToMedia and unpausing.
|
# we will now check to see if CPS has finished renaming before returning to TorrentToMedia and unpausing.
|
||||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||||
|
|
||||||
|
release_status = None
|
||||||
start = datetime.datetime.now() # set time for timeout
|
start = datetime.datetime.now() # set time for timeout
|
||||||
pause_for = int(wait_for) * 10 # keep this so we only ever have 6 complete loops. This may not be necessary now?
|
pause_for = int(wait_for) * 10 # keep this so we only ever have 6 complete loops. This may not be necessary now?
|
||||||
while (datetime.datetime.now() - start) < datetime.timedelta(minutes=wait_for): # only wait 2 (default) minutes, then return.
|
while (datetime.datetime.now() - start) < datetime.timedelta(minutes=wait_for): # only wait 2 (default) minutes, then return.
|
||||||
|
|
|
@ -1,50 +1,44 @@
|
||||||
import sys
|
|
||||||
import urllib
|
import urllib
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import ConfigParser
|
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
|
||||||
import json
|
|
||||||
import logging
|
import logging
|
||||||
import socket
|
|
||||||
|
|
||||||
from nzbToMediaEnv import *
|
from nzbToMediaEnv import *
|
||||||
from nzbToMediaUtil import *
|
from nzbToMediaUtil import *
|
||||||
|
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
Logger = logging.getLogger()
|
||||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||||
|
|
||||||
def process(dirName, nzbName=None, status=0, inputCategory=None):
|
def process(dirName, nzbName=None, status=0, inputCategory=None):
|
||||||
|
|
||||||
status = int(status)
|
status = int(status)
|
||||||
config = ConfigParser.ConfigParser()
|
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
Logger.info("Loading config from %s", configFilename)
|
|
||||||
|
|
||||||
if not os.path.isfile(configFilename):
|
|
||||||
|
Logger.info("Loading config from %s", CONFIG_FILE)
|
||||||
|
|
||||||
|
if not config():
|
||||||
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
|
||||||
|
|
||||||
config.read(configFilename)
|
|
||||||
|
|
||||||
section = "HeadPhones"
|
section = "HeadPhones"
|
||||||
if inputCategory != None and config.has_section(inputCategory):
|
if inputCategory != None and config().has_section(inputCategory):
|
||||||
section = inputCategory
|
section = inputCategory
|
||||||
|
|
||||||
host = config.get(section, "host")
|
host = config().get(section, "host")
|
||||||
port = config.get(section, "port")
|
port = config().get(section, "port")
|
||||||
apikey = config.get(section, "apikey")
|
apikey = config().get(section, "apikey")
|
||||||
delay = float(config.get(section, "delay"))
|
delay = float(config().get(section, "delay"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ssl = int(config.get(section, "ssl"))
|
ssl = int(config().get(section, "ssl"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = config.get(section, "web_root")
|
web_root = config().get(section, "web_root")
|
||||||
except ConfigParser.NoOptionError:
|
except config.NoOptionError:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
if ssl:
|
if ssl:
|
||||||
|
|
|
@ -3,10 +3,10 @@ import logging
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import Transcoder
|
import Transcoder
|
||||||
from nzbToMediaEnv import *
|
|
||||||
from nzbToMediaUtil import *
|
|
||||||
from nzbToMediaSceneExceptions import process_all_exceptions
|
from nzbToMediaSceneExceptions import process_all_exceptions
|
||||||
from autoProcess.autoSickBeardFork import autoFork
|
from autoProcess.autoSickBeardFork import autoFork
|
||||||
|
from nzbToMediaEnv import *
|
||||||
|
from nzbToMediaUtil import *
|
||||||
|
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
Logger = logging.getLogger()
|
||||||
|
@ -40,72 +40,72 @@ def delete(dirName):
|
||||||
def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputCategory=None):
|
def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputCategory=None):
|
||||||
|
|
||||||
status = int(failed)
|
status = int(failed)
|
||||||
config = ConfigParser.ConfigParser()
|
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
Logger.info("Loading config from %s", configFilename)
|
|
||||||
|
|
||||||
if not os.path.isfile(configFilename):
|
|
||||||
|
Logger.info("Loading config from %s", CONFIG_FILE)
|
||||||
|
|
||||||
|
if not config():
|
||||||
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
|
||||||
|
|
||||||
config.read(configFilename)
|
|
||||||
|
|
||||||
section = "SickBeard"
|
section = "SickBeard"
|
||||||
if inputCategory != None and config.has_section(inputCategory):
|
if inputCategory != None and config().has_section(inputCategory):
|
||||||
section = inputCategory
|
section = inputCategory
|
||||||
|
|
||||||
watch_dir = ""
|
watch_dir = ""
|
||||||
host = config.get(section, "host")
|
host = config().get(section, "host")
|
||||||
port = config.get(section, "port")
|
port = config().get(section, "port")
|
||||||
username = config.get(section, "username")
|
username = config().get(section, "username")
|
||||||
password = config.get(section, "password")
|
password = config().get(section, "password")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ssl = int(config.get(section, "ssl"))
|
ssl = int(config().get(section, "ssl"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
ssl = 0
|
ssl = 0
|
||||||
try:
|
try:
|
||||||
web_root = config.get(section, "web_root")
|
web_root = config().get(section, "web_root")
|
||||||
except ConfigParser.NoOptionError:
|
except config.NoOptionError:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
try:
|
try:
|
||||||
watch_dir = config.get(section, "watch_dir")
|
watch_dir = config().get(section, "watch_dir")
|
||||||
except ConfigParser.NoOptionError:
|
except config.NoOptionError:
|
||||||
watch_dir = ""
|
watch_dir = ""
|
||||||
try:
|
try:
|
||||||
transcode = int(config.get("Transcoder", "transcode"))
|
transcode = int(config().get("Transcoder", "transcode"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
transcode = 0
|
transcode = 0
|
||||||
try:
|
try:
|
||||||
delete_failed = int(config.get(section, "delete_failed"))
|
delete_failed = int(config().get(section, "delete_failed"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
delete_failed = 0
|
delete_failed = 0
|
||||||
try:
|
try:
|
||||||
delay = float(config.get(section, "delay"))
|
delay = float(config().get(section, "delay"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
delay = 0
|
delay = 0
|
||||||
try:
|
try:
|
||||||
wait_for = int(config.get(section, "wait_for"))
|
wait_for = int(config().get(section, "wait_for"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
wait_for = 5
|
wait_for = 5
|
||||||
try:
|
try:
|
||||||
SampleIDs = (config.get("Extensions", "SampleIDs")).split(',')
|
SampleIDs = (config().get("Extensions", "SampleIDs")).split(',')
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
SampleIDs = ['sample','-s.']
|
SampleIDs = ['sample','-s.']
|
||||||
try:
|
try:
|
||||||
nzbExtractionBy = config.get(section, "nzbExtractionBy")
|
nzbExtractionBy = config().get(section, "nzbExtractionBy")
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
nzbExtractionBy = "Downloader"
|
nzbExtractionBy = "Downloader"
|
||||||
try:
|
try:
|
||||||
process_method = config.get(section, "process_method")
|
process_method = config().get(section, "process_method")
|
||||||
except ConfigParser.NoOptionError:
|
except config.NoOptionError:
|
||||||
process_method = None
|
process_method = None
|
||||||
|
|
||||||
TimeOut = 60 * int(wait_for) # SickBeard needs to complete all moving and renaming before returning the log sequence via url.
|
TimeOut = 60 * int(wait_for) # SickBeard needs to complete all moving and renaming before returning the log sequence via url.
|
||||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||||
|
|
||||||
mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',')
|
mediaContainer = (config().get("Extensions", "mediaExtensions")).split(',')
|
||||||
minSampleSize = int(config.get("Extensions", "minSampleSize"))
|
minSampleSize = int(config().get("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]
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import sys
|
|
||||||
import urllib
|
import urllib
|
||||||
import os
|
|
||||||
import ConfigParser
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from nzbToMediaConfig import *
|
||||||
from autoProcess.nzbToMediaEnv import *
|
from autoProcess.nzbToMediaEnv import *
|
||||||
|
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
Logger = logging.getLogger()
|
||||||
|
|
||||||
class AuthURLOpener(urllib.FancyURLopener):
|
class AuthURLOpener(urllib.FancyURLopener):
|
||||||
|
@ -27,29 +26,26 @@ class AuthURLOpener(urllib.FancyURLopener):
|
||||||
return urllib.FancyURLopener.open(self, url)
|
return urllib.FancyURLopener.open(self, url)
|
||||||
|
|
||||||
def autoFork(fork=None):
|
def autoFork(fork=None):
|
||||||
config = ConfigParser.ConfigParser()
|
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
config.read(configFilename)
|
|
||||||
|
|
||||||
# config settings
|
# config settings
|
||||||
section = "SickBeard"
|
section = "SickBeard"
|
||||||
host = config.get(section, "host")
|
host = config().get(section, "host")
|
||||||
port = config.get(section, "port")
|
port = config().get(section, "port")
|
||||||
username = config.get(section, "username")
|
username = config().get(section, "username")
|
||||||
password = config.get(section, "password")
|
password = config().get(section, "password")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ssl = int(config.get(section, "ssl"))
|
ssl = int(config().get(section, "ssl"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (config.NoOptionError, ValueError):
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = config.get(section, "web_root")
|
web_root = config().get(section, "web_root")
|
||||||
except ConfigParser.NoOptionError:
|
except config.NoOptionError:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fork = forks.items()[forks.keys().index(config.get(section, "fork"))]
|
fork = forks.items()[forks.keys().index(config().get(section, "fork"))]
|
||||||
except:
|
except:
|
||||||
fork = "auto"
|
fork = "auto"
|
||||||
|
|
||||||
|
|
|
@ -1,298 +1,129 @@
|
||||||
#System imports
|
from nzbToMediaConfig import *
|
||||||
import ConfigParser
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
def migrate():
|
def migrate():
|
||||||
confignew = ConfigParser.ConfigParser()
|
|
||||||
confignew.optionxform = str
|
|
||||||
configFilenamenew = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg.sample")
|
|
||||||
confignew.read(configFilenamenew)
|
|
||||||
|
|
||||||
configold = ConfigParser.ConfigParser()
|
|
||||||
configold.optionxform = str
|
|
||||||
|
|
||||||
categories = []
|
categories = []
|
||||||
|
confignew = config(SAMPLE_CONFIG_FILE)
|
||||||
|
configold = config(CONFIG_FILE)
|
||||||
|
|
||||||
section = "CouchPotato"
|
section = "CouchPotato"
|
||||||
original = []
|
for option, value in configold.items(section) or config(MOVIE_CONFIG_FILE).items(section):
|
||||||
configFilenameold = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
if option is "category": # change this old format
|
||||||
if not os.path.isfile(configFilenameold): # lets look back for an older version.
|
|
||||||
configFilenameold = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMovie.cfg")
|
|
||||||
if not os.path.isfile(configFilenameold): # no config available
|
|
||||||
configFilenameold = ""
|
|
||||||
if configFilenameold: # read our old config.
|
|
||||||
configold.read(configFilenameold)
|
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
if option == "category": # change this old format
|
|
||||||
option = "cpsCategory"
|
option = "cpsCategory"
|
||||||
if option == "outputDirectory": # move this to new location format
|
if option is "outputDirectory": # move this to new location format
|
||||||
value = os.path.split(os.path.normpath(value))[0]
|
value = os.path.split(os.path.normpath(value))[0]
|
||||||
confignew.set("Torrent", option, value)
|
confignew.set("Torrent", option, value)
|
||||||
continue
|
continue
|
||||||
if option in ["username", "password" ]: # these are no-longer needed.
|
if option in ["username", "password" ]: # these are no-longer needed.
|
||||||
continue
|
continue
|
||||||
if option == "cpsCategory":
|
if option is "cpsCategory":
|
||||||
categories.extend(value.split(','))
|
categories.extend(value.split(','))
|
||||||
confignew.set(section, option, value)
|
confignew.set(section, option, value)
|
||||||
|
|
||||||
section = "SickBeard"
|
section = "SickBeard"
|
||||||
original = []
|
for option, value in configold.items(section) or config(TV_CONFIG_FILE).items(section):
|
||||||
configFilenameold = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
if option is "category": # change this old format
|
||||||
if not os.path.isfile(configFilenameold): # lets look back for an older version.
|
|
||||||
configFilenameold = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessTV.cfg")
|
|
||||||
if not os.path.isfile(configFilenameold): # no config available
|
|
||||||
configFilenameold = ""
|
|
||||||
if configFilenameold: # read our old config.
|
|
||||||
configold.read(configFilenameold)
|
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
if option == "category": # change this old format
|
|
||||||
option = "sbCategory"
|
option = "sbCategory"
|
||||||
if option == "failed_fork": # change this old format
|
if option is "failed_fork": # change this old format
|
||||||
option = "fork"
|
option = "fork"
|
||||||
if value not in ["default", "failed", "failed-torrent", "auto"]:
|
if value not in ["default", "failed", "failed-torrent", "auto"]:
|
||||||
value = "auto"
|
value = "auto"
|
||||||
if option == "fork" and value not in ["default", "failed", "failed-torrent", "auto"]:
|
if option is "fork" and value not in ["default", "failed", "failed-torrent", "auto"]:
|
||||||
value = "auto"
|
value = "auto"
|
||||||
if option == "outputDirectory": # move this to new location format
|
if option is "outputDirectory": # move this to new location format
|
||||||
value = os.path.split(os.path.normpath(value))[0]
|
value = os.path.split(os.path.normpath(value))[0]
|
||||||
confignew.set("Torrent", option, value)
|
confignew.set("Torrent", option, value)
|
||||||
continue
|
continue
|
||||||
if option == "sbCategory":
|
if option is "sbCategory":
|
||||||
categories.extend(value.split(','))
|
categories.extend(value.split(','))
|
||||||
confignew.set(section, option, value)
|
confignew.set(section, option, value)
|
||||||
|
|
||||||
section = "HeadPhones"
|
for section in configold.sections():
|
||||||
original = []
|
if section is "HeadPhones":
|
||||||
configFilenameold = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
if option in ["username", "password" ]:
|
||||||
if os.path.isfile(configFilenameold): # read our old config.
|
continue
|
||||||
configold.read(configFilenameold)
|
if option is "hpCategory":
|
||||||
try:
|
categories.extend(value.split(','))
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
if option in ["username", "password" ]: # these are no-longer needed.
|
|
||||||
continue
|
|
||||||
option, value = item
|
|
||||||
if option == "hpCategory":
|
|
||||||
categories.extend(value.split(','))
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "Mylar"
|
|
||||||
original = []
|
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
if option == "mlCategory":
|
|
||||||
categories.extend(value.split(','))
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "Gamez"
|
|
||||||
original = []
|
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
if option in ["username", "password" ]: # these are no-longer needed.
|
|
||||||
continue
|
|
||||||
if option == "gzCategory":
|
|
||||||
categories.extend(value.split(','))
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
for section in categories:
|
|
||||||
original = []
|
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
confignew.add_section(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
confignew.set(section, option, value)
|
||||||
|
|
||||||
section = "Torrent"
|
if section is "Mylar":
|
||||||
original = []
|
if option in "mlCategory":
|
||||||
try:
|
categories.extend(value.split(','))
|
||||||
original = configold.items(section)
|
confignew.set(section, option, value)
|
||||||
except:
|
|
||||||
pass
|
if section is "Gamez":
|
||||||
for item in original:
|
if option in ["username", "password" ]: # these are no-longer needed.
|
||||||
option, value = item
|
continue
|
||||||
if option in ["compressedExtensions", "mediaExtensions", "metaExtensions", "minSampleSize"]:
|
if option == "gzCategory":
|
||||||
section = "Extensions" # these were moved
|
categories.extend(value.split(','))
|
||||||
if option == "useLink": # Sym links supported now as well.
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
num_value = int(value)
|
if section is "Torrent":
|
||||||
if num_value == 1:
|
if option in ["compressedExtensions", "mediaExtensions", "metaExtensions", "minSampleSize"]:
|
||||||
|
section = "Extensions" # these were moved
|
||||||
|
if option is "useLink": # Sym links supported now as well.
|
||||||
|
num_value = int(value or 0)
|
||||||
|
if num_value is 1:
|
||||||
value = "hard"
|
value = "hard"
|
||||||
else:
|
else:
|
||||||
value = "no"
|
value = "no"
|
||||||
except ValueError:
|
confignew.set(section, option, value)
|
||||||
pass
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
section = "Torrent" # reset in case extensions out of order.
|
|
||||||
|
|
||||||
section = "Extensions"
|
if section is "Extensions":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "Transcoder"
|
if section is "Transcoder":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "WakeOnLan"
|
if section is "WakeOnLan":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "UserScript"
|
if section is "UserScript":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "ASCII"
|
if section is "ASCII":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "passwords"
|
if section is "passwords":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "loggers"
|
if section is "loggers":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "handlers"
|
if section is "handlers":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "formatters"
|
if section is "formatters":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "logger_root"
|
if section is "logger_root":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "handler_console"
|
if section is "handler_console":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
section = "formatter_generic"
|
if section is "formatter_generic":
|
||||||
original = []
|
confignew.set(section, option, value)
|
||||||
try:
|
|
||||||
original = configold.items(section)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
for item in original:
|
|
||||||
option, value = item
|
|
||||||
confignew.set(section, option, value)
|
|
||||||
|
|
||||||
# writing our configuration file to 'autoProcessMedia.cfg.sample'
|
for section in categories:
|
||||||
with open(configFilenamenew, 'wb') as configFile:
|
if configold.items(section):
|
||||||
confignew.write(configFile)
|
confignew.add_section(section)
|
||||||
|
|
||||||
|
for option, value in configold.items(section):
|
||||||
|
confignew.set(section, option, value)
|
||||||
|
|
||||||
# create a backup of our old config
|
# create a backup of our old config
|
||||||
if os.path.isfile(configFilenameold):
|
if os.path.isfile(CONFIG_FILE):
|
||||||
backupname = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg.old")
|
cfgbak_name = CONFIG_FILE + ".old"
|
||||||
if os.path.isfile(backupname): # remove older backups
|
if os.path.isfile(cfgbak_name): # remove older backups
|
||||||
os.unlink(backupname)
|
os.unlink(cfgbak_name)
|
||||||
os.rename(configFilenameold, backupname)
|
os.rename(CONFIG_FILE, cfgbak_name)
|
||||||
|
|
||||||
if os.path.isfile(configFilenamenew):
|
# writing our configuration file to 'autoProcessMedia.cfg.sample'
|
||||||
# rename our newly edited autoProcessMedia.cfg.sample to autoProcessMedia.cfg
|
with open(CONFIG_FILE, 'wb') as configFile:
|
||||||
os.rename(configFilenamenew, configFilenameold)
|
confignew.write(configFile)
|
||||||
return
|
|
||||||
|
|
||||||
def addnzbget():
|
def addnzbget():
|
||||||
confignew = ConfigParser.ConfigParser()
|
confignew = config()
|
||||||
confignew.optionxform = str
|
|
||||||
configFilenamenew = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
confignew.read(configFilenamenew)
|
|
||||||
|
|
||||||
section = "CouchPotato"
|
section = "CouchPotato"
|
||||||
envKeys = ['CATEGORY', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'METHOD', 'DELETE_FAILED', 'REMOTECPS', 'WAIT_FOR']
|
envKeys = ['CATEGORY', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'METHOD', 'DELETE_FAILED', 'REMOTECPS', 'WAIT_FOR']
|
||||||
cfgKeys = ['cpsCategory', 'apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'method', 'delete_failed', 'remoteCPS', 'wait_for']
|
cfgKeys = ['cpsCategory', 'apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'method', 'delete_failed', 'remoteCPS', 'wait_for']
|
||||||
|
@ -374,9 +205,6 @@ def addnzbget():
|
||||||
value = os.environ[key]
|
value = os.environ[key]
|
||||||
confignew.set(section, option, value)
|
confignew.set(section, option, value)
|
||||||
|
|
||||||
|
|
||||||
# writing our configuration file to 'autoProcessMedia.cfg'
|
# writing our configuration file to 'autoProcessMedia.cfg'
|
||||||
with open(configFilenamenew, 'wb') as configFile:
|
with open(CONFIG_FILE, 'wb') as configFile:
|
||||||
confignew.write(configFile)
|
confignew.write(configFile)
|
||||||
|
|
||||||
return
|
|
||||||
|
|
|
@ -1,28 +1,26 @@
|
||||||
import logging
|
import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import struct
|
import struct
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
import ConfigParser
|
|
||||||
|
|
||||||
import linktastic.linktastic as linktastic
|
import linktastic.linktastic as linktastic
|
||||||
|
from nzbToMediaConfig import *
|
||||||
|
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
Logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
def safeName(name):
|
def safeName(name):
|
||||||
safename = re.sub(r"[\/\\\:\*\?\"\<\>\|]", "", name) #make this name safe for use in directories for windows etc.
|
safename = re.sub(r"[\/\\\:\*\?\"\<\>\|]", "", name) #make this name safe for use in directories for windows etc.
|
||||||
return safename
|
return safename
|
||||||
|
|
||||||
|
|
||||||
def nzbtomedia_configure_logging(dirname):
|
def nzbtomedia_configure_logging(dirname):
|
||||||
logFile = os.path.join(dirname, "postprocess.log")
|
logging.config.fileConfig(CONFIG_FILE)
|
||||||
logging.config.fileConfig(os.path.join(dirname, "autoProcessMedia.cfg"))
|
fileHandler = logging.handlers.RotatingFileHandler(LOG_FILE, 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
|
||||||
logging.getLogger().addHandler(fileHandler)
|
logging.getLogger().addHandler(fileHandler)
|
||||||
|
@ -316,22 +314,18 @@ def TestCon(host, port):
|
||||||
|
|
||||||
|
|
||||||
def WakeUp():
|
def WakeUp():
|
||||||
config = ConfigParser.ConfigParser()
|
if not config():
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
Logger.error("You need an autoProcessMedia.config() file - did you rename and edit the .sample?")
|
||||||
|
|
||||||
if not os.path.isfile(configFilename):
|
|
||||||
Logger.error("You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
config.read(configFilename)
|
wake = int(config().get("WakeOnLan", "wake"))
|
||||||
wake = int(config.get("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", configFilename)
|
Logger.info("Loading WakeOnLan config from %s", CONFIG_FILE)
|
||||||
config.get("WakeOnLan", "host")
|
config().get("WakeOnLan", "host")
|
||||||
host = config.get("WakeOnLan", "host")
|
host = config().get("WakeOnLan", "host")
|
||||||
port = int(config.get("WakeOnLan", "port"))
|
port = int(config().get("WakeOnLan", "port"))
|
||||||
mac = config.get("WakeOnLan", "mac")
|
mac = config().get("WakeOnLan", "mac")
|
||||||
|
|
||||||
i=1
|
i=1
|
||||||
while TestCon(host, port) == "Down" and i < 4:
|
while TestCon(host, port) == "Down" and i < 4:
|
||||||
|
@ -346,13 +340,11 @@ def WakeUp():
|
||||||
Logger.info("System with mac: %s has been woken. Continuing with the rest of the script.", mac)
|
Logger.info("System with mac: %s has been woken. Continuing with the rest of the script.", mac)
|
||||||
|
|
||||||
def converto_to_ascii(nzbName, dirName):
|
def converto_to_ascii(nzbName, dirName):
|
||||||
config = ConfigParser.ConfigParser()
|
if not config():
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
if not os.path.isfile(configFilename):
|
|
||||||
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
|
||||||
config.read(configFilename)
|
|
||||||
ascii_convert = int(config.get("ASCII", "convert"))
|
ascii_convert = int(config().get("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
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import ConfigParser
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]),'autoProcess/'))
|
|
||||||
import logging
|
import logging
|
||||||
from subprocess import call, Popen, PIPE
|
|
||||||
|
from nzbToMediaConfig import *
|
||||||
|
from subprocess import call, Popen
|
||||||
from autoProcess.nzbToMediaUtil import create_destination
|
from autoProcess.nzbToMediaUtil import create_destination
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,11 +111,9 @@ def extract(filePath, outputDestination):
|
||||||
# Create outputDestination folder
|
# Create outputDestination folder
|
||||||
create_destination(outputDestination)
|
create_destination(outputDestination)
|
||||||
|
|
||||||
config = ConfigParser.ConfigParser()
|
Logger.info("MAIN: Loading config from %s", CONFIG_FILE)
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
Logger.info("MAIN: Loading config from %s", configFilename)
|
passwordsfile = config().get("passwords", "PassWordFile")
|
||||||
config.read(configFilename)
|
|
||||||
passwordsfile = config.get("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:
|
||||||
|
|
|
@ -116,8 +116,6 @@
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import autoProcess.migratecfg as migratecfg
|
import autoProcess.migratecfg as migratecfg
|
||||||
|
|
|
@ -57,8 +57,6 @@
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import autoProcess.migratecfg as migratecfg
|
import autoProcess.migratecfg as migratecfg
|
||||||
|
|
|
@ -62,8 +62,6 @@
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import autoProcess.migratecfg as migratecfg
|
import autoProcess.migratecfg as migratecfg
|
||||||
|
|
|
@ -261,22 +261,25 @@
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import ConfigParser
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import autoProcess.migratecfg as migratecfg
|
|
||||||
import autoProcess.autoProcessComics as autoProcessComics
|
import autoProcess.autoProcessComics as autoProcessComics
|
||||||
import autoProcess.autoProcessGames as autoProcessGames
|
import autoProcess.autoProcessGames as autoProcessGames
|
||||||
import autoProcess.autoProcessMusic as autoProcessMusic
|
import autoProcess.autoProcessMusic as autoProcessMusic
|
||||||
import autoProcess.autoProcessMovie as autoProcessMovie
|
import autoProcess.autoProcessMovie as autoProcessMovie
|
||||||
import autoProcess.autoProcessTV as autoProcessTV
|
import autoProcess.autoProcessTV as autoProcessTV
|
||||||
|
import autoProcess.migratecfg as migratecfg
|
||||||
from autoProcess.nzbToMediaEnv import *
|
from autoProcess.nzbToMediaEnv import *
|
||||||
from autoProcess.nzbToMediaUtil import *
|
from autoProcess.nzbToMediaUtil import *
|
||||||
|
|
||||||
|
# Exit codes used by NZBGet
|
||||||
|
POSTPROCESS_PARCHECK = 92
|
||||||
|
POSTPROCESS_SUCCESS = 93
|
||||||
|
POSTPROCESS_ERROR = 94
|
||||||
|
POSTPROCESS_NONE = 95
|
||||||
|
|
||||||
# check to migrate old cfg before trying to load.
|
# check to migrate old cfg before trying to load.
|
||||||
if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg.sample")):
|
if config(SAMPLE_CONFIG_FILE):
|
||||||
migratecfg.migrate()
|
migratecfg.migrate()
|
||||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
|
@ -290,20 +293,17 @@ Logger.info("nzbToMedia %s", VERSION)
|
||||||
|
|
||||||
WakeUp()
|
WakeUp()
|
||||||
|
|
||||||
config = ConfigParser.ConfigParser()
|
if not config():
|
||||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
|
||||||
if not os.path.isfile(configFilename):
|
|
||||||
Logger.error("MAIN: You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
|
Logger.error("MAIN: You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
# CONFIG FILE
|
|
||||||
Logger.info("MAIN: Loading config from %s", configFilename)
|
|
||||||
config.read(configFilename)
|
|
||||||
|
|
||||||
cpsCategory = (config.get("CouchPotato", "cpsCategory")).split(',') # movie
|
Logger.info("MAIN: Loading config from %s", CONFIG_FILE)
|
||||||
sbCategory = (config.get("SickBeard", "sbCategory")).split(',') # tv
|
|
||||||
hpCategory = (config.get("HeadPhones", "hpCategory")).split(',') # music
|
cpsCategory = (config().get("CouchPotato", "cpsCategory")).split(',') # movie
|
||||||
mlCategory = (config.get("Mylar", "mlCategory")).split(',') # comics
|
sbCategory = (config().get("SickBeard", "sbCategory")).split(',') # tv
|
||||||
gzCategory = (config.get("Gamez", "gzCategory")).split(',') # games
|
hpCategory = (config().get("HeadPhones", "hpCategory")).split(',') # music
|
||||||
|
mlCategory = (config().get("Mylar", "mlCategory")).split(',') # comics
|
||||||
|
gzCategory = (config().get("Gamez", "gzCategory")).split(',') # games
|
||||||
|
|
||||||
# NZBGet V11+
|
# NZBGet V11+
|
||||||
# Check if the script is called from nzbget 11.0 or later
|
# Check if the script is called from nzbget 11.0 or later
|
||||||
|
@ -312,11 +312,6 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
|
||||||
|
|
||||||
# NZBGet argv: all passed as environment variables.
|
# NZBGet argv: all passed as environment variables.
|
||||||
clientAgent = "nzbget"
|
clientAgent = "nzbget"
|
||||||
# Exit codes used by NZBGet
|
|
||||||
POSTPROCESS_PARCHECK=92
|
|
||||||
POSTPROCESS_SUCCESS=93
|
|
||||||
POSTPROCESS_ERROR=94
|
|
||||||
POSTPROCESS_NONE=95
|
|
||||||
|
|
||||||
# Check nzbget.conf options
|
# Check nzbget.conf options
|
||||||
status = 0
|
status = 0
|
||||||
|
|
35
nzbToMediaConfig.py
Normal file
35
nzbToMediaConfig.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import os
|
||||||
|
import ConfigParser
|
||||||
|
|
||||||
|
# init paths
|
||||||
|
MY_FULLNAME = os.path.normpath(os.path.abspath(__file__))
|
||||||
|
MY_NAME = os.path.basename(MY_FULLNAME)
|
||||||
|
PROG_DIR = os.path.dirname(MY_FULLNAME)
|
||||||
|
|
||||||
|
# init config file names
|
||||||
|
CONFIG_FILE = os.path.join(PROG_DIR, "autoProcessMedia.cfg")
|
||||||
|
SAMPLE_CONFIG_FILE = os.path.join(PROG_DIR, "autoProcessMedia.cfg.sample")
|
||||||
|
MOVIE_CONFIG_FILE = os.path.join(PROG_DIR, "autoProcessMovie.cfg")
|
||||||
|
TV_CONFIG_FILE = os.path.join(PROG_DIR, "autoProcessTv.cfg")
|
||||||
|
LOG_FILE = os.path.join(PROG_DIR, "postprocess.log")
|
||||||
|
|
||||||
|
class config(ConfigParser.ConfigParser):
|
||||||
|
|
||||||
|
# link error handlers
|
||||||
|
Error = ConfigParser.Error
|
||||||
|
NoSectionError = ConfigParser.NoSectionError
|
||||||
|
NoOptionError = ConfigParser.NoOptionError
|
||||||
|
DuplicateSectionError = ConfigParser.DuplicateSectionError
|
||||||
|
InterpolationError = ConfigParser.InterpolationError
|
||||||
|
InterpolationMissingOptionError = ConfigParser.InterpolationMissingOptionError
|
||||||
|
InterpolationSyntaxError = ConfigParser.InterpolationSyntaxError
|
||||||
|
InterpolationDepthError = ConfigParser.InterpolationDepthError
|
||||||
|
ParsingError = ConfigParser.ParsingError
|
||||||
|
MissingSectionHeaderError = ConfigParser.MissingSectionHeaderError
|
||||||
|
|
||||||
|
def __init__(self, *file):
|
||||||
|
ConfigParser.ConfigParser.__init__(self)
|
||||||
|
self.optionxform = str
|
||||||
|
if not file:
|
||||||
|
file = CONFIG_FILE
|
||||||
|
self.read(file)
|
|
@ -60,8 +60,6 @@
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import autoProcess.migratecfg as migratecfg
|
import autoProcess.migratecfg as migratecfg
|
||||||
|
|
|
@ -124,8 +124,6 @@
|
||||||
### NZBGET POST-PROCESSING SCRIPT ###
|
### NZBGET POST-PROCESSING SCRIPT ###
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import autoProcess.migratecfg as migratecfg
|
import autoProcess.migratecfg as migratecfg
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from itertools import imap
|
from itertools import imap
|
||||||
|
|
||||||
|
@ -8,6 +7,7 @@ from synchronousdeluge.exceptions import DelugeRPCError
|
||||||
from synchronousdeluge.protocol import DelugeRPCRequest, DelugeRPCResponse
|
from synchronousdeluge.protocol import DelugeRPCRequest, DelugeRPCResponse
|
||||||
from synchronousdeluge.transfer import DelugeTransfer
|
from synchronousdeluge.transfer import DelugeTransfer
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["DelugeClient"]
|
__all__ = ["DelugeClient"]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,6 @@ __all__ = ['dumps', 'loads']
|
||||||
#
|
#
|
||||||
|
|
||||||
import struct
|
import struct
|
||||||
import string
|
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
# Default number of bits for serialized floats, either 32 or 64 (also a parameter for dumps()).
|
# Default number of bits for serialized floats, either 32 or 64 (also a parameter for dumps()).
|
||||||
|
|
3
tests/test_autofork.py
Normal file
3
tests/test_autofork.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from autoProcess.autoSickBeardFork import autoFork
|
||||||
|
fork, params = autoFork()
|
||||||
|
print fork, params
|
|
@ -2,7 +2,11 @@
|
||||||
# Copyright (c) 2008-2013 Erik Svensson <erik.public@gmail.com>
|
# Copyright (c) 2008-2013 Erik Svensson <erik.public@gmail.com>
|
||||||
# Licensed under the MIT license.
|
# Licensed under the MIT license.
|
||||||
|
|
||||||
import re, time, operator, warnings, os
|
import re
|
||||||
|
import time
|
||||||
|
import operator
|
||||||
|
import warnings
|
||||||
|
import os
|
||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
@ -12,9 +16,9 @@ from transmissionrpc.utils import LOGGER, get_arguments, make_rpc_name, argument
|
||||||
from transmissionrpc.httphandler import DefaultHTTPHandler
|
from transmissionrpc.httphandler import DefaultHTTPHandler
|
||||||
from transmissionrpc.torrent import Torrent
|
from transmissionrpc.torrent import Torrent
|
||||||
from transmissionrpc.session import Session
|
from transmissionrpc.session import Session
|
||||||
|
|
||||||
from six import PY3, integer_types, string_types, iteritems
|
from six import PY3, integer_types, string_types, iteritems
|
||||||
|
|
||||||
|
|
||||||
if PY3:
|
if PY3:
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
|
@ -3,8 +3,10 @@
|
||||||
# Licensed under the MIT license.
|
# Licensed under the MIT license.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger('transmissionrpc')
|
LOGGER = logging.getLogger('transmissionrpc')
|
||||||
LOGGER.setLevel(logging.ERROR)
|
LOGGER.setLevel(logging.ERROR)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from transmissionrpc.error import HTTPHandlerError
|
from transmissionrpc.error import HTTPHandlerError
|
||||||
|
|
||||||
from six import PY3
|
from six import PY3
|
||||||
|
|
||||||
if PY3:
|
if PY3:
|
||||||
|
|
|
@ -151,7 +151,7 @@ _moved_attributes = [
|
||||||
MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
|
MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
|
||||||
|
|
||||||
MovedModule("builtins", "__builtin__"),
|
MovedModule("builtins", "__builtin__"),
|
||||||
MovedModule("configparser", "ConfigParser"),
|
MovedModule("config", "config"),
|
||||||
MovedModule("copyreg", "copy_reg"),
|
MovedModule("copyreg", "copy_reg"),
|
||||||
MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
|
MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
|
||||||
MovedModule("http_cookies", "Cookie", "http.cookies"),
|
MovedModule("http_cookies", "Cookie", "http.cookies"),
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
# Copyright (c) 2008-2013 Erik Svensson <erik.public@gmail.com>
|
# Copyright (c) 2008-2013 Erik Svensson <erik.public@gmail.com>
|
||||||
# Licensed under the MIT license.
|
# Licensed under the MIT license.
|
||||||
|
|
||||||
import sys, datetime
|
import sys
|
||||||
|
import datetime
|
||||||
|
|
||||||
from transmissionrpc.constants import PRIORITY, RATIO_LIMIT, IDLE_LIMIT
|
from transmissionrpc.constants import PRIORITY, RATIO_LIMIT, IDLE_LIMIT
|
||||||
from transmissionrpc.utils import Field, format_timedelta
|
from transmissionrpc.utils import Field, format_timedelta
|
||||||
|
|
||||||
from six import integer_types, string_types, text_type, iteritems
|
from six import integer_types, string_types, text_type, iteritems
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,16 @@
|
||||||
# Copyright (c) 2008-2013 Erik Svensson <erik.public@gmail.com>
|
# Copyright (c) 2008-2013 Erik Svensson <erik.public@gmail.com>
|
||||||
# Licensed under the MIT license.
|
# Licensed under the MIT license.
|
||||||
|
|
||||||
import socket, datetime, logging
|
import socket
|
||||||
|
import datetime
|
||||||
|
import logging
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
import transmissionrpc.constants as constants
|
import transmissionrpc.constants as constants
|
||||||
from transmissionrpc.constants import LOGGER
|
from transmissionrpc.constants import LOGGER
|
||||||
|
|
||||||
from six import string_types, iteritems
|
from six import string_types, iteritems
|
||||||
|
|
||||||
|
|
||||||
UNITS = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB']
|
UNITS = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB']
|
||||||
|
|
||||||
def format_size(size):
|
def format_size(size):
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
import itertools
|
import itertools
|
||||||
import mimetools
|
import mimetools
|
||||||
import mimetypes
|
import mimetypes
|
||||||
from cStringIO import StringIO
|
|
||||||
import urllib
|
|
||||||
import urllib2
|
|
||||||
|
|
||||||
class MultiPartForm(object):
|
class MultiPartForm(object):
|
||||||
"""Accumulate the data to be used when posting a form."""
|
"""Accumulate the data to be used when posting a form."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue