mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-22 14:13:33 -07:00
Merge 4c35248561
into 08968619ab
This commit is contained in:
commit
0a631f3721
29 changed files with 377 additions and 553 deletions
|
@ -81,7 +81,7 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
|
|||
os.utime(filepath, None)
|
||||
continue
|
||||
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_SUCCESS)
|
||||
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#System imports
|
||||
import os
|
||||
import sys
|
||||
import ConfigParser
|
||||
import shutil
|
||||
import logging
|
||||
import datetime
|
||||
import time
|
||||
import re
|
||||
from subprocess import call, Popen
|
||||
from subprocess import Popen
|
||||
|
||||
# Custom imports
|
||||
import autoProcess.migratecfg as migratecfg
|
||||
|
@ -442,7 +436,7 @@ if __name__ == "__main__":
|
|||
migratecfg.migrate()
|
||||
|
||||
# Logging
|
||||
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0]))
|
||||
nzbtomedia_configure_logging(LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
||||
Logger.info("====================") # Seperate old from new log
|
||||
|
@ -450,69 +444,65 @@ if __name__ == "__main__":
|
|||
|
||||
WakeUp()
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
||||
|
||||
if not os.path.isfile(configFilename):
|
||||
if not config():
|
||||
Logger.error("You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
|
||||
sys.exit(-1)
|
||||
|
||||
# CONFIG FILE
|
||||
Logger.info("MAIN: Loading config from %s", configFilename)
|
||||
config.read(configFilename)
|
||||
Logger.info("MAIN: Loading config from %s", CONFIG_FILE)
|
||||
# EXAMPLE VALUES:
|
||||
clientAgent = config.get("Torrent", "clientAgent") # utorrent | deluge | transmission | rtorrent | other
|
||||
useLink_in = config.get("Torrent", "useLink") # no | hard | sym
|
||||
outputDirectory = config.get("Torrent", "outputDirectory") # /abs/path/to/complete/
|
||||
categories = (config.get("Torrent", "categories")).split(',') # music,music_videos,pictures,software
|
||||
noFlatten = (config.get("Torrent", "noFlatten")).split(',')
|
||||
clientAgent = config().get("Torrent", "clientAgent") # utorrent | deluge | transmission | rtorrent | other
|
||||
useLink_in = config().get("Torrent", "useLink") # no | hard | sym
|
||||
outputDirectory = config().get("Torrent", "outputDirectory") # /abs/path/to/complete/
|
||||
categories = (config().get("Torrent", "categories")).split(',') # music,music_videos,pictures,software
|
||||
noFlatten = (config().get("Torrent", "noFlatten")).split(',')
|
||||
|
||||
uTorrentWEBui = config.get("Torrent", "uTorrentWEBui") # http://localhost:8090/gui/
|
||||
uTorrentUSR = config.get("Torrent", "uTorrentUSR") # mysecretusr
|
||||
uTorrentPWD = config.get("Torrent", "uTorrentPWD") # mysecretpwr
|
||||
uTorrentWEBui = config().get("Torrent", "uTorrentWEBui") # http://localhost:8090/gui/
|
||||
uTorrentUSR = config().get("Torrent", "uTorrentUSR") # mysecretusr
|
||||
uTorrentPWD = config().get("Torrent", "uTorrentPWD") # mysecretpwr
|
||||
|
||||
TransmissionHost = config.get("Torrent", "TransmissionHost") # localhost
|
||||
TransmissionPort = config.get("Torrent", "TransmissionPort") # 8084
|
||||
TransmissionUSR = config.get("Torrent", "TransmissionUSR") # mysecretusr
|
||||
TransmissionPWD = config.get("Torrent", "TransmissionPWD") # mysecretpwr
|
||||
TransmissionHost = config().get("Torrent", "TransmissionHost") # localhost
|
||||
TransmissionPort = config().get("Torrent", "TransmissionPort") # 8084
|
||||
TransmissionUSR = config().get("Torrent", "TransmissionUSR") # mysecretusr
|
||||
TransmissionPWD = config().get("Torrent", "TransmissionPWD") # mysecretpwr
|
||||
|
||||
DelugeHost = config.get("Torrent", "DelugeHost") # localhost
|
||||
DelugePort = config.get("Torrent", "DelugePort") # 8084
|
||||
DelugeUSR = config.get("Torrent", "DelugeUSR") # mysecretusr
|
||||
DelugePWD = config.get("Torrent", "DelugePWD") # mysecretpwr
|
||||
DelugeHost = config().get("Torrent", "DelugeHost") # localhost
|
||||
DelugePort = config().get("Torrent", "DelugePort") # 8084
|
||||
DelugeUSR = config().get("Torrent", "DelugeUSR") # mysecretusr
|
||||
DelugePWD = config().get("Torrent", "DelugePWD") # mysecretpwr
|
||||
|
||||
deleteOriginal = int(config.get("Torrent", "deleteOriginal")) # 0
|
||||
forceClean = int(config.get("Torrent", "forceClean")) # 0
|
||||
deleteOriginal = int(config().get("Torrent", "deleteOriginal")) # 0
|
||||
forceClean = int(config().get("Torrent", "forceClean")) # 0
|
||||
|
||||
compressedContainer = (config.get("Extensions", "compressedExtensions")).split(',') # .zip,.rar,.7z
|
||||
mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',') # .mkv,.avi,.divx
|
||||
metaContainer = (config.get("Extensions", "metaExtensions")).split(',') # .nfo,.sub,.srt
|
||||
minSampleSize = int(config.get("Extensions", "minSampleSize")) # 200 (in MB)
|
||||
SampleIDs = (config.get("Extensions", "SampleIDs")).split(',') # sample,-s.
|
||||
compressedContainer = (config().get("Extensions", "compressedExtensions")).split(',') # .zip,.rar,.7z
|
||||
mediaContainer = (config().get("Extensions", "mediaExtensions")).split(',') # .mkv,.avi,.divx
|
||||
metaContainer = (config().get("Extensions", "metaExtensions")).split(',') # .nfo,.sub,.srt
|
||||
minSampleSize = int(config().get("Extensions", "minSampleSize")) # 200 (in MB)
|
||||
SampleIDs = (config().get("Extensions", "SampleIDs")).split(',') # sample,-s.
|
||||
|
||||
cpsCategory = (config.get("CouchPotato", "cpsCategory")).split(',') # movie
|
||||
sbCategory = (config.get("SickBeard", "sbCategory")).split(',') # tv
|
||||
Torrent_ForceLink = int(config.get("SickBeard", "Torrent_ForceLink")) # 1
|
||||
hpCategory = (config.get("HeadPhones", "hpCategory")).split(',') # music
|
||||
mlCategory = (config.get("Mylar", "mlCategory")).split(',') # comics
|
||||
gzCategory = (config.get("Gamez", "gzCategory")).split(',') # games
|
||||
cpsCategory = (config().get("CouchPotato", "cpsCategory")).split(',') # movie
|
||||
sbCategory = (config().get("SickBeard", "sbCategory")).split(',') # tv
|
||||
Torrent_ForceLink = int(config().get("SickBeard", "Torrent_ForceLink")) # 1
|
||||
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().get("UserScript", "user_script_categories").split(',') # NONE
|
||||
if not "NONE" in user_script_categories:
|
||||
user_script_mediaExtensions = (config.get("UserScript", "user_script_mediaExtensions")).split(',')
|
||||
user_script = config.get("UserScript", "user_script_path")
|
||||
user_script_param = (config.get("UserScript", "user_script_param")).split(',')
|
||||
user_script_successCodes = (config.get("UserScript", "user_script_successCodes")).split(',')
|
||||
user_script_clean = int(config.get("UserScript", "user_script_clean"))
|
||||
user_delay = int(config.get("UserScript", "delay"))
|
||||
user_script_runOnce = int(config.get("UserScript", "user_script_runOnce"))
|
||||
user_script_mediaExtensions = (config().get("UserScript", "user_script_mediaExtensions")).split(',')
|
||||
user_script = config().get("UserScript", "user_script_path")
|
||||
user_script_param = (config().get("UserScript", "user_script_param")).split(',')
|
||||
user_script_successCodes = (config().get("UserScript", "user_script_successCodes")).split(',')
|
||||
user_script_clean = int(config().get("UserScript", "user_script_clean"))
|
||||
user_delay = int(config().get("UserScript", "delay"))
|
||||
user_script_runOnce = int(config().get("UserScript", "user_script_runOnce"))
|
||||
|
||||
transcode = int(config.get("Transcoder", "transcode"))
|
||||
transcode = int(config().get("Transcoder", "transcode"))
|
||||
|
||||
n = 0
|
||||
for arg in sys.argv:
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import sys
|
||||
import os
|
||||
import ConfigParser
|
||||
import logging
|
||||
import errno
|
||||
from subprocess import call
|
||||
|
||||
from nzbToMediaConfig import *
|
||||
|
||||
|
||||
Logger = logging.getLogger()
|
||||
|
||||
def Transcode_directory(dirName):
|
||||
|
@ -28,32 +29,28 @@ def Transcode_directory(dirName):
|
|||
else:
|
||||
ffmpeg = 'ffmpeg'
|
||||
useNiceness = True
|
||||
|
||||
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?")
|
||||
return 1 # failure
|
||||
|
||||
config.read(configFilename)
|
||||
|
||||
mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',')
|
||||
duplicate = int(config.get("Transcoder", "duplicate"))
|
||||
ignoreExtensions = (config.get("Transcoder", "ignoreExtensions")).split(',')
|
||||
outputVideoExtension = config.get("Transcoder", "outputVideoExtension").strip()
|
||||
outputVideoCodec = config.get("Transcoder", "outputVideoCodec").strip()
|
||||
outputVideoPreset = config.get("Transcoder", "outputVideoPreset").strip()
|
||||
outputVideoFramerate = config.get("Transcoder", "outputVideoFramerate").strip()
|
||||
outputVideoBitrate = config.get("Transcoder", "outputVideoBitrate").strip()
|
||||
outputAudioCodec = config.get("Transcoder", "outputAudioCodec").strip()
|
||||
outputAudioBitrate = config.get("Transcoder", "outputAudioBitrate").strip()
|
||||
outputSubtitleCodec = config.get("Transcoder", "outputSubtitleCodec").strip()
|
||||
outputFastStart = int(config.get("Transcoder", "outputFastStart"))
|
||||
outputQualityPercent = int(config.get("Transcoder", "outputQualityPercent"))
|
||||
mediaContainer = (config().get("Extensions", "mediaExtensions")).split(',')
|
||||
duplicate = int(config().get("Transcoder", "duplicate"))
|
||||
ignoreExtensions = (config().get("Transcoder", "ignoreExtensions")).split(',')
|
||||
outputVideoExtension = config().get("Transcoder", "outputVideoExtension").strip()
|
||||
outputVideoCodec = config().get("Transcoder", "outputVideoCodec").strip()
|
||||
outputVideoPreset = config().get("Transcoder", "outputVideoPreset").strip()
|
||||
outputVideoFramerate = config().get("Transcoder", "outputVideoFramerate").strip()
|
||||
outputVideoBitrate = config().get("Transcoder", "outputVideoBitrate").strip()
|
||||
outputAudioCodec = config().get("Transcoder", "outputAudioCodec").strip()
|
||||
outputAudioBitrate = config().get("Transcoder", "outputAudioBitrate").strip()
|
||||
outputSubtitleCodec = config().get("Transcoder", "outputSubtitleCodec").strip()
|
||||
outputFastStart = int(config().get("Transcoder", "outputFastStart"))
|
||||
outputQualityPercent = int(config().get("Transcoder", "outputQualityPercent"))
|
||||
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(), ignoreExtensions)
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
import sys
|
||||
import urllib
|
||||
import os.path
|
||||
import time
|
||||
import ConfigParser
|
||||
import logging
|
||||
import socket
|
||||
|
||||
from nzbToMediaEnv import *
|
||||
from nzbToMediaUtil import *
|
||||
from nzbToMediaSceneExceptions import process_all_exceptions
|
||||
|
||||
|
||||
Logger = logging.getLogger()
|
||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||
|
@ -34,36 +29,36 @@ class AuthURLOpener(urllib.FancyURLopener):
|
|||
|
||||
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)
|
||||
|
||||
|
||||
Logger.info("Loading config from %s", CONFIG_FILE)
|
||||
|
||||
if not os.path.isfile(configFilename):
|
||||
if not config():
|
||||
Logger.error("You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
|
||||
return 1 # failure
|
||||
|
||||
config.read(configFilename)
|
||||
|
||||
|
||||
section = "Mylar"
|
||||
if inputCategory != None and config.has_section(inputCategory):
|
||||
if inputCategory != None and config().has_section(inputCategory):
|
||||
section = inputCategory
|
||||
host = config.get(section, "host")
|
||||
port = config.get(section, "port")
|
||||
username = config.get(section, "username")
|
||||
password = config.get(section, "password")
|
||||
host = config().get(section, "host")
|
||||
port = config().get(section, "port")
|
||||
username = config().get(section, "username")
|
||||
password = config().get(section, "password")
|
||||
try:
|
||||
ssl = int(config.get(section, "ssl"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
ssl = int(config().get(section, "ssl"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
ssl = 0
|
||||
|
||||
try:
|
||||
web_root = config.get(section, "web_root")
|
||||
except ConfigParser.NoOptionError:
|
||||
web_root = config().get(section, "web_root")
|
||||
except config.NoOptionError:
|
||||
web_root = ""
|
||||
|
||||
try:
|
||||
watch_dir = config.get(section, "watch_dir")
|
||||
except ConfigParser.NoOptionError:
|
||||
watch_dir = config().get(section, "watch_dir")
|
||||
except config.NoOptionError:
|
||||
watch_dir = ""
|
||||
params = {}
|
||||
|
||||
|
|
|
@ -1,49 +1,43 @@
|
|||
import sys
|
||||
import urllib
|
||||
import os
|
||||
import shutil
|
||||
import ConfigParser
|
||||
import datetime
|
||||
import time
|
||||
import json
|
||||
import logging
|
||||
import socket
|
||||
|
||||
from nzbToMediaEnv import *
|
||||
from nzbToMediaUtil import *
|
||||
|
||||
|
||||
Logger = logging.getLogger()
|
||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||
|
||||
def process(dirName, nzbName=None, status=0, inputCategory=None):
|
||||
|
||||
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?")
|
||||
return 1 # failure
|
||||
|
||||
config.read(configFilename)
|
||||
|
||||
|
||||
section = "Gamez"
|
||||
if inputCategory != None and config.has_section(inputCategory):
|
||||
if inputCategory != None and config().has_section(inputCategory):
|
||||
section = inputCategory
|
||||
|
||||
host = config.get(section, "host")
|
||||
port = config.get(section, "port")
|
||||
apikey = config.get(section, "apikey")
|
||||
host = config().get(section, "host")
|
||||
port = config().get(section, "port")
|
||||
apikey = config().get(section, "apikey")
|
||||
|
||||
try:
|
||||
ssl = int(config.get(section, "ssl"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
ssl = int(config().get(section, "ssl"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
ssl = 0
|
||||
|
||||
try:
|
||||
web_root = config.get(section, "web_root")
|
||||
except ConfigParser.NoOptionError:
|
||||
web_root = config().get(section, "web_root")
|
||||
except config.NoOptionError:
|
||||
web_root = ""
|
||||
|
||||
if ssl:
|
||||
|
|
|
@ -1,19 +1,14 @@
|
|||
import sys
|
||||
import urllib
|
||||
import os
|
||||
import shutil
|
||||
import ConfigParser
|
||||
import datetime
|
||||
import time
|
||||
import json
|
||||
import logging
|
||||
import socket
|
||||
|
||||
import Transcoder
|
||||
from nzbToMediaEnv import *
|
||||
from nzbToMediaUtil import *
|
||||
from nzbToMediaSceneExceptions import process_all_exceptions
|
||||
|
||||
|
||||
Logger = logging.getLogger()
|
||||
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
|
||||
|
||||
def get_status(baseURL, movie_id, download_id):
|
||||
|
||||
result = None
|
||||
movie_status = None
|
||||
release_status = None
|
||||
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)
|
||||
except:
|
||||
Logger.exception("Could not find a status for this movie")
|
||||
|
||||
try:
|
||||
if len(result["media"]["releases"]) == 1 and result["media"]["releases"][0]["status"] == "done":
|
||||
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):
|
||||
|
||||
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?")
|
||||
return 1 # failure
|
||||
|
||||
config.read(configFilename)
|
||||
|
||||
section = "CouchPotato"
|
||||
if inputCategory != None and config.has_section(inputCategory):
|
||||
if inputCategory != None and config().has_section(inputCategory):
|
||||
section = inputCategory
|
||||
|
||||
host = config.get(section, "host")
|
||||
port = config.get(section, "port")
|
||||
apikey = config.get(section, "apikey")
|
||||
delay = float(config.get(section, "delay"))
|
||||
method = config.get(section, "method")
|
||||
delete_failed = int(config.get(section, "delete_failed"))
|
||||
wait_for = int(config.get(section, "wait_for"))
|
||||
host = config().get(section, "host")
|
||||
port = config().get(section, "port")
|
||||
apikey = config().get(section, "apikey")
|
||||
delay = float(config().get(section, "delay"))
|
||||
method = config().get(section, "method")
|
||||
delete_failed = int(config().get(section, "delete_failed"))
|
||||
wait_for = int(config().get(section, "wait_for"))
|
||||
try:
|
||||
TimePerGiB = int(config.get(section, "TimePerGiB"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
TimePerGiB = int(config().get(section, "TimePerGiB"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
TimePerGiB = 60 # note, if using Network to transfer on 100Mbit LAN, expect ~ 600 MB/minute.
|
||||
try:
|
||||
ssl = int(config.get(section, "ssl"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
ssl = int(config().get(section, "ssl"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
ssl = 0
|
||||
try:
|
||||
web_root = config.get(section, "web_root")
|
||||
except ConfigParser.NoOptionError:
|
||||
web_root = config().get(section, "web_root")
|
||||
except config.NoOptionError:
|
||||
web_root = ""
|
||||
try:
|
||||
transcode = int(config.get("Transcoder", "transcode"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
transcode = int(config().get("Transcoder", "transcode"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
transcode = 0
|
||||
try:
|
||||
remoteCPS = int(config.get(section, "remoteCPS"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
remoteCPS = int(config().get(section, "remoteCPS"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
remoteCPS = 0
|
||||
|
||||
nzbName = str(nzbName) # make sure it is a string
|
||||
|
@ -314,6 +307,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.
|
||||
socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout.
|
||||
|
||||
release_status = None
|
||||
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?
|
||||
while (datetime.datetime.now() - start) < datetime.timedelta(minutes=wait_for): # only wait 2 (default) minutes, then return.
|
||||
|
|
|
@ -1,51 +1,46 @@
|
|||
import sys
|
||||
import urllib
|
||||
import os
|
||||
import shutil
|
||||
import ConfigParser
|
||||
import datetime
|
||||
import time
|
||||
import json
|
||||
import logging
|
||||
import socket
|
||||
|
||||
from nzbToMediaEnv import *
|
||||
from nzbToMediaUtil import *
|
||||
|
||||
|
||||
Logger = logging.getLogger()
|
||||
|
||||
def process(dirName, nzbName=None, status=0, inputCategory=None):
|
||||
|
||||
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?")
|
||||
return 1 # failure
|
||||
|
||||
config.read(configFilename)
|
||||
|
||||
|
||||
section = "HeadPhones"
|
||||
if inputCategory != None and config.has_section(inputCategory):
|
||||
if inputCategory != None and config().has_section(inputCategory):
|
||||
section = inputCategory
|
||||
|
||||
host = config.get(section, "host")
|
||||
port = config.get(section, "port")
|
||||
apikey = config.get(section, "apikey")
|
||||
delay = float(config.get(section, "delay"))
|
||||
host = config().get(section, "host")
|
||||
port = config().get(section, "port")
|
||||
apikey = config().get(section, "apikey")
|
||||
delay = float(config().get(section, "delay"))
|
||||
|
||||
try:
|
||||
ssl = int(config.get(section, "ssl"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
ssl = int(config().get(section, "ssl"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
ssl = 0
|
||||
try:
|
||||
web_root = config.get(section, "web_root")
|
||||
except ConfigParser.NoOptionError:
|
||||
web_root = config().get(section, "web_root")
|
||||
except config.NoOptionError:
|
||||
web_root = ""
|
||||
try:
|
||||
TimePerGiB = int(config.get(section, "TimePerGiB"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
TimePerGiB = int(config().get(section, "TimePerGiB"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
TimePerGiB = 60 # note, if using Network to transfer on 100Mbit LAN, expect ~ 600 MB/minute.
|
||||
if ssl:
|
||||
protocol = "https://"
|
||||
|
|
|
@ -3,10 +3,10 @@ import logging
|
|||
import copy
|
||||
|
||||
import Transcoder
|
||||
from nzbToMediaEnv import *
|
||||
from nzbToMediaUtil import *
|
||||
from nzbToMediaSceneExceptions import process_all_exceptions
|
||||
from autoProcess.autoSickBeardFork import autoFork
|
||||
from nzbToMediaEnv import *
|
||||
from nzbToMediaUtil import *
|
||||
|
||||
|
||||
Logger = logging.getLogger()
|
||||
|
@ -40,69 +40,69 @@ def delete(dirName):
|
|||
def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputCategory=None):
|
||||
|
||||
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?")
|
||||
return 1 # failure
|
||||
|
||||
config.read(configFilename)
|
||||
|
||||
|
||||
section = "SickBeard"
|
||||
if inputCategory != None and config.has_section(inputCategory):
|
||||
if inputCategory != None and config().has_section(inputCategory):
|
||||
section = inputCategory
|
||||
|
||||
watch_dir = ""
|
||||
host = config.get(section, "host")
|
||||
port = config.get(section, "port")
|
||||
username = config.get(section, "username")
|
||||
password = config.get(section, "password")
|
||||
host = config().get(section, "host")
|
||||
port = config().get(section, "port")
|
||||
username = config().get(section, "username")
|
||||
password = config().get(section, "password")
|
||||
|
||||
try:
|
||||
ssl = int(config.get(section, "ssl"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
ssl = int(config().get(section, "ssl"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
ssl = 0
|
||||
try:
|
||||
web_root = config.get(section, "web_root")
|
||||
except ConfigParser.NoOptionError:
|
||||
web_root = config().get(section, "web_root")
|
||||
except config.NoOptionError:
|
||||
web_root = ""
|
||||
try:
|
||||
watch_dir = config.get(section, "watch_dir")
|
||||
except ConfigParser.NoOptionError:
|
||||
watch_dir = config().get(section, "watch_dir")
|
||||
except config.NoOptionError:
|
||||
watch_dir = ""
|
||||
try:
|
||||
transcode = int(config.get("Transcoder", "transcode"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
transcode = int(config().get("Transcoder", "transcode"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
transcode = 0
|
||||
try:
|
||||
delete_failed = int(config.get(section, "delete_failed"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
delete_failed = int(config().get(section, "delete_failed"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
delete_failed = 0
|
||||
try:
|
||||
delay = float(config.get(section, "delay"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
delay = float(config().get(section, "delay"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
delay = 0
|
||||
try:
|
||||
TimePerGiB = int(config.get(section, "TimePerGiB"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
TimePerGiB = int(config().get(section, "TimePerGiB"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
TimePerGiB = 60 # note, if using Network to transfer on 100Mbit LAN, expect ~ 600 MB/minute.
|
||||
try:
|
||||
SampleIDs = (config.get("Extensions", "SampleIDs")).split(',')
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
SampleIDs = (config().get("Extensions", "SampleIDs")).split(',')
|
||||
except (config.NoOptionError, ValueError):
|
||||
SampleIDs = ['sample','-s.']
|
||||
try:
|
||||
nzbExtractionBy = config.get(section, "nzbExtractionBy")
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
nzbExtractionBy = config().get(section, "nzbExtractionBy")
|
||||
except (config.NoOptionError, ValueError):
|
||||
nzbExtractionBy = "Downloader"
|
||||
try:
|
||||
process_method = config.get(section, "process_method")
|
||||
except ConfigParser.NoOptionError:
|
||||
process_method = config().get(section, "process_method")
|
||||
except config.NoOptionError:
|
||||
process_method = None
|
||||
|
||||
mediaContainer = (config.get("Extensions", "mediaExtensions")).split(',')
|
||||
minSampleSize = int(config.get("Extensions", "minSampleSize"))
|
||||
mediaContainer = (config().get("Extensions", "mediaExtensions")).split(',')
|
||||
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.
|
||||
dirName = os.path.split(os.path.normpath(dirName))[0]
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import sys
|
||||
import urllib
|
||||
import os
|
||||
import ConfigParser
|
||||
import logging
|
||||
|
||||
from nzbToMediaConfig import *
|
||||
from autoProcess.nzbToMediaEnv import *
|
||||
|
||||
|
||||
Logger = logging.getLogger()
|
||||
|
||||
class AuthURLOpener(urllib.FancyURLopener):
|
||||
|
@ -27,29 +26,26 @@ class AuthURLOpener(urllib.FancyURLopener):
|
|||
return urllib.FancyURLopener.open(self, url)
|
||||
|
||||
def autoFork(fork=None):
|
||||
config = ConfigParser.ConfigParser()
|
||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
||||
config.read(configFilename)
|
||||
|
||||
# config settings
|
||||
section = "SickBeard"
|
||||
host = config.get(section, "host")
|
||||
port = config.get(section, "port")
|
||||
username = config.get(section, "username")
|
||||
password = config.get(section, "password")
|
||||
host = config().get(section, "host")
|
||||
port = config().get(section, "port")
|
||||
username = config().get(section, "username")
|
||||
password = config().get(section, "password")
|
||||
|
||||
try:
|
||||
ssl = int(config.get(section, "ssl"))
|
||||
except (ConfigParser.NoOptionError, ValueError):
|
||||
ssl = int(config().get(section, "ssl"))
|
||||
except (config.NoOptionError, ValueError):
|
||||
ssl = 0
|
||||
|
||||
try:
|
||||
web_root = config.get(section, "web_root")
|
||||
except ConfigParser.NoOptionError:
|
||||
web_root = config().get(section, "web_root")
|
||||
except config.NoOptionError:
|
||||
web_root = ""
|
||||
|
||||
try:
|
||||
fork = forks.items()[forks.keys().index(config.get(section, "fork"))]
|
||||
fork = forks.items()[forks.keys().index(config().get(section, "fork"))]
|
||||
except:
|
||||
fork = "auto"
|
||||
|
||||
|
|
|
@ -1,62 +1,27 @@
|
|||
#System imports
|
||||
import ConfigParser
|
||||
import sys
|
||||
import os
|
||||
from nzbToMediaConfig import *
|
||||
|
||||
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 = []
|
||||
confignew = config(SAMPLE_CONFIG_FILE)
|
||||
configold = config(CONFIG_FILE)
|
||||
|
||||
section = "CouchPotato"
|
||||
original = []
|
||||
configFilenameold = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
||||
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
|
||||
for option, value in configold.items(section) or config(MOVIE_CONFIG_FILE).items(section):
|
||||
if option is "category": # change this old format
|
||||
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]
|
||||
confignew.set("Torrent", option, value)
|
||||
continue
|
||||
if option in ["username", "password" ]: # these are no-longer needed.
|
||||
continue
|
||||
if option == "cpsCategory":
|
||||
if option is "cpsCategory":
|
||||
categories.extend(value.split(','))
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "SickBeard"
|
||||
original = []
|
||||
configFilenameold = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
||||
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
|
||||
for option, value in configold.items(section) or config(TV_CONFIG_FILE).items(section):
|
||||
if option is "category": # change this old format
|
||||
option = "sbCategory"
|
||||
if option == "wait_for": # remove old format
|
||||
continue
|
||||
|
@ -64,237 +29,103 @@ def migrate():
|
|||
option = "fork"
|
||||
if value not in ["default", "failed", "failed-torrent", "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"
|
||||
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]
|
||||
confignew.set("Torrent", option, value)
|
||||
continue
|
||||
if option == "sbCategory":
|
||||
if option is "sbCategory":
|
||||
categories.extend(value.split(','))
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "HeadPhones"
|
||||
original = []
|
||||
configFilenameold = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
||||
if os.path.isfile(configFilenameold): # read our old config.
|
||||
configold.read(configFilenameold)
|
||||
try:
|
||||
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)
|
||||
for section in configold.sections():
|
||||
if section is "HeadPhones":
|
||||
if option in ["username", "password" ]:
|
||||
continue
|
||||
if option is "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)
|
||||
if section is "Mylar":
|
||||
if option in "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)
|
||||
if section is "Gamez":
|
||||
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)
|
||||
|
||||
section = "Torrent"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
if option in ["compressedExtensions", "mediaExtensions", "metaExtensions", "minSampleSize"]:
|
||||
section = "Extensions" # these were moved
|
||||
if option == "useLink": # Sym links supported now as well.
|
||||
try:
|
||||
num_value = int(value)
|
||||
if num_value == 1:
|
||||
if section is "Torrent":
|
||||
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"
|
||||
else:
|
||||
value = "no"
|
||||
except ValueError:
|
||||
pass
|
||||
confignew.set(section, option, value)
|
||||
section = "Torrent" # reset in case extensions out of order.
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "Extensions"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "Extensions":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "Transcoder"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "Transcoder":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "WakeOnLan"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "WakeOnLan":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "UserScript"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "UserScript":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "ASCII"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "ASCII":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "passwords"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "passwords":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "loggers"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "loggers":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "handlers"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "handlers":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "formatters"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "formatters":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "logger_root"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "logger_root":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "handler_console"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "handler_console":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "formatter_generic"
|
||||
original = []
|
||||
try:
|
||||
original = configold.items(section)
|
||||
except:
|
||||
pass
|
||||
for item in original:
|
||||
option, value = item
|
||||
confignew.set(section, option, value)
|
||||
if section is "formatter_generic":
|
||||
confignew.set(section, option, value)
|
||||
|
||||
# writing our configuration file to 'autoProcessMedia.cfg.sample'
|
||||
with open(configFilenamenew, 'wb') as configFile:
|
||||
confignew.write(configFile)
|
||||
for section in categories:
|
||||
if configold.items(section):
|
||||
confignew.add_section(section)
|
||||
|
||||
for option, value in configold.items(section):
|
||||
confignew.set(section, option, value)
|
||||
|
||||
# create a backup of our old config
|
||||
if os.path.isfile(configFilenameold):
|
||||
backupname = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg.old")
|
||||
if os.path.isfile(backupname): # remove older backups
|
||||
os.unlink(backupname)
|
||||
os.rename(configFilenameold, backupname)
|
||||
if os.path.isfile(CONFIG_FILE):
|
||||
cfgbak_name = CONFIG_FILE + ".old"
|
||||
if os.path.isfile(cfgbak_name): # remove older backups
|
||||
os.unlink(cfgbak_name)
|
||||
os.rename(CONFIG_FILE, cfgbak_name)
|
||||
|
||||
if os.path.isfile(configFilenamenew):
|
||||
# rename our newly edited autoProcessMedia.cfg.sample to autoProcessMedia.cfg
|
||||
os.rename(configFilenamenew, configFilenameold)
|
||||
return
|
||||
# writing our configuration file to 'autoProcessMedia.cfg'
|
||||
with open(CONFIG_FILE, 'wb') as configFile:
|
||||
confignew.write(configFile)
|
||||
|
||||
def addnzbget():
|
||||
confignew = ConfigParser.ConfigParser()
|
||||
confignew.optionxform = str
|
||||
configFilenamenew = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
||||
confignew.read(configFilenamenew)
|
||||
|
||||
confignew = config()
|
||||
section = "CouchPotato"
|
||||
envKeys = ['CATEGORY', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'METHOD', 'DELETE_FAILED', 'REMOTECPS', 'WAIT_FOR', 'TIMEPERGIB']
|
||||
cfgKeys = ['cpsCategory', 'apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'method', 'delete_failed', 'remoteCPS', 'wait_for', 'TimePerGiB']
|
||||
|
@ -324,7 +155,7 @@ def addnzbget():
|
|||
if os.environ.has_key(key):
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
confignew.set(section, option, value)
|
||||
confignew.set(section, option, value)
|
||||
|
||||
section = "Mylar"
|
||||
envKeys = ['CATEGORY', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT']
|
||||
|
@ -376,9 +207,13 @@ def addnzbget():
|
|||
value = os.environ[key]
|
||||
confignew.set(section, option, value)
|
||||
|
||||
# create a backup of our old config
|
||||
if os.path.isfile(CONFIG_FILE):
|
||||
cfgbak_name = CONFIG_FILE + ".old"
|
||||
if os.path.isfile(cfgbak_name): # remove older backups
|
||||
os.unlink(cfgbak_name)
|
||||
os.rename(CONFIG_FILE, cfgbak_name)
|
||||
|
||||
# writing our configuration file to 'autoProcessMedia.cfg'
|
||||
with open(configFilenamenew, 'wb') as configFile:
|
||||
with open(CONFIG_FILE, 'wb') as configFile:
|
||||
confignew.write(configFile)
|
||||
|
||||
return
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import logging
|
||||
import logging.config
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import shutil
|
||||
import struct
|
||||
import socket
|
||||
import time
|
||||
import ConfigParser
|
||||
|
||||
import linktastic.linktastic as linktastic
|
||||
from nzbToMediaConfig import *
|
||||
|
||||
|
||||
Logger = logging.getLogger()
|
||||
|
||||
|
@ -28,10 +28,9 @@ def safeName(name):
|
|||
return safename
|
||||
|
||||
|
||||
def nzbtomedia_configure_logging(dirname):
|
||||
logFile = os.path.join(dirname, "postprocess.log")
|
||||
logging.config.fileConfig(os.path.join(dirname, "autoProcessMedia.cfg"))
|
||||
fileHandler = logging.handlers.RotatingFileHandler(logFile, mode='a', maxBytes=1048576, backupCount=1, encoding='utf-8', delay=True)
|
||||
def nzbtomedia_configure_logging(logfile):
|
||||
logging.config.fileConfig(CONFIG_FILE)
|
||||
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.level = logging.DEBUG
|
||||
logging.getLogger().addHandler(fileHandler)
|
||||
|
@ -325,22 +324,18 @@ def TestCon(host, port):
|
|||
|
||||
|
||||
def WakeUp():
|
||||
config = ConfigParser.ConfigParser()
|
||||
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?")
|
||||
if not config():
|
||||
Logger.error("You need an autoProcessMedia.config() file - did you rename and edit the .sample?")
|
||||
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.
|
||||
return
|
||||
Logger.info("Loading WakeOnLan config from %s", configFilename)
|
||||
config.get("WakeOnLan", "host")
|
||||
host = config.get("WakeOnLan", "host")
|
||||
port = int(config.get("WakeOnLan", "port"))
|
||||
mac = config.get("WakeOnLan", "mac")
|
||||
Logger.info("Loading WakeOnLan config from %s", CONFIG_FILE)
|
||||
config().get("WakeOnLan", "host")
|
||||
host = config().get("WakeOnLan", "host")
|
||||
port = int(config().get("WakeOnLan", "port"))
|
||||
mac = config().get("WakeOnLan", "mac")
|
||||
|
||||
i=1
|
||||
while TestCon(host, port) == "Down" and i < 4:
|
||||
|
@ -355,13 +350,11 @@ def WakeUp():
|
|||
Logger.info("System with mac: %s has been woken. Continuing with the rest of the script.", mac)
|
||||
|
||||
def convert_to_ascii(nzbName, dirName):
|
||||
config = ConfigParser.ConfigParser()
|
||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
||||
if not os.path.isfile(configFilename):
|
||||
if not config():
|
||||
Logger.error("You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
|
||||
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!.
|
||||
return nzbName, dirName
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import os
|
||||
import sys
|
||||
import ConfigParser
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]),'autoProcess/'))
|
||||
import logging
|
||||
from subprocess import call, Popen, PIPE
|
||||
|
||||
from nzbToMediaConfig import *
|
||||
from subprocess import call, Popen
|
||||
from autoProcess.nzbToMediaUtil import create_destination
|
||||
|
||||
|
||||
|
@ -112,11 +111,9 @@ def extract(filePath, outputDestination):
|
|||
# Create outputDestination folder
|
||||
create_destination(outputDestination)
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
||||
Logger.info("MAIN: Loading config from %s", configFilename)
|
||||
config.read(configFilename)
|
||||
passwordsfile = config.get("passwords", "PassWordFile")
|
||||
Logger.info("MAIN: Loading config from %s", CONFIG_FILE)
|
||||
|
||||
passwordsfile = config().get("passwords", "PassWordFile")
|
||||
if passwordsfile != "" and os.path.isfile(os.path.normpath(passwordsfile)):
|
||||
passwords = [line.strip() for line in open(os.path.normpath(passwordsfile))]
|
||||
else:
|
||||
|
|
|
@ -121,8 +121,6 @@
|
|||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
import autoProcess.migratecfg as migratecfg
|
||||
|
@ -137,7 +135,7 @@ if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.c
|
|||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
migratecfg.addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0]))
|
||||
nzbtomedia_configure_logging(LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
||||
Logger.info("====================") # Seperate old from new log
|
||||
|
|
|
@ -57,8 +57,6 @@
|
|||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
import autoProcess.migratecfg as migratecfg
|
||||
|
@ -73,7 +71,7 @@ if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.c
|
|||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
migratecfg.addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0]))
|
||||
nzbtomedia_configure_logging(LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
||||
Logger.info("====================") # Seperate old from new log
|
||||
|
|
|
@ -67,8 +67,6 @@
|
|||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
import autoProcess.migratecfg as migratecfg
|
||||
|
@ -83,7 +81,7 @@ if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.c
|
|||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
migratecfg.addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0]))
|
||||
nzbtomedia_configure_logging(LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
||||
Logger.info("====================") # Seperate old from new log
|
||||
|
|
|
@ -271,28 +271,36 @@
|
|||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
import os
|
||||
import sys
|
||||
import ConfigParser
|
||||
import shutil
|
||||
import logging
|
||||
|
||||
import autoProcess.migratecfg as migratecfg
|
||||
import autoProcess.autoProcessComics as autoProcessComics
|
||||
import autoProcess.autoProcessGames as autoProcessGames
|
||||
import autoProcess.autoProcessMusic as autoProcessMusic
|
||||
import autoProcess.autoProcessMovie as autoProcessMovie
|
||||
import autoProcess.autoProcessTV as autoProcessTV
|
||||
import autoProcess.migratecfg as migratecfg
|
||||
from autoProcess.nzbToMediaEnv import *
|
||||
from autoProcess.nzbToMediaUtil import *
|
||||
|
||||
# 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")):
|
||||
# Exit codes used by NZBGet
|
||||
POSTPROCESS_PARCHECK = 92
|
||||
POSTPROCESS_SUCCESS = 93
|
||||
POSTPROCESS_ERROR = 94
|
||||
POSTPROCESS_NONE = 95
|
||||
|
||||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||
if config(SAMPLE_CONFIG_FILE):
|
||||
migratecfg.migrate()
|
||||
elif config():
|
||||
shutil.copyfile(CONFIG_FILE, SAMPLE_CONFIG_FILE)
|
||||
migratecfg.migrate()
|
||||
|
||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
if config() and os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
migratecfg.addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0]))
|
||||
nzbtomedia_configure_logging(LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
||||
Logger.info("====================") # Seperate old from new log
|
||||
|
@ -300,20 +308,17 @@ Logger.info("nzbToMedia %s", VERSION)
|
|||
|
||||
WakeUp()
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg")
|
||||
if not os.path.isfile(configFilename):
|
||||
if not config():
|
||||
Logger.error("MAIN: You need an autoProcessMedia.cfg file - did you rename and edit the .sample?")
|
||||
sys.exit(-1)
|
||||
# CONFIG FILE
|
||||
Logger.info("MAIN: Loading config from %s", configFilename)
|
||||
config.read(configFilename)
|
||||
|
||||
cpsCategory = (config.get("CouchPotato", "cpsCategory")).split(',') # movie
|
||||
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
|
||||
Logger.info("MAIN: Loading config from %s", CONFIG_FILE)
|
||||
|
||||
cpsCategory = (config().get("CouchPotato", "cpsCategory")).split(',') # movie
|
||||
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
|
||||
|
||||
# NZBGet V11+
|
||||
# Check if the script is called from nzbget 11.0 or later
|
||||
|
@ -322,11 +327,6 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
|
|||
|
||||
# NZBGet argv: all passed as environment variables.
|
||||
clientAgent = "nzbget"
|
||||
# Exit codes used by NZBGet
|
||||
POSTPROCESS_PARCHECK=92
|
||||
POSTPROCESS_SUCCESS=93
|
||||
POSTPROCESS_ERROR=94
|
||||
POSTPROCESS_NONE=95
|
||||
|
||||
# Check nzbget.conf options
|
||||
status = 0
|
||||
|
|
40
nzbToMediaConfig.py
Normal file
40
nzbToMediaConfig.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
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 configParser(object):
|
||||
|
||||
# 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
|
||||
|
||||
@staticmethod
|
||||
def config(*file):
|
||||
# if no file specified then load our default config
|
||||
if not file:file = CONFIG_FILE
|
||||
|
||||
# load config
|
||||
parser = ConfigParser.ConfigParser()
|
||||
parser.optionxform = str
|
||||
if parser.read(file):return parser
|
||||
|
||||
config = configParser.config
|
|
@ -60,8 +60,6 @@
|
|||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
import autoProcess.migratecfg as migratecfg
|
||||
|
@ -76,7 +74,7 @@ if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.c
|
|||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
migratecfg.addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0]))
|
||||
nzbtomedia_configure_logging(LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
||||
Logger.info("====================") # Seperate old from new log
|
||||
|
|
|
@ -124,8 +124,6 @@
|
|||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
import autoProcess.migratecfg as migratecfg
|
||||
|
@ -140,7 +138,7 @@ if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.c
|
|||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
migratecfg.addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0]))
|
||||
nzbtomedia_configure_logging(LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
||||
Logger.info("====================") # Seperate old from new log
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import os
|
||||
import platform
|
||||
|
||||
from collections import defaultdict
|
||||
from itertools import imap
|
||||
|
||||
|
@ -8,6 +7,7 @@ from synchronousdeluge.exceptions import DelugeRPCError
|
|||
from synchronousdeluge.protocol import DelugeRPCRequest, DelugeRPCResponse
|
||||
from synchronousdeluge.transfer import DelugeTransfer
|
||||
|
||||
|
||||
__all__ = ["DelugeClient"]
|
||||
|
||||
|
||||
|
|
|
@ -63,7 +63,6 @@ __all__ = ['dumps', 'loads']
|
|||
#
|
||||
|
||||
import struct
|
||||
import string
|
||||
from threading import Lock
|
||||
|
||||
# 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>
|
||||
# Licensed under the MIT license.
|
||||
|
||||
import re, time, operator, warnings, os
|
||||
import re
|
||||
import time
|
||||
import operator
|
||||
import warnings
|
||||
import os
|
||||
import base64
|
||||
import json
|
||||
|
||||
|
@ -12,9 +16,9 @@ from transmissionrpc.utils import LOGGER, get_arguments, make_rpc_name, argument
|
|||
from transmissionrpc.httphandler import DefaultHTTPHandler
|
||||
from transmissionrpc.torrent import Torrent
|
||||
from transmissionrpc.session import Session
|
||||
|
||||
from six import PY3, integer_types, string_types, iteritems
|
||||
|
||||
|
||||
if PY3:
|
||||
from urllib.parse import urlparse
|
||||
from urllib.request import urlopen
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
# Licensed under the MIT license.
|
||||
|
||||
import logging
|
||||
|
||||
from six import iteritems
|
||||
|
||||
|
||||
LOGGER = logging.getLogger('transmissionrpc')
|
||||
LOGGER.setLevel(logging.ERROR)
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import sys
|
||||
|
||||
from transmissionrpc.error import HTTPHandlerError
|
||||
|
||||
from six import PY3
|
||||
|
||||
if PY3:
|
||||
|
|
|
@ -151,7 +151,7 @@ _moved_attributes = [
|
|||
MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
|
||||
|
||||
MovedModule("builtins", "__builtin__"),
|
||||
MovedModule("configparser", "ConfigParser"),
|
||||
MovedModule("config", "config"),
|
||||
MovedModule("copyreg", "copy_reg"),
|
||||
MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
|
||||
MovedModule("http_cookies", "Cookie", "http.cookies"),
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
# Copyright (c) 2008-2013 Erik Svensson <erik.public@gmail.com>
|
||||
# Licensed under the MIT license.
|
||||
|
||||
import sys, datetime
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
from transmissionrpc.constants import PRIORITY, RATIO_LIMIT, IDLE_LIMIT
|
||||
from transmissionrpc.utils import Field, format_timedelta
|
||||
|
||||
from six import integer_types, string_types, text_type, iteritems
|
||||
|
||||
|
||||
|
|
|
@ -2,13 +2,16 @@
|
|||
# Copyright (c) 2008-2013 Erik Svensson <erik.public@gmail.com>
|
||||
# Licensed under the MIT license.
|
||||
|
||||
import socket, datetime, logging
|
||||
import socket
|
||||
import datetime
|
||||
import logging
|
||||
from collections import namedtuple
|
||||
|
||||
import transmissionrpc.constants as constants
|
||||
from transmissionrpc.constants import LOGGER
|
||||
|
||||
from six import string_types, iteritems
|
||||
|
||||
|
||||
UNITS = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB']
|
||||
|
||||
def format_size(size):
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
import itertools
|
||||
import mimetools
|
||||
import mimetypes
|
||||
from cStringIO import StringIO
|
||||
import urllib
|
||||
import urllib2
|
||||
|
||||
|
||||
class MultiPartForm(object):
|
||||
"""Accumulate the data to be used when posting a form."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue