use path to populate unknown sort names, #958

This commit is contained in:
j 2012-09-14 11:50:08 +02:00
parent fdb358ea89
commit 7b22bba4e7
2 changed files with 7 additions and 2 deletions

View file

@ -9,7 +9,7 @@ from django.conf import settings
from item.models import get_item, Item from item.models import get_item, Item
import item.tasks import item.tasks
from person.models import get_name_sort
import models import models
import extract import extract
@ -17,6 +17,9 @@ _INSTANCE_KEYS = ('mtime', 'path')
def get_or_create_item(volume, info, user): def get_or_create_item(volume, info, user):
item_info = ox.parse_movie_path(info['path']) item_info = ox.parse_movie_path(info['path'])
if item_info.get('director') and item_info.get('directorSort'):
for name, sortname in zip(item_info['director'], item_info['directorSort']):
get_name_sort(name, sortname)
return get_item(item_info, user) return get_item(item_info, user)
def get_or_create_file(volume, f, user, item=None): def get_or_create_file(volume, f, user, item=None):

View file

@ -15,11 +15,13 @@ import item.models
import managers import managers
import tasks import tasks
def get_name_sort(name): def get_name_sort(name, sortname=None):
name = unicodedata.normalize('NFKD', name).strip() name = unicodedata.normalize('NFKD', name).strip()
if name: if name:
person, created = Person.objects.get_or_create(name=name) person, created = Person.objects.get_or_create(name=name)
if created: if created:
if sortname:
person.sortname = sortname
person.save() person.save()
sortname = unicodedata.normalize('NFKD', person.sortname) sortname = unicodedata.normalize('NFKD', person.sortname)
else: else: