update plugin
This commit is contained in:
parent
dae29640d2
commit
8f86180f8f
1 changed files with 20 additions and 5 deletions
25
mosireen.py
25
mosireen.py
|
@ -8,11 +8,12 @@
|
||||||
'''
|
'''
|
||||||
import re
|
import re
|
||||||
import ox
|
import ox
|
||||||
|
import os
|
||||||
|
|
||||||
def example_path(client):
|
def example_path(client):
|
||||||
return '\t' + 'YYYY/MM_YYYY/DD_MM_YYYY/Location 1/Location 2/Subject 1/Shooter/Subject 2(optional)/MVI_2036.MOV'
|
return '\t' + 'YYYY/MM_YYYY/DD_MM_YYYY/Location 1/Location 2/Subject 1/Shooter/Subject 2(optional)/MVI_2036.MOV'
|
||||||
|
|
||||||
def parse_path(client, path):
|
def parse_path(client, path, context):
|
||||||
'''
|
'''
|
||||||
args:
|
args:
|
||||||
client - Client instance
|
client - Client instance
|
||||||
|
@ -20,18 +21,20 @@ def parse_path(client, path):
|
||||||
return:
|
return:
|
||||||
return None if file is ignored, dict with parsed item information otherwise
|
return None if file is ignored, dict with parsed item information otherwise
|
||||||
'''
|
'''
|
||||||
m = re.compile('^(\d{4})/(\d{2})_(\d{4})/(?P<day>\d+)_(?P<month>\d+)_(?P<year>\d{4})/(?P<location1>.+?)/(?P<location2>.+?)/(?P<subject1>.+?)/(?P<shooter>.+?)/((?P<subject2>.+?)/|).*').match(path)
|
m = re.compile('^(\d{4})/(\d{2}|NA)_(\d{4})/(?P<day>\d+|NA)_(?P<month>\d+|NA)_(?P<year>\d{4})((-(?P<tilday>\d+|NA)_(?P<tilmonth>\d+|NA)_(?P<tilyear>\d{4}))?)/(?P<location1>.+?)/(?P<location2>.+?)/(?P<subject1>.+?)/(?P<shooter>.+?)/((?P<subject2>.+?)/|).*').match(path)
|
||||||
if not m:
|
if not m:
|
||||||
return None
|
return None
|
||||||
info = m.groupdict()
|
info = m.groupdict()
|
||||||
date = '%s-%s-%s' % (info['year'], info['month'], info['day'])
|
date = '%s-%s-%s' % (info['year'], info['month'], info['day'])
|
||||||
|
if info['tilday']:
|
||||||
|
date = '%s-%s-%s - %s-%s-%s' % (info['year'], info['month'], info['day'], info['tilyear'],info['tilmonth'],info['tilday'])
|
||||||
for key in info:
|
for key in info:
|
||||||
if info[key]:
|
if info[key]:
|
||||||
info[key] = info[key].replace('_', ' ')
|
info[key] = info[key].replace('_', ' ')
|
||||||
|
|
||||||
topic = [info['subject1']]
|
topic = info['subject1'].split(",")
|
||||||
if info['subject2']:
|
if info['subject2']:
|
||||||
topic.append(info['subject2'])
|
topic+=info['subject2'].split(",")
|
||||||
title = "%s, %s (%s)" % (info['subject1'], info['subject2'], date)
|
title = "%s, %s (%s)" % (info['subject1'], info['subject2'], date)
|
||||||
else:
|
else:
|
||||||
title = "%s (%s)" % (info['subject1'], date)
|
title = "%s (%s)" % (info['subject1'], date)
|
||||||
|
@ -50,4 +53,16 @@ def parse_path(client, path):
|
||||||
r[key] = _info[key]
|
r[key] = _info[key]
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def ignore_file(client, path):
|
||||||
|
'''
|
||||||
|
return True if file should not even be considered.
|
||||||
|
i.e. to filter out .DS_Store, empty files
|
||||||
|
'''
|
||||||
|
filename = os.path.basename(path)
|
||||||
|
if filename.startswith('._') \
|
||||||
|
or filename in ('.DS_Store',) \
|
||||||
|
or filename.endswith('~') \
|
||||||
|
or not os.path.exists(path) \
|
||||||
|
or os.stat(path).st_size == 0:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
Loading…
Reference in a new issue