mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-31 03:50:06 -07:00
Added support for symbolic linking.
This commit is contained in:
parent
cecd34c626
commit
6ee08b99b0
4 changed files with 29 additions and 7 deletions
|
@ -143,7 +143,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
Logger.error("MAIN: Failed to connect to uTorrent: %s", e)
|
Logger.error("MAIN: Failed to connect to uTorrent: %s", e)
|
||||||
|
|
||||||
# if we are using links with uTorrent it means we need to pause it in order to access the files
|
# if we are using links with uTorrent it means we need to pause it in order to access the files
|
||||||
if useLink == 1:
|
if useLink != "no":
|
||||||
Logger.debug("MAIN: Stoping torrent %s in uTorrent while processing", inputName)
|
Logger.debug("MAIN: Stoping torrent %s in uTorrent while processing", inputName)
|
||||||
utorrentClass.stop(inputHash)
|
utorrentClass.stop(inputHash)
|
||||||
time.sleep(5) # Give uTorrent some time to catch up with the change
|
time.sleep(5) # Give uTorrent some time to catch up with the change
|
||||||
|
@ -192,7 +192,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
Logger.info("MAIN: A problem was reported in the autoProcess* script. If torrent was pasued we will resume seeding")
|
Logger.info("MAIN: A problem was reported in the autoProcess* script. If torrent was pasued we will resume seeding")
|
||||||
|
|
||||||
# Hardlink solution for uTorrent, need to implent support for deluge, transmission
|
# Hardlink solution for uTorrent, need to implent support for deluge, transmission
|
||||||
if clientAgent == 'utorrent' and extractionSuccess == False and inputHash and useLink == 1 and deleteOriginal == 0: # we always want to resume seeding, for now manually find out what is wrong when extraction fails
|
if clientAgent == 'utorrent' and extractionSuccess == False and inputHash and useLink != "no" and deleteOriginal == 0: # we always want to resume seeding, for now manually find out what is wrong when extraction fails
|
||||||
Logger.debug("MAIN: Starting torrent %s in uTorrent", inputName)
|
Logger.debug("MAIN: Starting torrent %s in uTorrent", inputName)
|
||||||
utorrentClass.start(inputHash)
|
utorrentClass.start(inputHash)
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ if __name__ == "__main__":
|
||||||
config.read(configFilename)
|
config.read(configFilename)
|
||||||
# EXAMPLE VALUES:
|
# EXAMPLE VALUES:
|
||||||
clientAgent = config.get("Torrent", "clientAgent") # utorrent | deluge | transmission | other
|
clientAgent = config.get("Torrent", "clientAgent") # utorrent | deluge | transmission | other
|
||||||
useLink = int(config.get("Torrent", "useLink")) # true | false
|
useLink = config.get("Torrent", "useLink") # no | hard | sym
|
||||||
minSampleSize = int(config.get("Torrent", "minSampleSize")) # 200 (in MB)
|
minSampleSize = int(config.get("Torrent", "minSampleSize")) # 200 (in MB)
|
||||||
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
|
||||||
|
|
|
@ -101,6 +101,15 @@ def migrate():
|
||||||
option, value = item
|
option, value = item
|
||||||
if option in ["compressedExtensions", "mediaExtensions", "metaExtensions"]:
|
if option in ["compressedExtensions", "mediaExtensions", "metaExtensions"]:
|
||||||
section = "Extensions" # these were moved
|
section = "Extensions" # these were moved
|
||||||
|
if option == "useLink": # Sym links supported now as well.
|
||||||
|
try:
|
||||||
|
num_value = int(value)
|
||||||
|
if num_value == 1:
|
||||||
|
value = "hard"
|
||||||
|
else:
|
||||||
|
value = "no"
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
confignew.set(section, option, value)
|
confignew.set(section, option, value)
|
||||||
section = "Torrent" # reset in case extensions out of order.
|
section = "Torrent" # reset in case extensions out of order.
|
||||||
|
|
||||||
|
|
|
@ -150,9 +150,9 @@ def is_sample(filePath, inputName, minSampleSize):
|
||||||
|
|
||||||
def copy_link(filePath, targetDirectory, useLink, outputDestination):
|
def copy_link(filePath, targetDirectory, useLink, outputDestination):
|
||||||
create_destination(outputDestination)
|
create_destination(outputDestination)
|
||||||
if useLink != 0:
|
if useLink == "hard":
|
||||||
try:
|
try:
|
||||||
Logger.info("COPYLINK: Linking %s to %s", filePath, targetDirectory)
|
Logger.info("COPYLINK: Hard linking %s to %s", filePath, targetDirectory)
|
||||||
linktastic.link(filePath, targetDirectory)
|
linktastic.link(filePath, targetDirectory)
|
||||||
except:
|
except:
|
||||||
if os.path.isfile(targetDirectory):
|
if os.path.isfile(targetDirectory):
|
||||||
|
@ -161,6 +161,19 @@ def copy_link(filePath, targetDirectory, useLink, outputDestination):
|
||||||
Logger.info("COPYLINK: Something went wrong in linktastic.link, copying instead")
|
Logger.info("COPYLINK: Something went wrong in linktastic.link, copying instead")
|
||||||
Logger.debug("COPYLINK: Copying %s to %s", filePath, targetDirectory)
|
Logger.debug("COPYLINK: Copying %s to %s", filePath, targetDirectory)
|
||||||
shutil.copy(filePath, targetDirectory)
|
shutil.copy(filePath, targetDirectory)
|
||||||
|
elif useLink == "sym":
|
||||||
|
try:
|
||||||
|
Logger.info("COPYLINK: Moving %s to %s before sym linking", filePath, targetDirectory)
|
||||||
|
shutil.move(filePath, targetDirectory)
|
||||||
|
Logger.info("COPYLINK: Sym linking %s to %s", targetDirectory, filePath)
|
||||||
|
linktastic.symlink(targetDirectory, filePath)
|
||||||
|
except:
|
||||||
|
if os.path.isfile(targetDirectory):
|
||||||
|
Logger.info("COPYLINK: Something went wrong in linktastic.link, but the destination file was created")
|
||||||
|
else:
|
||||||
|
Logger.info("COPYLINK: Something went wrong in linktastic.link, copying instead")
|
||||||
|
Logger.debug("COPYLINK: Copying %s to %s", filePath, targetDirectory)
|
||||||
|
shutil.copy(filePath, targetDirectory)
|
||||||
else:
|
else:
|
||||||
Logger.debug("Copying %s to %s", filePath, targetDirectory)
|
Logger.debug("Copying %s to %s", filePath, targetDirectory)
|
||||||
shutil.copy(filePath, targetDirectory)
|
shutil.copy(filePath, targetDirectory)
|
||||||
|
|
|
@ -79,8 +79,8 @@ web_root =
|
||||||
[Torrent]
|
[Torrent]
|
||||||
###### clientAgent - Supported clients: utorrent, transmission, deluge, other
|
###### clientAgent - Supported clients: utorrent, transmission, deluge, other
|
||||||
clientAgent = other
|
clientAgent = other
|
||||||
###### useLink - Set to 1 to use or 0 depending on if you want to use hardlinks
|
###### useLink - Set to hard for physical links, sym for symbolic links, and no to not use links
|
||||||
useLink = 1
|
useLink = hard
|
||||||
###### minSampleSize - Minimum required size to consider a file not an sample file (in MB, eg 200mb)
|
###### minSampleSize - Minimum required size to consider a file not an sample file (in MB, eg 200mb)
|
||||||
minSampleSize = 200
|
minSampleSize = 200
|
||||||
###### outputDirectory - Default output directory (categories will be appended as sub directory to outputDirectory)
|
###### outputDirectory - Default output directory (categories will be appended as sub directory to outputDirectory)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue