mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 10:36:52 -07:00
Merge branch 'clinton-hall/dev-CH'
Made some minor code corrections.
This commit is contained in:
commit
e82abc3b01
8 changed files with 24 additions and 13 deletions
|
@ -151,6 +151,9 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
if not inputCategory in nzbtomedia.NOFLATTEN: #don't flatten hp in case multi cd albums, and we need to copy this back later.
|
||||
flatten(outputDestination)
|
||||
|
||||
if os.name == 'nt': # remove Read Only flag from files in Windows.
|
||||
remove_read_only(outputDestination)
|
||||
|
||||
# Now check if video files exist in destination:
|
||||
if nzbtomedia.CFG["SickBeard","NzbDrone", "CouchPotato"].issubsection(inputCategory):
|
||||
for dirpath, dirnames, filenames in os.walk(outputDestination):
|
||||
|
|
|
@ -424,9 +424,8 @@ else:
|
|||
result = 0
|
||||
|
||||
# init sub-sections
|
||||
subsections = nzbtomedia.CFG["CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez"].subsections
|
||||
logger.warning("Invalid number of arguments received from client.")
|
||||
for section, subsection in subsections.items():
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS.items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
|
|
|
@ -154,7 +154,7 @@ else:
|
|||
|
||||
subsections = nzbtomedia.CFG["Mylar"].subsections
|
||||
logger.warning("Invalid number of arguments received from client.")
|
||||
for section, subsection in subsections.items():
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS['Mylar'].items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
|
|
|
@ -182,9 +182,8 @@ elif len(sys.argv) >= nzbtomedia.SABNZB_0717_NO_OF_ARGUMENTS:
|
|||
else:
|
||||
result = 0
|
||||
|
||||
subsections = nzbtomedia.CFG["NzbDrone"].subsections
|
||||
logger.warning("Invalid number of arguments received from client.")
|
||||
for section, subsection in subsections.items():
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS['NzbDrone'].items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
|
|
|
@ -215,9 +215,8 @@ elif len(sys.argv) >= nzbtomedia.SABNZB_0717_NO_OF_ARGUMENTS:
|
|||
else:
|
||||
result = 0
|
||||
|
||||
subsections = nzbtomedia.CFG["SickBeard"].subsections
|
||||
logger.warning("Invalid number of arguments received from client.")
|
||||
for section, subsection in subsections.items():
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS['SickBeard'].items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
|
|
|
@ -32,7 +32,7 @@ class Sections(dict):
|
|||
# returns {section name:[subsections]}
|
||||
to_return = {}
|
||||
for section in sections:
|
||||
to_return.update(sections[section].subsections)
|
||||
to_return.update({section:sections[section].subsections})
|
||||
return to_return
|
||||
|
||||
class Section(lib.configobj.Section):
|
||||
|
@ -58,7 +58,7 @@ class Section(lib.configobj.Section):
|
|||
# returns {section name:[subsections]}
|
||||
to_return = {}
|
||||
for subsection in section:
|
||||
to_return.update({section.name: section.sections})
|
||||
to_return.update({subsection:section[subsection]})
|
||||
return to_return
|
||||
|
||||
def findsection(section, key):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import re
|
||||
import socket
|
||||
import stat
|
||||
import struct
|
||||
import shutil
|
||||
import sys
|
||||
|
@ -197,12 +198,20 @@ def removeEmptyFolders(path):
|
|||
logger.debug("REMOVER: Removing empty folder: %s", path)
|
||||
os.rmdir(path)
|
||||
|
||||
def remove_read_only(path):
|
||||
if not os.path.isdir(path):
|
||||
return
|
||||
for dirpath, dirnames, filenames in os.walk(path):
|
||||
for filename in filenames:
|
||||
logger.debug("Removing Read Only Flag for: %s", filename)
|
||||
os.chmod(os.path.join(dirpath, filename), stat.S_IWRITE)
|
||||
|
||||
def iterate_media_files(dirname):
|
||||
mediaContainer = [ '.mkv', '.avi', '.divx', '.xvid', '.mov', '.wmv',
|
||||
'.mp4', '.mpg', '.mpeg', '.iso' ]
|
||||
|
||||
for dirpath, dirnames, filesnames in os.walk(dirname):
|
||||
for filename in filesnames:
|
||||
for dirpath, dirnames, filenames in os.walk(dirname):
|
||||
for filename in filenames:
|
||||
fileExtension = os.path.splitext(filename)[1]
|
||||
if not (fileExtension in mediaContainer):
|
||||
continue
|
||||
|
@ -372,7 +381,7 @@ def get_dirnames(section, subsections=None):
|
|||
dirNames = []
|
||||
|
||||
if subsections is None:
|
||||
subsections = nzbtomedia.get_subsections(section).values()
|
||||
subsections = nzbtomedia.CFG[section].subsections.values()
|
||||
|
||||
if not isinstance(subsections, list):
|
||||
subsections = [subsections]
|
||||
|
@ -414,4 +423,4 @@ def delete(dirName):
|
|||
try:
|
||||
shutil.rmtree(dirName, True)
|
||||
except:
|
||||
logger.error("Unable to delete folder %s", dirName)
|
||||
logger.error("Unable to delete folder %s", dirName)
|
||||
|
|
|
@ -5,6 +5,8 @@ from nzbtomedia import logger
|
|||
# Initialize the config
|
||||
nzbtomedia.initialize()
|
||||
|
||||
print nzbtomedia.SUBSECTIONS["SickBeard"].items()
|
||||
print
|
||||
print nzbtomedia.CFG.findsection('tv')
|
||||
print
|
||||
print nzbtomedia.CFG.sections
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue