pubic_id, load utf-16 subtitles, fix oxid
This commit is contained in:
parent
f7e49bce00
commit
234085a2db
3 changed files with 11 additions and 10 deletions
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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'],
|
||||
|
|
Loading…
Reference in a new issue