don't set root is files in unique dir but still looking for cat. fix #185

This commit is contained in:
clinton-hall 2013-12-02 07:28:48 +10:30
commit c2af80dea0

View file

@ -54,30 +54,32 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
categorySearch = [os.path.normpath(inputDirectory), ""] # initializie categorySearch = [os.path.normpath(inputDirectory), ""] # initializie
notfound = 0 notfound = 0
unique = int(0)
for x in range(10): # loop up through 10 directories looking for category. for x in range(10): # loop up through 10 directories looking for category.
try: try:
categorySearch2 = os.path.split(os.path.normpath(categorySearch[0])) categorySearch2 = os.path.split(os.path.normpath(categorySearch[0]))
except: # this might happen when we can't go higher. except: # this might happen when we can't go higher.
if inputCategory and inputName: # if these exists, we are ok to proceed, but assume we are in a root/common directory. if unique = int(0)
Logger.info("SEARCH: Could not find a category in the directory structure") if inputCategory and inputName: # if these exists, we are ok to proceed, but assume we are in a root/common directory.
Logger.info("SEARCH: We will try and determine which files to process, individually") Logger.info("SEARCH: Could not find a category in the directory structure")
root = 1 Logger.info("SEARCH: We will try and determine which files to process, individually")
break # we are done root = 1
elif inputCategory: # if this exists, we are ok to proceed, but assume we are in a root/common directory and we have to check file dates. break # we are done
Logger.info("SEARCH: Could not find a torrent name or category in the directory structure") elif inputCategory: # if this exists, we are ok to proceed, but assume we are in a root/common directory and we have to check file dates.
Logger.info("SEARCH: We will try and determine which files to process, individually") Logger.info("SEARCH: Could not find a torrent name or category in the directory structure")
root = 2 Logger.info("SEARCH: We will try and determine which files to process, individually")
break # we are done root = 2
elif inputName: # we didn't find category after 10 loops. This is a problem. break # we are done
Logger.info("SEARCH: Could not find a category in the directory structure") elif inputName: # we didn't find category after 10 loops. This is a problem.
Logger.info("SEARCH: Files will be linked and will only be processed by the userscript if enabled for UNCAT or ALL") Logger.info("SEARCH: Could not find a category in the directory structure")
root = 1 Logger.info("SEARCH: Files will be linked and will only be processed by the userscript if enabled for UNCAT or ALL")
break # we are done root = 1
else: # we didn't find this after 10 loops. This is a problem. break # we are done
Logger.info("SEARCH: Could not identify category or torrent name from the directory structure.") else: # we didn't find this after 10 loops. This is a problem.
Logger.info("SEARCH: Files will be linked and will only be processed by the userscript if enabled for UNCAT or ALL") Logger.info("SEARCH: Could not identify category or torrent name from the directory structure.")
root = 2 Logger.info("SEARCH: Files will be linked and will only be processed by the userscript if enabled for UNCAT or ALL")
break # we are done root = 2
break # we are done
if categorySearch2[1] in categories: if categorySearch2[1] in categories:
Logger.debug("SEARCH: Found Category: %s in directory structure", categorySearch2[1]) Logger.debug("SEARCH: Found Category: %s in directory structure", categorySearch2[1])
@ -123,6 +125,7 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
break break
elif inputName and safeName(categorySearch2[1]) == safeName(inputName): # we have identified a unique directory. elif inputName and safeName(categorySearch2[1]) == safeName(inputName): # we have identified a unique directory.
Logger.info("SEARCH: Files appear to be in their own directory") Logger.info("SEARCH: Files appear to be in their own directory")
unique = int(1)
if inputCategory: # we are ok to proceed. if inputCategory: # we are ok to proceed.
break # we are done break # we are done
else: else:
@ -137,7 +140,7 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
categorySearch = categorySearch2 # ready for next loop categorySearch = categorySearch2 # ready for next loop
continue # keep going continue # keep going
if notfound == 1: if notfound == 1 and not unique = int(1):
if inputCategory and inputName: # if these exists, we are ok to proceed, but assume we are in a root/common directory. if inputCategory and inputName: # if these exists, we are ok to proceed, but assume we are in a root/common directory.
Logger.info("SEARCH: Could not find a category in the directory structure") Logger.info("SEARCH: Could not find a category in the directory structure")
Logger.info("SEARCH: We will try and determine which files to process, individually") Logger.info("SEARCH: We will try and determine which files to process, individually")