Merge pull request #853 from fativi/master

Added an option to preserve archives after extraction
This commit is contained in:
Clinton Hall 2015-10-14 22:31:39 +10:30
commit db1c3d8f64
3 changed files with 16 additions and 4 deletions

View file

@ -84,6 +84,11 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
except: except:
Torrent_NoLink = 0 Torrent_NoLink = 0
try:
keep_archive = int(section[usercat]["keep_archive"])
except:
keep_archive = 0
try: try:
extract = int(section[usercat]['extract']) extract = int(section[usercat]['extract'])
except: except:
@ -178,7 +183,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
if extract == 1: if extract == 1:
logger.debug('Checking for archives to extract in directory: %s' % (outputDestination)) logger.debug('Checking for archives to extract in directory: %s' % (outputDestination))
core.extractFiles(outputDestination) core.extractFiles(inputDirectory, outputDestination, keep_archive)
if not inputCategory in core.NOFLATTEN: #don't flatten hp in case multi cd albums, and we need to copy this back later. if not inputCategory in core.NOFLATTEN: #don't flatten hp in case multi cd albums, and we need to copy this back later.
core.flatten(outputDestination) core.flatten(outputDestination)

View file

@ -51,6 +51,7 @@
web_root = web_root =
# Enable/Disable linking for Torrents # Enable/Disable linking for Torrents
Torrent_NoLink = 0 Torrent_NoLink = 0
keep_archive = 1
method = renamer method = renamer
delete_failed = 0 delete_failed = 0
wait_for = 2 wait_for = 2
@ -80,6 +81,7 @@
delete_failed = 0 delete_failed = 0
# Enable/Disable linking for Torrents # Enable/Disable linking for Torrents
Torrent_NoLink = 0 Torrent_NoLink = 0
keep_archive = 1
process_method = process_method =
# force processing of already processed content when running a manual scan. # force processing of already processed content when running a manual scan.
force = 0 force = 0
@ -112,6 +114,7 @@
delete_failed = 0 delete_failed = 0
# Enable/Disable linking for Torrents # Enable/Disable linking for Torrents
Torrent_NoLink = 0 Torrent_NoLink = 0
keep_archive = 1
extract = 1 extract = 1
nzbExtractionBy = Downloader nzbExtractionBy = Downloader
wait_for = 2 wait_for = 2
@ -138,6 +141,7 @@
wait_for = 2 wait_for = 2
# Enable/Disable linking for Torrents # Enable/Disable linking for Torrents
Torrent_NoLink = 0 Torrent_NoLink = 0
keep_archive = 1
extract = 1 extract = 1
# Set this to minimum required size to consider a media file valid (in MB) # Set this to minimum required size to consider a media file valid (in MB)
minSize = 0 minSize = 0
@ -162,6 +166,7 @@
ssl=0 ssl=0
# Enable/Disable linking for Torrents # Enable/Disable linking for Torrents
Torrent_NoLink = 0 Torrent_NoLink = 0
keep_archive = 1
extract = 1 extract = 1
# Set this to minimum required size to consider a media file valid (in MB) # Set this to minimum required size to consider a media file valid (in MB)
minSize = 0 minSize = 0
@ -187,6 +192,7 @@
web_root = web_root =
# Enable/Disable linking for Torrents # Enable/Disable linking for Torrents
Torrent_NoLink = 0 Torrent_NoLink = 0
keep_archive = 1
extract = 1 extract = 1
# Set this to minimum required size to consider a media file valid (in MB) # Set this to minimum required size to consider a media file valid (in MB)
minSize = 0 minSize = 0
@ -341,6 +347,7 @@
#Enable/Disable this subsection category #Enable/Disable this subsection category
enabled = 0 enabled = 0
Torrent_NoLink = 0 Torrent_NoLink = 0
keep_archive = 1
extract = 1 extract = 1
#Enable if you are sending commands to a remote server for this category #Enable if you are sending commands to a remote server for this category
remote_path = 0 remote_path = 0

View file

@ -993,7 +993,7 @@ def find_imdbid(dirName, inputName):
logger.warning('Unable to find a imdbID for %s' % (inputName)) logger.warning('Unable to find a imdbID for %s' % (inputName))
return imdbid return imdbid
def extractFiles(src, dst=None): def extractFiles(src, dst=None, keep_archive = None):
extracted_folder = [] extracted_folder = []
extracted_archive = [] extracted_archive = []
@ -1018,8 +1018,8 @@ def extractFiles(src, dst=None):
fullFileName = os.path.basename(inputFile) fullFileName = os.path.basename(inputFile)
archiveName = os.path.splitext(fullFileName)[0] archiveName = os.path.splitext(fullFileName)[0]
archiveName = re.sub(r"part[0-9]+", "", archiveName) archiveName = re.sub(r"part[0-9]+", "", archiveName)
if not archiveName in extracted_archive: if not archiveName in extracted_archive or keep_archive == True:
continue # don't remove if we haven't extracted this archive. continue # don't remove if we haven't extracted this archive, or if we want to preserve them.
logger.info("Removing extracted archive %s from folder %s ..." % (fullFileName, folder)) logger.info("Removing extracted archive %s from folder %s ..." % (fullFileName, folder))
try: try:
if not os.access(inputFile, os.W_OK): if not os.access(inputFile, os.W_OK):