cleanup field names

This commit is contained in:
j 2011-01-03 21:32:33 +05:30
parent 7745ec5c7f
commit 60e3f658a1
3 changed files with 17 additions and 15 deletions

View file

@ -37,7 +37,9 @@ def parseCondition(condition):
key_type = models.site_config['keys'].get(k, {'type':'string'}).get('type') key_type = models.site_config['keys'].get(k, {'type':'string'}).get('type')
key_type = { key_type = {
'title': 'string', 'title': 'string',
'person': 'string' 'person': 'string',
'text': 'string',
'year': 'string',
}.get(key_type, key_type) }.get(key_type, key_type)
if key_type == "string": if key_type == "string":

View file

@ -133,10 +133,10 @@ def get_item(info):
item = Item.objects.get(itemId=info['imdbId']) item = Item.objects.get(itemId=info['imdbId'])
except Item.DoesNotExist: except Item.DoesNotExist:
item = Item(itemId=info['imdbId']) item = Item(itemId=info['imdbId'])
if 'title' in info and 'directors' in info: if 'title' in info and 'director' in info:
item.external_data = { item.external_data = {
'title': info['title'], 'title': info['title'],
'directors': info['directors'], 'director': info['director'],
'year': info.get('year', '') 'year': info.get('year', '')
} }
#FIXME: this should be done async #FIXME: this should be done async
@ -155,7 +155,7 @@ def get_item(info):
item = Item() item = Item()
item.data = { item.data = {
'title': info['title'], 'title': info['title'],
'directors': info['directors'], 'director': info['director'],
'year': info.get('year', '') 'year': info.get('year', '')
} }
item.itemId = info['oxdbId'] item.itemId = info['oxdbId']
@ -353,15 +353,15 @@ class Item(models.Model):
'runtime': 'runtime', 'runtime': 'runtime',
'release_date': 'release_date', 'release_date': 'release_date',
'countries': 'country', 'country': 'country',
'directors': 'director', 'director': 'director',
'writers': 'writer', 'writer': 'writer',
'editors': 'editor', 'editor': 'editor',
'producers': 'producer', 'producer': 'producer',
'cinematographer': 'cinematographer', 'cinematographer': 'cinematographer',
'languages': 'language', 'language': 'language',
'genres': 'genre', 'genres': 'genre',
'keywords': 'keyword', 'keyword': 'keyword',
'cast': 'cast', 'cast': 'cast',
'series_title': 'series_title', 'series_title': 'series_title',
'episode_title': 'episode_title', 'episode_title': 'episode_title',
@ -464,12 +464,12 @@ class Item(models.Model):
fields = classmethod(fields) fields = classmethod(fields)
def oxid(self): def oxid(self):
return utils.oxid(self.get('title', ''), self.get('directors', []), str(self.get('year', '')), return utils.oxid(self.get('title', ''), self.get('director', []), str(self.get('year', '')),
self.get('series title', ''), self.get('episode title', ''), self.get('series title', ''), self.get('episode title', ''),
self.get('season', ''), self.get('episode', '')) self.get('season', ''), self.get('episode', ''))
def oxdb_id(self): def oxdb_id(self):
return utils.oxdb_id(self.get('title', ''), self.get('directors', []), str(self.get('year', '')), return utils.oxdb_id(self.get('title', ''), self.get('director', []), str(self.get('year', '')),
self.get('season', ''), self.get('episode', ''), self.get('season', ''), self.get('episode', ''),
self.get('episode_title', ''), self.get('episode_directors', ''), self.get('episode_year', '')) self.get('episode_title', ''), self.get('episode_directors', ''), self.get('episode_year', ''))
@ -852,7 +852,7 @@ class Item(models.Model):
if os.path.exists(timeline): if os.path.exists(timeline):
cmd = [settings.ITEM_POSTER, cmd = [settings.ITEM_POSTER,
'-t', self.get('title'), '-t', self.get('title'),
'-d', ', '.join(self.get('directors', ['Unknown Director'])), '-d', ', '.join(self.get('director', ['Unknown Director'])),
'-y', str(self.get('year', '')), '-y', str(self.get('year', '')),
'-f', frame, '-f', frame,
'-l', timeline, '-l', timeline,

View file

@ -213,7 +213,7 @@ Positions
response['data']['files'] = files.count() response['data']['files'] = files.count()
response['data']['items'] = items.count() response['data']['items'] = items.count()
response['data']['pixels'] = r['pixels__sum'] response['data']['pixels'] = r['pixels__sum']
response['data']['runtime'] = items.aggregate(Sum('sort__runtime'))['sort__runtime__sum'] response['data']['runtime'] = items.filter(sort__runtime__gt=0).aggregate(Sum('sort__runtime'))['sort__runtime__sum']
if response['data']['runtime'] == None: if response['data']['runtime'] == None:
response['data']['runtime'] = 1337 response['data']['runtime'] = 1337
response['data']['size'] = r['size__sum'] response['data']['size'] = r['size__sum']