mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-13 18:16:52 -07:00
Fixed issues in the nzbTo* scripts with manual runs not properly sending the categories to be processed.
Fixed issue in TorrentToMedia with noFlatten variable for HeadPhones. Changed name of function get_categories to get_sections in nzbToMediaUtil. Added code in get_dirnames to properly return back the directory could not find anything to process in.
This commit is contained in:
parent
2791139c6b
commit
c3410fba8f
10 changed files with 70 additions and 72 deletions
|
@ -131,7 +131,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
|
||||
Logger.debug("MAIN: Scanning files in directory: %s", inputDirectory)
|
||||
|
||||
noFlatten.extend(config.get_categories(["HeadPhones"]).values()) # Make sure we preserve folder structure for HeadPhones.
|
||||
noFlatten.extend(list(chain.from_iterable(config.get_sections(["HeadPhones"]).values()))) # Make sure we preserve folder structure for HeadPhones.
|
||||
|
||||
outputDestinationMaster = outputDestination # Save the original, so we can change this within the loop below, and reset afterwards.
|
||||
now = datetime.datetime.now()
|
||||
|
@ -173,7 +173,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
continue # This file has not been recently moved or created, skip it
|
||||
|
||||
if fileExtension in mediaContainer: # If the file is a video file
|
||||
if is_sample(filePath, inputName, minSampleSize, SampleIDs) and not inputCategory in config.get_categories(["HeadPhones"]).values(): # Ignore samples
|
||||
if is_sample(filePath, inputName, minSampleSize, SampleIDs) and not inputCategory in config.get_sections(["HeadPhones"]).values(): # Ignore samples
|
||||
Logger.info("MAIN: Ignoring sample file: %s ", filePath)
|
||||
continue
|
||||
else:
|
||||
|
@ -209,7 +209,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
except:
|
||||
Logger.exception("MAIN: Extraction failed for: %s", file)
|
||||
continue
|
||||
elif not inputCategory in list(chain.from_iterable(config.get_categories(['CouchPotato','SickBeard']).values())): #process all for non-video categories.
|
||||
elif not inputCategory in list(chain.from_iterable(config.get_sections(['CouchPotato','SickBeard']).values())): #process all for non-video categories.
|
||||
Logger.info("MAIN: Found file %s for category %s", filePath, inputCategory)
|
||||
copy_link(filePath, targetDirectory, useLink, outputDestination)
|
||||
copy_list.append([filePath, os.path.join(outputDestination, file)])
|
||||
|
@ -223,7 +223,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
flatten(outputDestination)
|
||||
|
||||
# Now check if movie files exist in destination:
|
||||
if inputCategory in list(chain.from_iterable(config.get_categories(['CouchPotato','SickBeard']).values())):
|
||||
if inputCategory in list(chain.from_iterable(config.get_sections(['CouchPotato','SickBeard']).values())):
|
||||
for dirpath, dirnames, filenames in os.walk(outputDestination):
|
||||
for file in filenames:
|
||||
filePath = os.path.join(dirpath, file)
|
||||
|
@ -248,7 +248,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
if (inputCategory in user_script_categories and not "NONE" in user_script_categories) or ("ALL" in user_script_categories and not inputCategory in processCategories):
|
||||
Logger.info("MAIN: Processing user script %s.", user_script)
|
||||
result = external_script(outputDestination,inputName,inputCategory)
|
||||
elif status == int(0) or (inputCategory in list(chain.from_iterable(config.get_categories(['HeadPhones','Mylar','Gamez']).values()))): # if movies linked/extracted or for other categories.
|
||||
elif status == int(0) or (inputCategory in list(chain.from_iterable(config.get_sections(['HeadPhones','Mylar','Gamez']).values()))): # if movies linked/extracted or for other categories.
|
||||
Logger.debug("MAIN: Calling autoProcess script for successful download.")
|
||||
status = int(0) # hp, my, gz don't support failed.
|
||||
else:
|
||||
|
@ -435,7 +435,7 @@ if __name__ == "__main__":
|
|||
minSampleSize = int(config()["Extensions"]["minSampleSize"]) # 200 (in MB)
|
||||
SampleIDs = (config()["Extensions"]["SampleIDs"]) # sample,-s.
|
||||
|
||||
sections = config.get_categories(["CouchPotato", "SickBeard", "HeadPhones", "Mylar", "Gamez"])
|
||||
sections = config.get_sections(["CouchPotato", "SickBeard", "HeadPhones", "Mylar", "Gamez"])
|
||||
categories += list(chain.from_iterable(sections.values()))
|
||||
|
||||
user_script_categories = config()["UserScript"]["user_script_categories"] # NONE
|
||||
|
|
|
@ -149,7 +149,7 @@ else:
|
|||
sys.exit(-1)
|
||||
|
||||
# setup sections and categories
|
||||
categories = config.get_categories(["CouchPotato"])
|
||||
sections = config.get_sections(["CouchPotato"])
|
||||
|
||||
WakeUp()
|
||||
|
||||
|
@ -239,13 +239,13 @@ else:
|
|||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||
Logger.info("MAIN: Running autoProcessMovie as a manual run...")
|
||||
|
||||
for section, category in categories.items():
|
||||
for dirName in get_dirnames(section, category):
|
||||
for section, categories in sections.items():
|
||||
for category in categories:
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: Calling " + section + ":" + category + " to post-process: %s", dirName)
|
||||
results = autoProcessMovie().process(dirName, dirName, 0)
|
||||
if results != 0:
|
||||
result = 1
|
||||
Logger.info("MAIN: A problem was reported in the autoProcessMovie script.")
|
||||
results = autoProcessMovie().process(dirName, dirName, 0, inputCategory=category)
|
||||
if results != 0:result = results
|
||||
|
||||
if result == 0:
|
||||
Logger.info("MAIN: The autoProcessMovie script completed successfully.")
|
||||
|
|
|
@ -84,7 +84,7 @@ else:
|
|||
sys.exit(-1)
|
||||
|
||||
# gamez category
|
||||
categories = config.get_categories(['Gamez'])
|
||||
sections = config.get_sections(['Gamez'])
|
||||
|
||||
WakeUp()
|
||||
|
||||
|
@ -166,13 +166,13 @@ else:
|
|||
Logger.warn("MAIN: Invalid number of arguments received from client. Exiting")
|
||||
Logger.info("MAIN: Running autoProcessGames as a manual run...")
|
||||
|
||||
for section, category in categories.items():
|
||||
for dirName in get_dirnames(section, category):
|
||||
for section, categories in sections.items():
|
||||
for category in categories:
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: Calling " + section + ":" + category + " to post-process: %s", dirName)
|
||||
results = autoProcessGames().process(dirName, dirName, 0)
|
||||
if results != 0:
|
||||
result = 1
|
||||
Logger.info("MAIN: A problem was reported in the autoProcessGames script.")
|
||||
results = autoProcessGames().process(dirName, dirName, 0, inputCategory=category)
|
||||
if results != 0:result = results
|
||||
|
||||
if result == 0:
|
||||
Logger.info("MAIN: The autoProcessGames script completed successfully.")
|
||||
|
|
|
@ -97,7 +97,7 @@ else:
|
|||
sys.exit(-1)
|
||||
|
||||
# headphones category
|
||||
categories = config.get_categories(["HeadPhones"])
|
||||
sections = config.get_sections(["HeadPhones"])
|
||||
|
||||
WakeUp()
|
||||
|
||||
|
@ -179,13 +179,13 @@ else:
|
|||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||
Logger.info("MAIN: Running autoProcessMusic as a manual run...")
|
||||
|
||||
for section, category in categories.items():
|
||||
for dirName in get_dirnames(section, category):
|
||||
for section, categories in sections.items():
|
||||
for category in categories:
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: Calling " + section + ":" + category + " to post-process: %s", dirName)
|
||||
results = autoProcessMusic().process(dirName, dirName, 0)
|
||||
if results != 0:
|
||||
result = 1
|
||||
Logger.info("MAIN: A problem was reported in the autoProcessMusic script.")
|
||||
results = autoProcessMusic().process(dirName, dirName, 0, inputCategory=category)
|
||||
if results != 0:result = results
|
||||
|
||||
if result == 0:
|
||||
Logger.info("MAIN: The autoProcessMusic script completed successfully.")
|
||||
|
@ -195,3 +195,4 @@ else:
|
|||
Logger.info("MAIN: A problem was reported in the autoProcessMusic script.")
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'): # return code for nzbget v11
|
||||
sys.exit(config.NZBGET_POSTPROCESS_ERROR)
|
||||
|
||||
|
|
|
@ -362,7 +362,7 @@ else:
|
|||
sys.exit(-1)
|
||||
|
||||
# setup sections and categories
|
||||
sections = config.get_categories(["CouchPotato","SickBeard","HeadPhones","Mylar","Gamez"])
|
||||
sections = config.get_sections(["CouchPotato","SickBeard","HeadPhones","Mylar","Gamez"])
|
||||
|
||||
WakeUp()
|
||||
|
||||
|
@ -454,9 +454,11 @@ else:
|
|||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||
for section, categories in sections.items():
|
||||
for category in categories:
|
||||
dirnames = get_dirnames(section, category)
|
||||
dirNames = get_dirnames(section, category)
|
||||
Logger.info("MAIN: Running " + section + ":" + category + " as a manual run...")
|
||||
if process(dirnames, inputName=dirnames, status=0, inputCategory=category, clientAgent = "manual") != 0:
|
||||
results = process(dirNames, inputName=dirNames, status=0, inputCategory=category, clientAgent = "manual")
|
||||
if results != 0:
|
||||
result = results
|
||||
Logger.info("MAIN: A problem was reported when trying to manually run " + section + ":" + category + ".")
|
||||
|
||||
if result == 0:
|
||||
|
|
|
@ -89,7 +89,7 @@ else:
|
|||
sys.exit(-1)
|
||||
|
||||
# mylar category
|
||||
categories = config.get_categories(["Mylar"])
|
||||
sections = config.get_sections(["Mylar"])
|
||||
|
||||
WakeUp()
|
||||
|
||||
|
@ -171,13 +171,13 @@ else:
|
|||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||
Logger.info("MAIN: Running autoProcessComics as a manual run...")
|
||||
|
||||
for section, category in categories.items():
|
||||
for dirName in get_dirnames(section, category):
|
||||
for section, categories in sections.items():
|
||||
for category in categories:
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: Calling " + section + ":" + category + " to post-process: %s", dirName)
|
||||
results = autoProcessComics().processEpisode(dirName, dirName, 0)
|
||||
if results != 0:
|
||||
result = 1
|
||||
Logger.info("MAIN: A problem was reported in the autoProcessComics script.")
|
||||
results = autoProcessComics().processEpisode(dirName, dirName, 0, inputCategory=category)
|
||||
if results != 0:result = results
|
||||
|
||||
if result == 0:
|
||||
Logger.info("MAIN: The autoProcessComics script completed successfully.")
|
||||
|
|
|
@ -151,7 +151,7 @@ else:
|
|||
sys.exit(-1)
|
||||
|
||||
# sickbeard category
|
||||
categories = config.get_categories(["SickBeard"])
|
||||
sections = config.get_sections(["SickBeard"])
|
||||
|
||||
WakeUp()
|
||||
|
||||
|
@ -236,13 +236,13 @@ else:
|
|||
Logger.debug("MAIN: Invalid number of arguments received from client.")
|
||||
Logger.info("MAIN: Running autoProcessTV as a manual run...")
|
||||
|
||||
for section, category in categories.items():
|
||||
for dirName in get_dirnames(section, category):
|
||||
for section, categories in sections.items():
|
||||
for category in categories:
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: Calling " + section + ":" + category + " to post-process: %s", dirName)
|
||||
results = autoProcessTV().processEpisode(dirName, dirName, 0)
|
||||
if results != 0:
|
||||
result = 1
|
||||
Logger.info("MAIN: A problem was reported in the autoProcessTV script.")
|
||||
results = autoProcessTV().processEpisode(dirName, dirName, 0, inputCategory=category)
|
||||
if results != 0:result = results
|
||||
|
||||
if result == 0:
|
||||
Logger.info("MAIN: The autoProcessTV script completed successfully.")
|
||||
|
|
|
@ -14,6 +14,7 @@ from nzbtomedia.nzbToMediaUtil import getDirectorySize, convert_to_ascii
|
|||
Logger = logging.getLogger()
|
||||
|
||||
class autoProcessMovie:
|
||||
|
||||
def get_imdb(self, nzbName, dirName):
|
||||
imdbid = ""
|
||||
|
||||
|
@ -41,18 +42,18 @@ class autoProcessMovie:
|
|||
|
||||
def get_movie_info(self, baseURL, imdbid, download_id):
|
||||
|
||||
movie_id = ""
|
||||
movie_id = None
|
||||
movie_status = None
|
||||
release_status = None
|
||||
if not imdbid and not download_id:
|
||||
return movie_id, imdbid, download_id, movie_status, release_status
|
||||
|
||||
releaselist = []
|
||||
movieid = []
|
||||
moviestatus = []
|
||||
library = []
|
||||
release = []
|
||||
offset = int(0)
|
||||
release_status = None
|
||||
|
||||
if not imdbid and not download_id:
|
||||
return movie_id, imdbid, download_id, movie_status, release_status
|
||||
|
||||
while True:
|
||||
url = baseURL + "media.list/?status=active&release_status=snatched&limit_offset=50," + str(offset)
|
||||
|
||||
|
@ -64,10 +65,7 @@ class autoProcessMovie:
|
|||
Logger.exception("Unable to open URL")
|
||||
break
|
||||
|
||||
movieid2 = []
|
||||
library2 = []
|
||||
release2 = []
|
||||
moviestatus2 = []
|
||||
try:
|
||||
result = r.json()
|
||||
movieid2 = [item["_id"] for item in result["movies"]]
|
||||
|
@ -78,7 +76,7 @@ class autoProcessMovie:
|
|||
library2.append(item["identifiers"]["imdb"])
|
||||
release2 = [item["releases"] for item in result["movies"]]
|
||||
moviestatus2 = [item["status"] for item in result["movies"]]
|
||||
except:
|
||||
except Exception, e:
|
||||
Logger.exception("Unable to parse json data for movies")
|
||||
break
|
||||
|
||||
|
@ -86,11 +84,11 @@ class autoProcessMovie:
|
|||
moviestatus.extend(moviestatus2)
|
||||
library.extend(library2)
|
||||
release.extend(release2)
|
||||
|
||||
if len(movieid2) < int(50): # finished parsing list of movies. Time to break.
|
||||
break
|
||||
offset = offset + 50
|
||||
|
||||
result = None # reset
|
||||
for index in range(len(movieid)):
|
||||
releaselist1 = [item for item in release[index] if item["status"] == "snatched" and "download_info" in item]
|
||||
if download_id:
|
||||
|
|
|
@ -47,7 +47,7 @@ class config(object):
|
|||
return
|
||||
|
||||
@staticmethod
|
||||
def get_categories(section):
|
||||
def get_sections(section):
|
||||
sections = {}
|
||||
|
||||
# check and return categories if section does exist
|
||||
|
@ -58,8 +58,3 @@ class config(object):
|
|||
if config().has_key(x):
|
||||
sections.update({x: config()[x].sections})
|
||||
return sections
|
||||
|
||||
@staticmethod
|
||||
def gather_subsection(section, key):
|
||||
if section.depth > 1:
|
||||
return section.name
|
|
@ -451,13 +451,13 @@ def parse_args(clientAgent):
|
|||
|
||||
return clients[clientAgent](sys.argv)
|
||||
|
||||
def get_dirnames(section, category):
|
||||
def get_dirnames(section, inputCategory):
|
||||
try:
|
||||
watch_dir = config()[section][inputCategory]["watch_dir"]
|
||||
except:
|
||||
watch_dir = ""
|
||||
try:
|
||||
outputDirectory = os.path.join(config()["Torrent"]["outputDirectory"], category)
|
||||
outputDirectory = os.path.join(config()["Torrent"]["outputDirectory"], inputCategory)
|
||||
except:
|
||||
outputDirectory = ""
|
||||
|
||||
|
@ -467,13 +467,15 @@ def get_dirnames(section, category):
|
|||
if os.path.exists(watch_dir):
|
||||
dirNames.extend([os.path.join(watch_dir, o) for o in os.listdir(watch_dir) if
|
||||
os.path.isdir(os.path.join(watch_dir, o))])
|
||||
if not dirNames:
|
||||
Logger.warn("No Directories identified to Scan inside " + watch_dir)
|
||||
|
||||
if outputDirectory != "":
|
||||
if os.path.exists(outputDirectory):
|
||||
dirNames.extend([os.path.join(outputDirectory, o) for o in os.listdir(outputDirectory) if
|
||||
os.path.isdir(os.path.join(outputDirectory, o))])
|
||||
|
||||
if not dirNames:
|
||||
Logger.warn("No Directories identified to Scan.")
|
||||
Logger.warn("No Directories identified to Scan inside " + outputDirectory)
|
||||
|
||||
return dirNames
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue