This commit is contained in:
rolux 2011-10-18 17:09:41 +00:00
commit af31caef5a
3 changed files with 11 additions and 10 deletions

View file

@ -83,7 +83,7 @@ class Annotation(models.Model):
item = models.ForeignKey('item.Item', related_name='annotations')
clip = models.ForeignKey('clip.Clip', null=True, related_name='annotations')
public_id = models.CharField(max_length=128, unique=True)
public_id = models.CharField(max_length=128, unique=True, null=True)
#seconds
start = models.FloatField(default=-1, db_index=True)
end = models.FloatField(default=-1)

View file

@ -188,7 +188,6 @@ class File(models.Model):
bomDetection = bomDict.get((byte1, byte2, byte3, None))
if not bomDetection:
bomDetection = bomDict.get((byte1, byte2, None, None))
## if BOM detected, we're done :-)
fp.seek(oldFP)
if bomDetection:
@ -211,7 +210,6 @@ class File(models.Model):
encoding = _detectEncoding(f)
data = f.read()
f.close()
data = data.replace('\r\n', '\n')
try:
data = unicode(data, encoding)
except:
@ -220,7 +218,7 @@ class File(models.Model):
except:
print "failed to detect encoding, giving up"
return srt
data = data.replace('\r\n', '\n')
srts = re.compile('(\d\d:\d\d:\d\d[,.]\d\d\d)\s*-->\s*(\d\d:\d\d:\d\d[,.]\d\d\d)\s*(.+?)\n\n', re.DOTALL)
i = 0
for s in srts.findall(data):

View file

@ -387,7 +387,7 @@ class Item(models.Model):
layers = {}
for l in Layer.objects.all():
ll = layers.setdefault(l.name, [])
qs = Annotation.objects.filter(layer=l, item=self)
qs = Annotation.objects.filter(layer=l, item=self).select_related()
if l.private:
if user and user.is_anonymous():
user = None
@ -460,11 +460,14 @@ class Item(models.Model):
return self.itemId
if not self.get('title') and not self.get('director'):
return None
return ox.get_oxid(self.get('title', ''), self.get('director', []),
str(self.get('year', '')),
self.get('season', ''), self.get('episode', ''),
return ox.get_oxid(self.get('seriesTitle', self.get('title', '')),
self.get('director', []),
self.get('year', ''),
self.get('season', ''),
self.get('episode', ''),
self.get('episodeTitle', ''),
self.get('episodeDirector', []), self.get('episodeYear', ''))
self.get('episodeDirector', []),
self.get('episodeYear', ''))
'''
Search related functions
@ -1003,7 +1006,7 @@ class Item(models.Model):
user = s.instances.all()[0].volume.user
for data in s.srt(offset):
annotation = Annotation(
item=f.item,
item=self,
layer=layer,
start=data['in'],
end=data['out'],