From e625c48ab23e7d695d383bc252e4fddd3eaaf46f Mon Sep 17 00:00:00 2001 From: j Date: Thu, 8 Jun 2017 13:58:03 +0200 Subject: [PATCH] no NA --- mosireen.py | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/mosireen.py b/mosireen.py index 16872ba..1b22822 100644 --- a/mosireen.py +++ b/mosireen.py @@ -3,7 +3,7 @@ custom parse_path for pandora_client to parse musereen archive paths in the form - YYYY/MM_YYYY/DD_MM_YYYY/Location 1/Location 2/Event/Cinematographer/Topic 2(optional)/MVI_2036.MOV + YYYY/MM_YYYY/DD_MM_YYYY/Location 1/Location 2/Event/Shooter/Topic 2(optional)/MVI_2036.MOV ''' import re @@ -23,7 +23,7 @@ def parse_path(client, path, context): return: return None if file is ignored, dict with parsed item information otherwise ''' - m = re.compile('^(\d{4})/(\d{2}|NA)_(\d{4})/(?P\d+|NA)_(?P\d+|NA)_(?P\d{4})((-(?P\d+|NA)_(?P\d+|NA)_(?P\d{4}))?)/(?P.+?)/(?P.+?)/(?P.+?)/(?P.+?)/((?P.+?)/|).*').match(path) + m = re.compile('^(\d{4}|NA)/(\d{2}|NA)_(\d{4}|NA)/(?P\d+|NA)_(?P\d+|NA)_(?P\d{4}|NA)((-(?P\d+|NA)_(?P\d+|NA)_(?P\d{4}))?)/(?P.+?)/(?P.+?)/(?P.+?)/(?P.+?)/((?P.+?)/|).*').match(path) if not m: return None info = m.groupdict() @@ -34,27 +34,38 @@ def parse_path(client, path, context): if info[key]: info[key] = info[key].replace('_', ' ') + while date.endswith('-NA'): + date = date[:-3] + if date == 'NA': + date = '' + + title_date = ' (%s)' % date if date else '' + topic = info['subject1'].split(",") if info['subject2']: topic += info['subject2'].split(",") - title = "%s, %s (%s)" % (info['subject1'], info['subject2'], date) + title = "%s, %s%s" % (info['subject1'], info['subject2'], title_date) else: - title = "%s (%s)" % (info['subject1'], date) + title = "%s%s" % (info['subject1'], title_date) - while date.endswith('-NA'): - date = date[:-3] - title = "%s %s at %s, %s" % (title, info['shooter'], info['location2'], info['location1']) - title = title.replace(' ', ' ').strip() - title = title.replace(' ', ' ').strip() - - topic = [t.strip() for t in topic] - shooter = [s.strip() for s in info['shooter'].split(',')] - - location = '%s, %s' % (info['location2'], info['location1']) + ''' + if info['shooter'] != 'NA': + title = "%s %s" % (title, info['shooter']) + ''' + location = [info['location2'], info['location1']] + location = ', '.join([l.strip() for l in location if l.strip() != 'NA']) location = location.strip() + if location: + title += ' at ' + location + title = title.replace(' ', ' ').strip() + title = title.replace(' ', ' ').strip() + + topic = [t.strip() for t in topic if t.strip() != 'NA'] + shooter = [s.strip() for s in info['shooter'].split(',') if s.strip() != 'NA'] + r = { - 'cinematographer': shooter, + 'shooter': shooter, 'date': date, 'location': location, 'title': title, @@ -74,7 +85,8 @@ def ignore_file(client, path): if filename.startswith('._') \ or filename in ( '.DS_Store', 'Thumbs.db', - 'CINDEX.TMP', 'THUMB.TDT', 'THUMB.TID' + 'CINDEX.TMP', 'THUMB.TDT', 'THUMB.TID', + 'S_INDEX.DAT', ) \ or filename.endswith('~') \ or 'Autosave Vault' in path \ @@ -83,7 +95,7 @@ def ignore_file(client, path): or os.path.splitext(filename.lower())[-1] in ( '.thm', '.rtf', '.sfk', '.fcp', '.xmp', '.prproj', '.ctg', '.cpi', '.bdm', '.mpl', '.html', '.txt', - '.doc', '.xml', '.psd', '.pds', + '.doc', '.xml', '.psd', '.pds', '.qtindex', '.lnk', ) \ or not os.path.exists(path) \ or os.stat(path).st_size == 0: