dont filter files, filtering is done on client. add additional metadata parsed from path to item

This commit is contained in:
j 2013-04-23 14:14:48 +00:00
parent 15e0d9a633
commit a4442dacd8
2 changed files with 12 additions and 8 deletions

View file

@ -68,11 +68,7 @@ def update_or_create_instance(volume, f):
def update_files(user, volume, files):
user = models.User.objects.get(username=user)
volume, created = models.Volume.objects.get_or_create(user=user, name=volume)
all_files = []
folder_depth = settings.CONFIG['site']['folderdepth']
for f in files:
if len(f['path'].split('/')) == folder_depth:
all_files.append(f['oshash'])
all_files = [f['oshash'] for f in files]
#remove deleted files
removed = models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files)
@ -80,7 +76,6 @@ def update_files(user, volume, files):
files__instances__in=removed.filter(file__selected=True)).distinct().values('itemId')]
removed.delete()
for f in files:
if f['oshash'] in all_files:
update_or_create_instance(volume, f)
for i in ids:
i = Item.objects.get(itemId=i)

View file

@ -72,13 +72,22 @@ def get_item(info, user=None, async=False):
'title': info.get('title', ''),
'director': info.get('director', []),
}
if filter(lambda k: k['id'] == 'year', settings.CONFIG['itemKeys']):
item_data['year'] = info.get('year', '')
#add additional item metadata parsed from path
for key in [i for i in info
if i in set([k['id'] for k in settings.CONFIG['itemKeys']]) \
and i not in ('language', ) \
and i not in item_data]:
item_data[key] = info[key]
for key in ('episodeTitle', 'episodeDirector', 'episodeYear',
'season', 'episode', 'seriesTitle'):
if key in info and info[key]:
item_data[key] = info[key]
if settings.USE_IMDB:
if 'imdbId' in info and info['imdbId']:
try: