dont filter files, filtering is done on client. add additional metadata parsed from path to item
This commit is contained in:
parent
15e0d9a633
commit
a4442dacd8
2 changed files with 12 additions and 8 deletions
|
@ -68,11 +68,7 @@ def update_or_create_instance(volume, f):
|
||||||
def update_files(user, volume, files):
|
def update_files(user, volume, files):
|
||||||
user = models.User.objects.get(username=user)
|
user = models.User.objects.get(username=user)
|
||||||
volume, created = models.Volume.objects.get_or_create(user=user, name=volume)
|
volume, created = models.Volume.objects.get_or_create(user=user, name=volume)
|
||||||
all_files = []
|
all_files = [f['oshash'] for f in files]
|
||||||
folder_depth = settings.CONFIG['site']['folderdepth']
|
|
||||||
for f in files:
|
|
||||||
if len(f['path'].split('/')) == folder_depth:
|
|
||||||
all_files.append(f['oshash'])
|
|
||||||
|
|
||||||
#remove deleted files
|
#remove deleted files
|
||||||
removed = models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files)
|
removed = models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files)
|
||||||
|
@ -80,8 +76,7 @@ def update_files(user, volume, files):
|
||||||
files__instances__in=removed.filter(file__selected=True)).distinct().values('itemId')]
|
files__instances__in=removed.filter(file__selected=True)).distinct().values('itemId')]
|
||||||
removed.delete()
|
removed.delete()
|
||||||
for f in files:
|
for f in files:
|
||||||
if f['oshash'] in all_files:
|
update_or_create_instance(volume, f)
|
||||||
update_or_create_instance(volume, f)
|
|
||||||
for i in ids:
|
for i in ids:
|
||||||
i = Item.objects.get(itemId=i)
|
i = Item.objects.get(itemId=i)
|
||||||
i.update_selected()
|
i.update_selected()
|
||||||
|
|
|
@ -72,13 +72,22 @@ def get_item(info, user=None, async=False):
|
||||||
'title': info.get('title', ''),
|
'title': info.get('title', ''),
|
||||||
'director': info.get('director', []),
|
'director': info.get('director', []),
|
||||||
}
|
}
|
||||||
|
|
||||||
if filter(lambda k: k['id'] == 'year', settings.CONFIG['itemKeys']):
|
if filter(lambda k: k['id'] == 'year', settings.CONFIG['itemKeys']):
|
||||||
item_data['year'] =info.get('year', '')
|
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',
|
for key in ('episodeTitle', 'episodeDirector', 'episodeYear',
|
||||||
'season', 'episode', 'seriesTitle'):
|
'season', 'episode', 'seriesTitle'):
|
||||||
if key in info and info[key]:
|
if key in info and info[key]:
|
||||||
item_data[key] = info[key]
|
item_data[key] = info[key]
|
||||||
|
|
||||||
if settings.USE_IMDB:
|
if settings.USE_IMDB:
|
||||||
if 'imdbId' in info and info['imdbId']:
|
if 'imdbId' in info and info['imdbId']:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue