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')
|
item = models.ForeignKey('item.Item', related_name='annotations')
|
||||||
clip = models.ForeignKey('clip.Clip', null=True, 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
|
#seconds
|
||||||
start = models.FloatField(default=-1, db_index=True)
|
start = models.FloatField(default=-1, db_index=True)
|
||||||
end = models.FloatField(default=-1)
|
end = models.FloatField(default=-1)
|
||||||
|
|
|
@ -188,7 +188,6 @@ class File(models.Model):
|
||||||
bomDetection = bomDict.get((byte1, byte2, byte3, None))
|
bomDetection = bomDict.get((byte1, byte2, byte3, None))
|
||||||
if not bomDetection:
|
if not bomDetection:
|
||||||
bomDetection = bomDict.get((byte1, byte2, None, None))
|
bomDetection = bomDict.get((byte1, byte2, None, None))
|
||||||
|
|
||||||
## if BOM detected, we're done :-)
|
## if BOM detected, we're done :-)
|
||||||
fp.seek(oldFP)
|
fp.seek(oldFP)
|
||||||
if bomDetection:
|
if bomDetection:
|
||||||
|
@ -211,7 +210,6 @@ class File(models.Model):
|
||||||
encoding = _detectEncoding(f)
|
encoding = _detectEncoding(f)
|
||||||
data = f.read()
|
data = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
data = data.replace('\r\n', '\n')
|
|
||||||
try:
|
try:
|
||||||
data = unicode(data, encoding)
|
data = unicode(data, encoding)
|
||||||
except:
|
except:
|
||||||
|
@ -220,7 +218,7 @@ class File(models.Model):
|
||||||
except:
|
except:
|
||||||
print "failed to detect encoding, giving up"
|
print "failed to detect encoding, giving up"
|
||||||
return srt
|
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)
|
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
|
i = 0
|
||||||
for s in srts.findall(data):
|
for s in srts.findall(data):
|
||||||
|
|
|
@ -387,7 +387,7 @@ class Item(models.Model):
|
||||||
layers = {}
|
layers = {}
|
||||||
for l in Layer.objects.all():
|
for l in Layer.objects.all():
|
||||||
ll = layers.setdefault(l.name, [])
|
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 l.private:
|
||||||
if user and user.is_anonymous():
|
if user and user.is_anonymous():
|
||||||
user = None
|
user = None
|
||||||
|
@ -460,11 +460,14 @@ class Item(models.Model):
|
||||||
return self.itemId
|
return self.itemId
|
||||||
if not self.get('title') and not self.get('director'):
|
if not self.get('title') and not self.get('director'):
|
||||||
return None
|
return None
|
||||||
return ox.get_oxid(self.get('title', ''), self.get('director', []),
|
return ox.get_oxid(self.get('seriesTitle', self.get('title', '')),
|
||||||
str(self.get('year', '')),
|
self.get('director', []),
|
||||||
self.get('season', ''), self.get('episode', ''),
|
self.get('year', ''),
|
||||||
|
self.get('season', ''),
|
||||||
|
self.get('episode', ''),
|
||||||
self.get('episodeTitle', ''),
|
self.get('episodeTitle', ''),
|
||||||
self.get('episodeDirector', []), self.get('episodeYear', ''))
|
self.get('episodeDirector', []),
|
||||||
|
self.get('episodeYear', ''))
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Search related functions
|
Search related functions
|
||||||
|
@ -1003,7 +1006,7 @@ class Item(models.Model):
|
||||||
user = s.instances.all()[0].volume.user
|
user = s.instances.all()[0].volume.user
|
||||||
for data in s.srt(offset):
|
for data in s.srt(offset):
|
||||||
annotation = Annotation(
|
annotation = Annotation(
|
||||||
item=f.item,
|
item=self,
|
||||||
layer=layer,
|
layer=layer,
|
||||||
start=data['in'],
|
start=data['in'],
|
||||||
end=data['out'],
|
end=data['out'],
|
||||||
|
|
Loading…
Reference in a new issue