suggested name

This commit is contained in:
j 2010-09-01 13:32:25 +02:00
parent 8598b2c771
commit a8f150272e

View file

@ -8,7 +8,7 @@ from django.db.models import Q, Max
from django.contrib.auth.models import User from django.contrib.auth.models import User
import ox import ox
from ox.normalize import canonicalName from ox.normalize import canonicalName, normalizePath
from ox import stripTags from ox import stripTags
import ox.web.imdb import ox.web.imdb
import ox.web.wikipedia import ox.web.wikipedia
@ -108,6 +108,9 @@ class MovieId(models.Model):
self.oxdb_id = u"0x" + oxid self.oxdb_id = u"0x" + oxid
self.save() self.save()
def suggested_name(self):
return normalizePath(self.title)
def suggested_path(self): def suggested_path(self):
if self.series_title: if self.series_title:
title = self.series_title title = self.series_title
@ -118,7 +121,7 @@ class MovieId(models.Model):
title = self.title title = self.title
if self.year: if self.year:
title += ' (%s)' % self.year title += ' (%s)' % self.year
return os.path.join(directors[0], directors, title) return os.path.join(directors[0].upper(), normalizePath(directors), normalizePath(title))
def json(self): def json(self):
json = {} json = {}
@ -144,6 +147,7 @@ class MovieId(models.Model):
if 'year' in json and json['year']: if 'year' in json and json['year']:
json['year'] = int(json['year']) json['year'] = int(json['year'])
json['suggested_name'] = self.suggested_name()
json['suggested_path'] = self.suggested_path() json['suggested_path'] = self.suggested_path()
return json return json