loop back to 0xdb to get name sort

This commit is contained in:
j 2012-10-15 16:06:11 +02:00
parent a506de677b
commit 06696dd466

View file

@ -18,6 +18,14 @@ import ox.web.allmovie
from modules import get_info
oxdb_api = ox.API('http://0xdb.org/api/')
def oxdb_sortnames(names):
try:
sort_name = oxdb_api.sortName(names=names)['data'].values()
except:
sort_names = map(canonical_name, names)
return sort_names
def get_movie_id(imdb_id):
#movies moved in imdb
@ -110,20 +118,28 @@ class MovieId(models.Model):
self.episode_yeaer or '')
def suggested_name(self):
return normalize_path(self.title)
return os.path.splitext(os.path.basename(self.format_path()))[0]
def suggested_path(self):
path = self.format_path()
path = os.path.dirname(path)
return os.path.join(path[0], path)
def format_path(self):
info = {}
for key in ('season', 'episode', 'isEpisode',
'version', 'language', 'part', 'partTitle'):
if not key in info:
info[key] = None
for key in ('title', 'year'):
info[key] = getattr(self, key)
if self.series_title:
title = self.series_title
return os.path.join('S', 'Series', title)
else:
directors = '; '.join(map(canonical_name, self.director.split(', ')))
if not directors: directors = "Unknown Director"
title = self.title
if self.year:
title += ' (%s)' % self.year
folder = strip_accents(directors[0].upper())[0]
return os.path.join(folder, normalize_path(directors), normalize_path(title))
info['seriesTitle'] = self.series_title
info['type'] = 'video'
info['extension'] = 'avi'
info['director'] = self.director.split(', ')
info['directorSort'] = oxdb_sortnames(info['director'])
return ox.movie.format_path(info)
def links(self):
links = []