forked from 0x2620/pandora
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']
|
return p[0]['normalizedPath']
|
||||||
|
|
||||||
def update_info(self, info, user):
|
def update_info(self, info, user):
|
||||||
#populate name sort with director if unknown
|
if not self.info:
|
||||||
if info.get('director') and info.get('directorSort'):
|
#populate name sort with director if unknown
|
||||||
for name, sortname in zip(info['director'], info['directorSort']):
|
if info.get('director') and info.get('directorSort'):
|
||||||
get_name_sort(name, sortname)
|
for name, sortname in zip(info['director'], info['directorSort']):
|
||||||
#add all files in one folder to same item
|
get_name_sort(name, sortname)
|
||||||
if self.instances.all().count():
|
#add all files in one folder to same item
|
||||||
if info.get('isEpisode'):
|
if self.instances.all().count():
|
||||||
prefix = os.path.splitext(self.instances.all()[0].path)[0]
|
if info.get('isEpisode'):
|
||||||
else:
|
prefix = os.path.splitext(self.instances.all()[0].path)[0]
|
||||||
prefix = os.path.dirname(self.instances.all()[0].path) + '/'
|
else:
|
||||||
qs = item.models.Item.objects.filter(files__instances__path__startswith=prefix)
|
prefix = os.path.dirname(self.instances.all()[0].path) + '/'
|
||||||
if qs.exists():
|
qs = item.models.Item.objects.filter(files__instances__path__startswith=prefix)
|
||||||
self.item = qs[0]
|
if qs.exists():
|
||||||
if not self.item:
|
self.item = qs[0]
|
||||||
self.item = item.models.get_item(info, user)
|
if not self.item:
|
||||||
|
self.item = item.models.get_item(info, user)
|
||||||
for key in self.AV_INFO + self.PATH_INFO:
|
for key in self.AV_INFO + self.PATH_INFO:
|
||||||
if key in info:
|
if key in info:
|
||||||
self.info[key] = info[key]
|
self.info[key] = info[key]
|
||||||
|
|
|
@ -85,9 +85,8 @@ def update_info(user, info):
|
||||||
user = models.User.objects.get(username=user)
|
user = models.User.objects.get(username=user)
|
||||||
files = models.File.objects.filter(oshash__in=info.keys())
|
files = models.File.objects.filter(oshash__in=info.keys())
|
||||||
for f in files:
|
for f in files:
|
||||||
if not f.info:
|
f.update_info(info[f.oshash], user)
|
||||||
f.update_info(info[f.oshash], user)
|
f.save()
|
||||||
f.save()
|
|
||||||
for i in Item.objects.filter(files__in=files).distinct():
|
for i in Item.objects.filter(files__in=files).distinct():
|
||||||
i.update_selected()
|
i.update_selected()
|
||||||
i.update_wanted()
|
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.shortcuts import get_object_or_404, redirect, render_to_response
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.models import Count
|
from django.db.models import Count, Q
|
||||||
|
|
||||||
import ox
|
import ox
|
||||||
from ox.utils import json
|
from ox.utils import json
|
||||||
|
@ -95,7 +95,7 @@ def update(request, data):
|
||||||
files = all_files.filter(file__available=False)
|
files = all_files.filter(file__available=False)
|
||||||
if volume:
|
if volume:
|
||||||
files = files.filter(volume=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,
|
response['data']['data'] = [f.file.oshash for f in files.filter(file__is_video=True,
|
||||||
file__available=False,
|
file__available=False,
|
||||||
file__wanted=True)]
|
file__wanted=True)]
|
||||||
|
|
Loading…
Reference in a new issue