forked from 0x2620/pandora
more path normalization
This commit is contained in:
parent
9dafefdcf2
commit
0383de30fb
1 changed files with 10 additions and 6 deletions
|
@ -174,22 +174,26 @@ class File(models.Model):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def normalize_item_path(self):
|
def normalize_item_path(self):
|
||||||
|
if not self.instances.all().count():
|
||||||
|
return ox.movie.format_path(self.get_path_info())
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
instance = self.instances.all()[0]
|
volume = self.instances.all()[0].volume
|
||||||
for f in self.item.files.filter(instances__volume=instance.volume):
|
for f in self.item.files.filter(instances__volume=volume):
|
||||||
|
instance = f.instances.all()[0]
|
||||||
files.append(f.get_path_info())
|
files.append(f.get_path_info())
|
||||||
files[-1].update({
|
files[-1].update({
|
||||||
'path': instance.path,
|
'path': instance.path,
|
||||||
|
'normalizedPath': ox.movie.format_path(files[-1]),
|
||||||
'time': instance.mtime,
|
'time': instance.mtime,
|
||||||
'oshash': f.oshash,
|
'oshash': f.oshash,
|
||||||
'size': f.size
|
'size': f.size
|
||||||
})
|
})
|
||||||
|
versions = ox.movie.parse_item_files(files)
|
||||||
info = ox.movie.parse_item_files(files)
|
for version in versions:
|
||||||
for version in info:
|
|
||||||
p = filter(lambda f: f['oshash'] == self.oshash, version['files'])
|
p = filter(lambda f: f['oshash'] == self.oshash, version['files'])
|
||||||
if p:
|
if p:
|
||||||
return p[0]['path']
|
return p[0]['normalizedPath']
|
||||||
|
|
||||||
def update_info(self, info, user):
|
def update_info(self, info, user):
|
||||||
#populate name sort with director if unknown
|
#populate name sort with director if unknown
|
||||||
|
|
Loading…
Reference in a new issue