forked from 0x2620/pandora
language
This commit is contained in:
parent
e4519b41a4
commit
16cf98cad6
1 changed files with 8 additions and 1 deletions
|
@ -144,6 +144,7 @@ class File(models.Model):
|
||||||
self.is_subtitle = True
|
self.is_subtitle = True
|
||||||
|
|
||||||
self.type = self.get_type()
|
self.type = self.get_type()
|
||||||
|
self.language = self.get_language()
|
||||||
self.part = self.get_part()
|
self.part = self.get_part()
|
||||||
|
|
||||||
if self.type not in ('audio', 'video'):
|
if self.type not in ('audio', 'video'):
|
||||||
|
@ -282,7 +283,7 @@ class File(models.Model):
|
||||||
|
|
||||||
def get_part(self):
|
def get_part(self):
|
||||||
if not self.is_extra:
|
if not self.is_extra:
|
||||||
files = list(self.item.files.filter(type=self.type,
|
files = list(self.item.files.filter(type=self.type, language=self.language,
|
||||||
is_main=self.is_main).order_by('sort_name'))
|
is_main=self.is_main).order_by('sort_name'))
|
||||||
if self in files:
|
if self in files:
|
||||||
return files.index(self) + 1
|
return files.index(self) + 1
|
||||||
|
@ -335,6 +336,12 @@ class File(models.Model):
|
||||||
ext = '.unknown'
|
ext = '.unknown'
|
||||||
return name + ext
|
return name + ext
|
||||||
|
|
||||||
|
def get_language(self):
|
||||||
|
language = self.name.split('.')
|
||||||
|
if len(language) >= 3 and len(language[-2]) == 2:
|
||||||
|
return language[-2]
|
||||||
|
return ''
|
||||||
|
|
||||||
def delete_file(sender, **kwargs):
|
def delete_file(sender, **kwargs):
|
||||||
f = kwargs['instance']
|
f = kwargs['instance']
|
||||||
if f.video:
|
if f.video:
|
||||||
|
|
Loading…
Reference in a new issue