mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 21:33:13 -07:00
added option to remove read only flags in windows. fixes #317
This commit is contained in:
parent
c431e0e3da
commit
b63ff3c962
2 changed files with 13 additions and 2 deletions
|
@ -158,6 +158,9 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
if not inputCategory in noFlatten: #don't flatten hp in case multi cd albums, and we need to copy this back later.
|
if not inputCategory in noFlatten: #don't flatten hp in case multi cd albums, and we need to copy this back later.
|
||||||
flatten(outputDestination)
|
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:
|
# Now check if video files exist in destination:
|
||||||
if config().issubsection(inputCategory,["SickBeard","NzbDrone","CouchPotato"]):
|
if config().issubsection(inputCategory,["SickBeard","NzbDrone","CouchPotato"]):
|
||||||
for dirpath, dirnames, filenames in os.walk(outputDestination):
|
for dirpath, dirnames, filenames in os.walk(outputDestination):
|
||||||
|
|
|
@ -205,12 +205,20 @@ def removeEmptyFolders(path):
|
||||||
Logger.debug("REMOVER: Removing empty folder: %s", path)
|
Logger.debug("REMOVER: Removing empty folder: %s", path)
|
||||||
os.rmdir(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):
|
def iterate_media_files(dirname):
|
||||||
mediaContainer = [ '.mkv', '.avi', '.divx', '.xvid', '.mov', '.wmv',
|
mediaContainer = [ '.mkv', '.avi', '.divx', '.xvid', '.mov', '.wmv',
|
||||||
'.mp4', '.mpg', '.mpeg', '.iso' ]
|
'.mp4', '.mpg', '.mpeg', '.iso' ]
|
||||||
|
|
||||||
for dirpath, dirnames, filesnames in os.walk(dirname):
|
for dirpath, dirnames, filenames in os.walk(dirname):
|
||||||
for filename in filesnames:
|
for filename in filenames:
|
||||||
fileExtension = os.path.splitext(filename)[1]
|
fileExtension = os.path.splitext(filename)[1]
|
||||||
if not (fileExtension in mediaContainer):
|
if not (fileExtension in mediaContainer):
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue