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 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): def get_movie_id(imdb_id):
#movies moved in imdb #movies moved in imdb
@ -110,20 +118,28 @@ class MovieId(models.Model):
self.episode_yeaer or '') self.episode_yeaer or '')
def suggested_name(self): def suggested_name(self):
return normalize_path(self.title) return os.path.splitext(os.path.basename(self.format_path()))[0]
def suggested_path(self): 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: if self.series_title:
title = self.series_title info['seriesTitle'] = self.series_title
return os.path.join('S', 'Series', title) info['type'] = 'video'
else: info['extension'] = 'avi'
directors = '; '.join(map(canonical_name, self.director.split(', '))) info['director'] = self.director.split(', ')
if not directors: directors = "Unknown Director" info['directorSort'] = oxdb_sortnames(info['director'])
title = self.title return ox.movie.format_path(info)
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))
def links(self): def links(self):
links = [] links = []