mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 02:26:53 -07:00
use common create_destination
instead of duplicate code in both copylink and extractor
This commit is contained in:
parent
f41b576967
commit
9c34ac2a35
2 changed files with 13 additions and 17 deletions
|
@ -124,22 +124,23 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
|
|||
|
||||
def is_sample(filePath, inputName):
|
||||
# 200 MB in bytes
|
||||
# Maybe let the users change this?
|
||||
SIZE_CUTOFF = minSampleSize * 1024 * 1024
|
||||
# Ignore 'sample' in files unless 'sample' in Torrent Name
|
||||
return ('sample' in filePath.lower()) and (not 'sample' in inputName) and (os.path.getsize(filePath) < SIZE_CUTOFF)
|
||||
|
||||
|
||||
def copy_link(source, target, useLink, outputDestination):
|
||||
# Create destination folder
|
||||
def create_destination(outputDestination)
|
||||
if not os.path.exists(outputDestination):
|
||||
try:
|
||||
Logger.info("COPYLINK: Creating destination folder: %s", outputDestination)
|
||||
Logger.info("CREATE DESTINATION: Creating destination folder: %s", outputDestination)
|
||||
os.makedirs(outputDestination)
|
||||
except Exception, e:
|
||||
Logger.error("COPYLINK: Not possible to create destination folder: %s", e)
|
||||
Logger.error("CREATE DESTINATION: Not possible to create destination folder: %s", e)
|
||||
return False
|
||||
|
||||
|
||||
def copy_link(source, target, useLink, outputDestination):
|
||||
create_destination(outputDestination)
|
||||
if useLink:
|
||||
try:
|
||||
Logger.info("COPYLINK: Linking %s to %s", source, target)
|
||||
|
@ -340,20 +341,20 @@ else:
|
|||
# Hardlink solution with uTorrent
|
||||
if inputHash and useLink:
|
||||
try:
|
||||
Logger.debug("Connecting to uTorrent: %s", uTorrentWEBui)
|
||||
Logger.debug("MAIN: Connecting to uTorrent: %s", uTorrentWEBui)
|
||||
utorrentClass = UTorrentClient(uTorrentWEBui, uTorrentUSR, uTorrentPWD)
|
||||
except:
|
||||
Logger.error("Failed to connect to uTorrent")
|
||||
Logger.debug("MAIN: Stoping torrent %s in uTorrent while processing", inputName)
|
||||
Logger.error("MAIN: Failed to connect to uTorrent")
|
||||
Logger.debug("MAIN: Stoping torrent %s in uTorrent while processing", videofile)
|
||||
utorrentClass.stop(inputHash)
|
||||
time.sleep(5) # Give uTorrent some time to catch up with the change
|
||||
|
||||
# Now we pass off to CouchPotato or Sick-Beard
|
||||
if inputCategory == movieCategory:
|
||||
Logger.info("MAIN: Calling CouchPotatoServer to post-process: %s", inputName) # can we use logger while logfile open?
|
||||
Logger.info("MAIN: Calling CouchPotatoServer to post-process: %s", videofile) # can we use logger while logfile open?
|
||||
autoProcessMovie.process(outputDestination, inputName, status)
|
||||
elif inputCategory == tvCategory:
|
||||
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", inputName) # can we use logger while logfile open?
|
||||
Logger.info("MAIN: Calling Sick-Beard to post-process: %s", videofile) # can we use logger while logfile open?
|
||||
autoProcessTV.processEpisode(outputDestination, inputName, status)
|
||||
|
||||
# Check if the file still exists in the post-process directory
|
||||
|
|
|
@ -100,13 +100,8 @@ def extract(dirpath, file, outputDestination):
|
|||
return False
|
||||
|
||||
# Create outputDestination folder
|
||||
if not os.path.exists(outputDestination):
|
||||
try:
|
||||
Logger.debug("EXTRACTOR: Creating destination folder: %s", outputDestination)
|
||||
os.makedirs(outputDestination)
|
||||
except Exception, e:
|
||||
Logger.error("EXTRACTOR: Not possible to create destination folder: %s", e)
|
||||
return False
|
||||
create_destination(outputDestination)
|
||||
|
||||
Logger.info("Extracting %s to %s", filePath, outputDestination)
|
||||
Logger.debug("Extracting %s %s %s %s", cmd[0], cmd[1], filePath, outputDestination)
|
||||
pwd = os.getcwd() # Get our Present Working Directory
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue