From 234085a2db750dbf3da0c11621d4fdad101aaee4 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 18 Oct 2011 14:01:01 +0200 Subject: [PATCH] pubic_id, load utf-16 subtitles, fix oxid --- pandora/annotation/models.py | 2 +- pandora/archive/models.py | 4 +--- pandora/item/models.py | 15 +++++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 55c262d6..477c1225 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -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) diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 57ff9378..cee5e8d7 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -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): diff --git a/pandora/item/models.py b/pandora/item/models.py index 40a7bc29..83889e21 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -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'],