server side cleanups and fixed for pandora_client sync

This commit is contained in:
j 2011-04-06 20:57:25 +02:00
commit 4328d54450
8 changed files with 88 additions and 61 deletions

View file

@ -550,7 +550,7 @@ class Item(models.Model):
for key in self.facet_keys:
current_values = self.get(key, [])
if not isinstance(current_values, list):
current_values = [current_values]
current_values = [unicode(current_values)]
current_values = list(set(current_values))
saved_values = [i.value for i in Facet.objects.filter(item=self, key=key)]
removed_values = filter(lambda i: i not in current_values, saved_values)
@ -632,8 +632,7 @@ class Item(models.Model):
cmd = []
if os.path.exists(stream.video.path):
os.unlink(stream.video.path)
elif not os.path.exists(os.path.dirname(stream.video.path)):
os.makedirs(os.path.dirname(stream.video.path))
ox.makedirs(os.path.dirname(stream.video.path))
if len(files.values()) > 1:
if len(files.values()) > 4:
print "FIXME: to many files for this item, not merging entire tv shows"
@ -753,8 +752,7 @@ class Item(models.Model):
posters = self.local_posters()
timeline = self.path('timeline.64.png')
timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline))
if not os.path.exists(os.path.join(settings.MEDIA_ROOT,self.path())):
os.makedirs(os.path.join(settings.MEDIA_ROOT,self.path()))
ox.makedirs(os.path.join(settings.MEDIA_ROOT,self.path()))
for poster in posters:
frame = posters[poster]
cmd = [settings.ITEM_POSTER,

View file

@ -102,6 +102,8 @@ def parse_title(_title, searchTitle = False):
if year and title.endswith(year):
title = title[:-len(year)].strip()
title = normalizeTitle(title)
if searchTitle and year:
title = u"%s %s" % (title, year)
return title
@ -180,7 +182,9 @@ def parse_path(path):
r['season'], r['episode'] = parse_season_episode(path)
r['series_title'] = parse_series_title(path)
r['imdbId'] = ox.web.imdb.guess(search_title, ', '.join(r['director']), timeout=-1)
#FIXME: use oxdata/id/?title=title&director=director&year=year
#r['imdbId'] = ox.web.imdb.guess(search_title, ', '.join(r['director']), timeout=-1)
r['imdbId'] = ox.web.imdb.guess(search_title, timeout=-1)
r['oxdbId'] = oxdb_id(r['title'], r['director'], r.get('year', ''),
r.get('season', ''), r.get('episode', ''),
episode_title=r['episode_title'],