path = os.path.join(chapter_dir, filename)
if os.path.isfile(path) and '.txt' == os.path.splitext(filename)[1]:
f = open(path, 'r')
+ i = 0
for line in f.readlines():
data = re.split(r'\t+', line.rstrip('\t'))
- metadata[data[0]] = data[1:]
+ if i == 0:
+ chapter_title = data[1]
+ print chapter_title
+ else:
+ metadata[data[0]] = data[1:]
+ i += 1
print metadata
break
corpus, c = MediaCorpus.objects.get_or_create(code=corpus_id, title=corpus_name)
- collection, c = MediaCollection.objects.get_or_create(code=collection_id, title=collection_name)
+ collection_title = collection_name.replace('_', ' ') + ' : ' + chapter_title
+ print collection_title
+ collection, c = MediaCollection.objects.get_or_create(code=collection_id, title=collection_title)
if not collection in corpus.children.all():
corpus.children.add(collection)
item.file = media_path
item.save()
- title = data[1].split('.')
+ title = data[0].split('.')
item.title = title[0]
- item.track = data[2].replace('\n', '')
+ print data
+ item.track = data[1].replace('\n', '')
if len(title) > 1:
item.comment = '. '.join(title[1:])
item.save()
<link rel="stylesheet" type="text/css" href="style/nav.css" />
+<h2>{{ collection.title }}</h2>
+
{% for item in items %}
<div class="item">
<h3>
- <b>Son {{ item.old_code }}</b> : {{ item.title }}. {{ item.comment }} (fig. {{ item.track }}, p. )
+ <b>Son {{ item.old_code }}</b> : {{ item.title }}. {{ item.comment }} ({{ item.track }})
</h3>
<div class="item-audio">
for collection in corpus.children.all():
items = {}
for item in collection.items.all():
- id = item.old_code.split('.')[1].replace('a', '.1').replace('b', '.2')
+ if '.' in item.old_code:
+ id = item.old_code.split('.')[1]
+ else:
+ id = item.old_code
+ id = id.replace('a', '.1').replace('b', '.2')
items[item] = float(id)
items = OrderedDict(sorted(items.items(), key=lambda t: t[1]))