forked from 0x2620/pandora
use isSubtitles itemKey for subtitles
This commit is contained in:
parent
20c5186640
commit
ba3d1538f4
2 changed files with 8 additions and 4 deletions
|
@ -1249,10 +1249,11 @@ class Item(models.Model):
|
|||
return icon
|
||||
|
||||
def load_subtitles(self):
|
||||
if not utils.get_by_id(settings.CONFIG['layers'], 'subtitles'):
|
||||
subtitles = utils.get_by_key(settings.CONFIG['layers'], 'isSubtitles', True)
|
||||
if not subtitles:
|
||||
return False
|
||||
with transaction.commit_on_success():
|
||||
layer = 'subtitles'
|
||||
layer = subtitles['id']
|
||||
Annotation.objects.filter(layer=layer,item=self).delete()
|
||||
offset = 0
|
||||
language = ''
|
||||
|
|
|
@ -70,6 +70,9 @@ def get_positions(ids, pos):
|
|||
pass
|
||||
return positions
|
||||
|
||||
def get_by_id(objects, id):
|
||||
obj = filter(lambda o: o['id'] == id, objects)
|
||||
def get_by_key(objects, key, value):
|
||||
obj = filter(lambda o: o.get(key) == value, objects)
|
||||
return obj and obj[0] or None
|
||||
|
||||
def get_by_id(objects, id):
|
||||
return get_by_key(objects, 'id', id)
|
||||
|
|
Loading…
Reference in a new issue