2013-04-24 17:42:47 +00:00
|
|
|
'''
|
|
|
|
mosireen.py - pandora_client plugin
|
|
|
|
|
|
|
|
custom parse_path for pandora_client to parse musereen archive paths in the form
|
|
|
|
|
2013-04-24 22:53:53 +00:00
|
|
|
YYYY/MM_YYYY/DD_MM_YYYY/Location 1/Location 2/Subject 1/Cinematographer/Subject 2(optional)/MVI_2036.MOV
|
2013-04-24 17:42:47 +00:00
|
|
|
|
|
|
|
'''
|
|
|
|
import re
|
2013-04-24 22:53:53 +00:00
|
|
|
import ox
|
2013-04-24 17:42:47 +00:00
|
|
|
|
|
|
|
def example_path(client):
|
2013-04-24 22:53:53 +00:00
|
|
|
return '\t' + 'YYYY/MM_YYYY/DD_MM_YYYY/Location 1/Location 2/Subject 1/Shooter/Subject 2(optional)/MVI_2036.MOV'
|
2013-04-24 17:42:47 +00:00
|
|
|
|
|
|
|
def parse_path(client, path):
|
|
|
|
'''
|
|
|
|
args:
|
|
|
|
client - Client instance
|
|
|
|
path - path without volume prefix
|
|
|
|
return:
|
|
|
|
return None if file is ignored, dict with parsed item information otherwise
|
|
|
|
'''
|
2013-04-24 22:53:53 +00:00
|
|
|
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)
|
2013-04-24 17:42:47 +00:00
|
|
|
if not m:
|
|
|
|
return None
|
2013-04-24 22:53:53 +00:00
|
|
|
info = m.groupdict()
|
|
|
|
date = '%s-%s-%s' % (info['year'], info['month'], info['day'])
|
|
|
|
for key in info:
|
|
|
|
if info[key]:
|
|
|
|
info[key] = info[key].replace('_', ' ')
|
|
|
|
|
|
|
|
topic = [info['subject1']]
|
|
|
|
if info['subject2']:
|
|
|
|
topic.append(info['subject2'])
|
|
|
|
title = "%s, %s (%s)" % (info['subject1'], info['subject2'], date)
|
|
|
|
else:
|
|
|
|
title = "%s (%s)" % (info['subject1'], date)
|
2013-12-02 17:26:38 +00:00
|
|
|
title = "%s %s at %s, %s" % (title,
|
|
|
|
info['shooter'],info['location2'],info['location1'])
|
2013-04-24 22:53:53 +00:00
|
|
|
|
|
|
|
r = {
|
|
|
|
'cinematographer': [info['shooter']],
|
2013-04-24 17:42:47 +00:00
|
|
|
'date': date,
|
2013-04-24 22:53:53 +00:00
|
|
|
'location': '%s, %s' % (info['location2'], info['location1']),
|
|
|
|
'title': title,
|
|
|
|
'topic': topic
|
2013-04-24 17:42:47 +00:00
|
|
|
}
|
2013-04-24 22:53:53 +00:00
|
|
|
_info = ox.movie.parse_path(path)
|
|
|
|
for key in ('extension', 'type'):
|
|
|
|
r[key] = _info[key]
|
|
|
|
return r
|
2013-04-24 17:42:47 +00:00
|
|
|
|
|
|
|
|