annotation, oxdb_id

This commit is contained in:
j 2010-11-28 17:03:23 +01:00
parent 34b98ae985
commit da213d1745
8 changed files with 23 additions and 16 deletions

View file

@ -6,11 +6,11 @@ from django.contrib import admin
import models
class BinAdmin(admin.ModelAdmin):
search_fields = ['name', 'title']
admin.site.register(models.Bin, BinAdmin)
class LayerAdmin(admin.ModelAdmin):
search_fields = ['name', 'title']
admin.site.register(models.Layer, LayerAdmin)
class AnnotationAdmin(admin.ModelAdmin):
search_fields = ['name', 'title']
admin.site.register(models.Annotation, AnnotationAdmin)

View file

@ -24,7 +24,7 @@ from ox import stripTags
from ox.normalize import canonicalTitle, canonicalName
class Bin(models.Model):
class Layer(models.Model):
class Meta:
ordering = ('position', )
@ -42,7 +42,7 @@ class Bin(models.Model):
subtitle = models.BooleanField(default=True) #bis can be displayed as subtitle, only one bin
find = models.BooleanField(default=True)
#words / item duration(wpm), total words, cuts per minute, cuts, number of layers, number of layers/duration
#words / item duration(wpm), total words, cuts per minute, cuts, number of annotations, number of annotations/duration
sort = models.CharField(null=True, max_length=255)
def properties(self):
@ -53,7 +53,10 @@ class Bin(models.Model):
print 'FIXME: need to add sort stuff'
return p
class Layer(models.Model):
def json(self):
return {'id': self.name, 'title': self.title, 'type': self.type}
class Annotation(models.Model):
#FIXME: here having a item,start index would be good
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
@ -66,9 +69,6 @@ class Layer(models.Model):
type = models.CharField(blank=True, max_length=255)
value = models.TextField()
#FIXME: relational layers, Locations, clips etc
#location = models.ForeignKey('Location', default=None)
def editable(self, user):
if user.is_authenticated():

View file

@ -30,7 +30,7 @@ import utils
import tasks
from archive import extract
from layer.models import Layer
from annotaion.models import Annotation, Layer
from person.models import get_name_sort, Person
@ -47,6 +47,8 @@ def siteJson():
r['findKeys'].append(f)
r['groups'] = [p.name for p in Property.objects.filter(group=True)]
r['layers'] = [l.json() for l in Layer.objects()]
r['itemViews'] = [
{"id": "info", "title": "Info"},
{"id": "statistics", "title": "Statistics"},
@ -286,7 +288,7 @@ class Item(models.Model):
def save(self, *args, **kwargs):
self.json = self.get_json()
if not self.oxdbId:
self.oxdbId = self.oxid()
self.oxdbId = self.oxdb_id()
if self.poster:
self.poster_height = self.poster.height
@ -412,7 +414,7 @@ class Item(models.Model):
layers['cuts'] = self.data.get('cuts', {})
layers['subtitles'] = {}
#FIXME: subtitles should be stored in Layer
#FIXME: subtitles should be stored in Annotation
qs = self.files.filter(is_subtitle=True, is_main=True, available=True)
if qs.count()>0:
layers['subtitles'] = qs[0].srt()
@ -456,6 +458,10 @@ class Item(models.Model):
self.get('series title', ''), self.get('episode title', ''),
self.get('season', ''), self.get('episode', ''))
def oxdb_id(self):
return utils.oxdb_id(self.get('title', ''), self.get('directors', []), str(self.get('year', '')),
self.get('season', ''), self.get('episode', ''),
self.get('episode_title', ''), self.get('episode_directors', ''), self.get('episode_year', ''))
'''
Search related functions
@ -490,7 +496,7 @@ class Item(models.Model):
#FIXME:
#f.dialog = 'fixme'
save('dialog', '\n'.join([l.value for l in Layer.objects.filter(type='subtitle', item=self).order_by('start')]))
save('dialog', '\n'.join([l.value for l in Annotation.objects.filter(type='subtitle', item=self).order_by('start')]))
#FIXME: collate filenames
#f.filename = self.filename

View file

@ -30,11 +30,12 @@ def oxid(title, directors, year='', seriesTitle='', episodeTitle='', season=0, e
oxid += hashlib.sha1(oxid_value.encode('utf-8')).hexdigest()[:20]
return u"0x" + oxid
def oxdb_id(title, directors=[], year='', season='', episode='', episode_title='', episode_director='', episode_year=''):
def oxdb_id(title, directors=[], year='', season='', episode='', episode_title='', episode_directors=[], episode_year=''):
# new id function, will replace oxid()
def get_hash(string):
return hashlib.sha1(string.encode('utf-8')).hexdigest().upper()
director = ', '.join(directors)
episode_director = ', '.join(episode_directors)
if not episode:
oxdb_id = get_hash(director)[:8] + get_hash('\n'.join([title, year]))[:8]
else:

View file

@ -117,13 +117,13 @@ INSTALLED_APPS = (
# 'south',
'djcelery',
'annotaion',
'app',
'api',
'archive',
'date',
'item',
'itemlist',
'layer',
'person',
'place',
'text',