allow updates of file metadata for files with info
This commit is contained in:
parent
6aa04ca73b
commit
441cb9892a
3 changed files with 20 additions and 20 deletions
|
@ -208,21 +208,22 @@ class File(models.Model):
|
|||
return p[0]['normalizedPath']
|
||||
|
||||
def update_info(self, info, user):
|
||||
#populate name sort with director if unknown
|
||||
if info.get('director') and info.get('directorSort'):
|
||||
for name, sortname in zip(info['director'], info['directorSort']):
|
||||
get_name_sort(name, sortname)
|
||||
#add all files in one folder to same item
|
||||
if self.instances.all().count():
|
||||
if info.get('isEpisode'):
|
||||
prefix = os.path.splitext(self.instances.all()[0].path)[0]
|
||||
else:
|
||||
prefix = os.path.dirname(self.instances.all()[0].path) + '/'
|
||||
qs = item.models.Item.objects.filter(files__instances__path__startswith=prefix)
|
||||
if qs.exists():
|
||||
self.item = qs[0]
|
||||
if not self.item:
|
||||
self.item = item.models.get_item(info, user)
|
||||
if not self.info:
|
||||
#populate name sort with director if unknown
|
||||
if info.get('director') and info.get('directorSort'):
|
||||
for name, sortname in zip(info['director'], info['directorSort']):
|
||||
get_name_sort(name, sortname)
|
||||
#add all files in one folder to same item
|
||||
if self.instances.all().count():
|
||||
if info.get('isEpisode'):
|
||||
prefix = os.path.splitext(self.instances.all()[0].path)[0]
|
||||
else:
|
||||
prefix = os.path.dirname(self.instances.all()[0].path) + '/'
|
||||
qs = item.models.Item.objects.filter(files__instances__path__startswith=prefix)
|
||||
if qs.exists():
|
||||
self.item = qs[0]
|
||||
if not self.item:
|
||||
self.item = item.models.get_item(info, user)
|
||||
for key in self.AV_INFO + self.PATH_INFO:
|
||||
if key in info:
|
||||
self.info[key] = info[key]
|
||||
|
|
|
@ -85,9 +85,8 @@ def update_info(user, info):
|
|||
user = models.User.objects.get(username=user)
|
||||
files = models.File.objects.filter(oshash__in=info.keys())
|
||||
for f in files:
|
||||
if not f.info:
|
||||
f.update_info(info[f.oshash], user)
|
||||
f.save()
|
||||
f.update_info(info[f.oshash], user)
|
||||
f.save()
|
||||
for i in Item.objects.filter(files__in=files).distinct():
|
||||
i.update_selected()
|
||||
i.update_wanted()
|
||||
|
|
|
@ -8,7 +8,7 @@ from django import forms
|
|||
from django.shortcuts import get_object_or_404, redirect, render_to_response
|
||||
from django.template import RequestContext
|
||||
from django.conf import settings
|
||||
from django.db.models import Count
|
||||
from django.db.models import Count, Q
|
||||
|
||||
import ox
|
||||
from ox.utils import json
|
||||
|
@ -95,7 +95,7 @@ def update(request, data):
|
|||
files = all_files.filter(file__available=False)
|
||||
if volume:
|
||||
files = files.filter(volume=volume)
|
||||
response['data']['info'] = [f.file.oshash for f in all_files.filter(file__info='{}')]
|
||||
response['data']['info'] = [f.file.oshash for f in all_files.filter(Q(file__info='{}')|Q(file__size=0))]
|
||||
response['data']['data'] = [f.file.oshash for f in files.filter(file__is_video=True,
|
||||
file__available=False,
|
||||
file__wanted=True)]
|
||||
|
|
Loading…
Reference in a new issue