tagging fixes
This commit is contained in:
1 parent
6abc4cc549
commit
89f7cfb896
1 file changed
+20
-13
@@ -555,12 +555,12 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
|||||||
|
|
||||||
# Tag movie files if they are known
|
# Tag movie files if they are known
|
||||||
if isinstance(group, dict):
|
if isinstance(group, dict):
|
||||||
tag_files = sorted(list(group['files']['movie']))[0]
|
tag_files = [sorted(list(group['files']['movie']))[0]]
|
||||||
|
|
||||||
elif isinstance(release_download, dict):
|
elif isinstance(release_download, dict):
|
||||||
# Tag download_files if they are known
|
# Tag download_files if they are known
|
||||||
if release_download['files']:
|
if release_download['files']:
|
||||||
tag_files = release_download['files']
|
tag_files = release_download['files'].split('|')
|
||||||
|
|
||||||
# Tag all files in release folder
|
# Tag all files in release folder
|
||||||
else:
|
else:
|
||||||
@@ -568,36 +568,42 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
|||||||
tag_files.extend([os.path.join(root, name) for name in names])
|
tag_files.extend([os.path.join(root, name) for name in names])
|
||||||
|
|
||||||
for filename in tag_files:
|
for filename in tag_files:
|
||||||
self.createFile('%s.%s.ignore' % (os.path.splitext(filename)[0], tag), text)
|
tag_filename = '%s.%s.ignore' % (os.path.splitext(filename)[0], tag)
|
||||||
|
if not os.path.isfile(tag_filename):
|
||||||
|
self.createFile(tag_filename, text)
|
||||||
|
|
||||||
def untagRelease(self, release_download, tag = ''):
|
def untagRelease(self, release_download, tag = ''):
|
||||||
if not release_download:
|
if not release_download:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
tag_files = []
|
||||||
|
|
||||||
folder = release_download['folder']
|
folder = release_download['folder']
|
||||||
if not os.path.isdir(folder):
|
if not os.path.isdir(folder):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Untag download_files if they are known
|
# Untag download_files if they are known
|
||||||
if release_download['files']:
|
if release_download['files']:
|
||||||
tag_files = release_download['files']
|
tag_files = release_download['files'].split('|')
|
||||||
|
|
||||||
# Untag all files in release folder
|
# Untag all files in release folder
|
||||||
else:
|
else:
|
||||||
tag_files = []
|
|
||||||
for root, folders, names in os.walk(release_download['folder']):
|
for root, folders, names in os.walk(release_download['folder']):
|
||||||
tag_files.extend([os.path.join(root, name) for name in names if not os.path.splitext(name)[1] == '.ignore'])
|
tag_files.extend([os.path.join(root, name) for name in names if not os.path.splitext(name)[1] == '.ignore'])
|
||||||
|
|
||||||
# Find all .ignore files in folder
|
# Find all .ignore files in folder
|
||||||
ignore_files = []
|
ignore_files = []
|
||||||
for root, dirnames, filenames in os.walk(folder):
|
for root, dirnames, filenames in os.walk(folder):
|
||||||
ignore_files.extend([fnmatch.filter([os.path.join(root, filename) for filename in filenames], '*%s.ignore' % tag)])
|
ignore_files.extend(fnmatch.filter([os.path.join(root, filename) for filename in filenames], '*%s.ignore' % tag))
|
||||||
|
|
||||||
# Match all found ignore files with the tag_files and delete if found
|
# Match all found ignore files with the tag_files and delete if found
|
||||||
for tag_file in tag_files:
|
for tag_file in tag_files:
|
||||||
ignore_file = fnmatch.filter(ignore_files, '%s.%s.ignore' % (os.path.splitext(tag_file)[0], tag if tag else '*'))
|
ignore_file = fnmatch.filter(ignore_files, '%s.%s.ignore' % (os.path.splitext(tag_file)[0], tag if tag else '*'))
|
||||||
if ignore_file:
|
for filename in ignore_file:
|
||||||
os.remove(ignore_file)
|
try:
|
||||||
|
os.remove(filename)
|
||||||
|
except:
|
||||||
|
log.debug('Unable to remove ignore file: %s' % (filename, traceback.format_exc()))
|
||||||
|
|
||||||
def hastagRelease(self, release_download, tag = ''):
|
def hastagRelease(self, release_download, tag = ''):
|
||||||
if not release_download:
|
if not release_download:
|
||||||
@@ -607,20 +613,21 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
|||||||
if not os.path.isdir(folder):
|
if not os.path.isdir(folder):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
tag_files = []
|
||||||
|
ignore_files = []
|
||||||
|
|
||||||
# Find tag on download_files if they are known
|
# Find tag on download_files if they are known
|
||||||
if release_download['files']:
|
if release_download['files']:
|
||||||
tag_files = release_download['files']
|
tag_files = release_download['files'].split('|')
|
||||||
|
|
||||||
# Find tag on all files in release folder
|
# Find tag on all files in release folder
|
||||||
else:
|
else:
|
||||||
tag_files = []
|
|
||||||
for root, folders, names in os.walk(release_download['folder']):
|
for root, folders, names in os.walk(release_download['folder']):
|
||||||
tag_files.extend([os.path.join(root, name) for name in names if not os.path.splitext(name)[1] == '.ignore'])
|
tag_files.extend([os.path.join(root, name) for name in names if not os.path.splitext(name)[1] == '.ignore'])
|
||||||
|
|
||||||
# Find all .ignore files in folder
|
# Find all .ignore files in folder
|
||||||
ignore_files = []
|
|
||||||
for root, dirnames, filenames in os.walk(folder):
|
for root, dirnames, filenames in os.walk(folder):
|
||||||
ignore_files.extend([fnmatch.filter([os.path.join(root, filename) for filename in filenames], '*%s.ignore' % tag)])
|
ignore_files.extend(fnmatch.filter([os.path.join(root, filename) for filename in filenames], '*%s.ignore' % tag))
|
||||||
|
|
||||||
# Match all found ignore files with the tag_files and return True found
|
# Match all found ignore files with the tag_files and return True found
|
||||||
for tag_file in tag_files:
|
for tag_file in tag_files:
|
||||||
@@ -950,7 +957,7 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
|||||||
#Extract all found archives
|
#Extract all found archives
|
||||||
for archive in archives:
|
for archive in archives:
|
||||||
# Check if it has already been processed by CPS
|
# Check if it has already been processed by CPS
|
||||||
if self.hastagRelease(release_download = {'folder': os.path.dirname(archive['file']), 'files': [archive['file']]}):
|
if self.hastagRelease(release_download = {'folder': os.path.dirname(archive['file']), 'files': archive['file']}):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Find all related archive files
|
# Find all related archive files
|
||||||
|
|||||||
Reference in new issue
Block a user