mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 05:13:16 -07:00
add option move-sym to create symlink to renamed files. Fixes #894
This commit is contained in:
parent
a121cb6baf
commit
316cc64075
3 changed files with 24 additions and 4 deletions
|
@ -249,6 +249,10 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
core.update_downloadInfoStatus(inputName, 1)
|
core.update_downloadInfoStatus(inputName, 1)
|
||||||
|
|
||||||
# remove torrent
|
# remove torrent
|
||||||
|
if core.USELINK == 'move-sym' and not core.DELETE_ORIGINAL == 1:
|
||||||
|
inputFiles = core.listMediaFiles(inputDirectory)
|
||||||
|
for link in inputFiles:
|
||||||
|
core.replace_links(link)
|
||||||
core.remove_torrent(clientAgent, inputHash, inputID, inputName)
|
core.remove_torrent(clientAgent, inputHash, inputID, inputName)
|
||||||
|
|
||||||
if not sectionName == 'UserScript': # for user script, we assume this is cleaned by the script or option USER_SCRIPT_CLEAN
|
if not sectionName == 'UserScript': # for user script, we assume this is cleaned by the script or option USER_SCRIPT_CLEAN
|
||||||
|
|
|
@ -221,7 +221,7 @@
|
||||||
[Torrent]
|
[Torrent]
|
||||||
###### clientAgent - Supported clients: utorrent, transmission, deluge, rtorrent, vuze, other
|
###### clientAgent - Supported clients: utorrent, transmission, deluge, rtorrent, vuze, other
|
||||||
clientAgent = other
|
clientAgent = other
|
||||||
###### useLink - Set to hard for physical links, sym for symbolic links, move to move, and no to not use links (copy)
|
###### useLink - Set to hard for physical links, sym for symbolic links, move to move, move-sym to move and link back, and no to not use links (copy)
|
||||||
useLink = hard
|
useLink = hard
|
||||||
###### outputDirectory - Default output directory (categories will be appended as sub directory to outputDirectory)
|
###### outputDirectory - Default output directory (categories will be appended as sub directory to outputDirectory)
|
||||||
outputDirectory = /abs/path/to/complete/
|
outputDirectory = /abs/path/to/complete/
|
||||||
|
|
|
@ -232,10 +232,13 @@ def copy_link(src, targetLink, useLink):
|
||||||
return True
|
return True
|
||||||
elif useLink == "sym":
|
elif useLink == "sym":
|
||||||
logger.info("Sym linking SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK')
|
logger.info("Sym linking SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK')
|
||||||
#shutil.move(src, targetLink)
|
|
||||||
#linktastic.symlink(targetLink, src)
|
|
||||||
linktastic.symlink(src, targetLink)
|
linktastic.symlink(src, targetLink)
|
||||||
return True
|
return True
|
||||||
|
elif useLink == "move-sym":
|
||||||
|
logger.info("Sym linking SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK')
|
||||||
|
shutil.move(src, targetLink)
|
||||||
|
linktastic.symlink(targetLink, src)
|
||||||
|
return True
|
||||||
elif useLink == "move":
|
elif useLink == "move":
|
||||||
logger.info("Moving SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK')
|
logger.info("Moving SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK')
|
||||||
shutil.move(src, targetLink)
|
shutil.move(src, targetLink)
|
||||||
|
@ -248,6 +251,19 @@ def copy_link(src, targetLink, useLink):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def replace_links(link):
|
||||||
|
if not os.path.islink(link):
|
||||||
|
return
|
||||||
|
target = link
|
||||||
|
n = 0
|
||||||
|
while os.path.islink(target):
|
||||||
|
target = os.readlink(target)
|
||||||
|
n = n + 1
|
||||||
|
if n > 1:
|
||||||
|
logger.info("Changing sym-link: %s to point directly to file: %s" % (link, target), 'COPYLINK')
|
||||||
|
os.unlink(link)
|
||||||
|
linktastic.symlink(target, link)
|
||||||
|
|
||||||
def flatten(outputDestination):
|
def flatten(outputDestination):
|
||||||
logger.info("FLATTEN: Flattening directory: %s" % (outputDestination))
|
logger.info("FLATTEN: Flattening directory: %s" % (outputDestination))
|
||||||
for outputFile in listMediaFiles(outputDestination):
|
for outputFile in listMediaFiles(outputDestination):
|
||||||
|
@ -782,7 +798,7 @@ def remove_torrent(clientAgent, inputHash, inputID, inputName):
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
except:
|
except:
|
||||||
logger.warning("Failed to delete torrent %s in %s" % (inputName, clientAgent))
|
logger.warning("Failed to delete torrent %s in %s" % (inputName, clientAgent))
|
||||||
else:
|
else:
|
||||||
resume_torrent(clientAgent, inputHash, inputID, inputName)
|
resume_torrent(clientAgent, inputHash, inputID, inputName)
|
||||||
|
|
||||||
def find_download(clientAgent, download_id):
|
def find_download(clientAgent, download_id):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue