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
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue