forked from 0x2620/pandora
add space and other flake8 cleanups
This commit is contained in:
parent
f21e8413fb
commit
225259e521
1 changed files with 51 additions and 59 deletions
|
@ -79,10 +79,8 @@ def get_item(info, user=None, async=False):
|
||||||
item_data['year'] = info.get('year', '') or ''
|
item_data['year'] = info.get('year', '') or ''
|
||||||
|
|
||||||
# add additional item metadata parsed from path
|
# add additional item metadata parsed from path
|
||||||
for key in [i for i in info
|
for key in [i for i in info if i in set([k['id'] for k in settings.CONFIG['itemKeys']])
|
||||||
if i in set([k['id'] for k in settings.CONFIG['itemKeys']]) \
|
and i not in ('language', ) and i not in item_data]:
|
||||||
and i not in ('language', ) \
|
|
||||||
and i not in item_data]:
|
|
||||||
item_data[key] = info[key]
|
item_data[key] = info[key]
|
||||||
|
|
||||||
for key in ('episodeTitle', 'episodeDirector', 'episodeYear',
|
for key in ('episodeTitle', 'episodeDirector', 'episodeYear',
|
||||||
|
@ -220,7 +218,7 @@ class Item(models.Model):
|
||||||
def editable(self, user):
|
def editable(self, user):
|
||||||
if user.is_anonymous():
|
if user.is_anonymous():
|
||||||
return False
|
return False
|
||||||
if user.profile.capability('canEditMetadata') == True or \
|
if user.profile.capability('canEditMetadata') or \
|
||||||
user.is_staff or \
|
user.is_staff or \
|
||||||
self.user == user or \
|
self.user == user or \
|
||||||
self.groups.filter(id__in=user.groups.all()).count() > 0:
|
self.groups.filter(id__in=user.groups.all()).count() > 0:
|
||||||
|
@ -263,7 +261,7 @@ class Item(models.Model):
|
||||||
d.description = ox.sanitize_html(description)
|
d.description = ox.sanitize_html(description)
|
||||||
d.save()
|
d.save()
|
||||||
for key in data:
|
for key in data:
|
||||||
if data[key] == None:
|
if data[key] is None:
|
||||||
if key in self.data:
|
if key in self.data:
|
||||||
del self.data[key]
|
del self.data[key]
|
||||||
else:
|
else:
|
||||||
|
@ -508,7 +506,7 @@ class Item(models.Model):
|
||||||
'width': 640,
|
'width': 640,
|
||||||
'height': 1024,
|
'height': 1024,
|
||||||
'source': settings.URL,
|
'source': settings.URL,
|
||||||
'selected': url == None,
|
'selected': url is None,
|
||||||
'index': index.index(settings.URL)
|
'index': index.index(settings.URL)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -592,7 +590,6 @@ class Item(models.Model):
|
||||||
if not keys or 'posterRatio' in keys:
|
if not keys or 'posterRatio' in keys:
|
||||||
i['posterRatio'] = self.poster_width / self.poster_height
|
i['posterRatio'] = self.poster_width / self.poster_height
|
||||||
|
|
||||||
|
|
||||||
streams = self.streams()
|
streams = self.streams()
|
||||||
i['durations'] = [s.duration for s in streams]
|
i['durations'] = [s.duration for s in streams]
|
||||||
i['duration'] = sum(i['durations'])
|
i['duration'] = sum(i['durations'])
|
||||||
|
@ -644,8 +641,7 @@ class Item(models.Model):
|
||||||
i['%sdescription' % key] = {}
|
i['%sdescription' % key] = {}
|
||||||
if key == 'name':
|
if key == 'name':
|
||||||
values = []
|
values = []
|
||||||
for ikey in filter(lambda i: i.get('sortType') == 'person',
|
for ikey in filter(lambda i: i.get('sortType') == 'person', settings.CONFIG['itemKeys']):
|
||||||
settings.CONFIG['itemKeys']):
|
|
||||||
values += i.get(ikey['id'], [])
|
values += i.get(ikey['id'], [])
|
||||||
values = list(set(values))
|
values = list(set(values))
|
||||||
else:
|
else:
|
||||||
|
@ -766,7 +762,6 @@ class Item(models.Model):
|
||||||
titles += [a[0] for a in at]
|
titles += [a[0] for a in at]
|
||||||
return titles
|
return titles
|
||||||
|
|
||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
for key in settings.CONFIG['itemKeys']:
|
for key in settings.CONFIG['itemKeys']:
|
||||||
i = key['id']
|
i = key['id']
|
||||||
|
@ -818,7 +813,7 @@ class Item(models.Model):
|
||||||
isSeries = self.get('series',
|
isSeries = self.get('series',
|
||||||
self.get('episodeTitle',
|
self.get('episodeTitle',
|
||||||
self.get('episode',
|
self.get('episode',
|
||||||
self.get('seriesTitle')))) != None
|
self.get('seriesTitle')))) is not None
|
||||||
save('series', isSeries)
|
save('series', isSeries)
|
||||||
|
|
||||||
def update_sort(self):
|
def update_sort(self):
|
||||||
|
@ -1206,7 +1201,7 @@ class Item(models.Model):
|
||||||
return ox.torrent.bencode(data)
|
return ox.torrent.bencode(data)
|
||||||
|
|
||||||
def make_torrent(self):
|
def make_torrent(self):
|
||||||
if settings.CONFIG['video'].get('torrent') == False:
|
if not settings.CONFIG['video'].get('torrent'):
|
||||||
return
|
return
|
||||||
streams = self.streams()
|
streams = self.streams()
|
||||||
if streams.count() == 0:
|
if streams.count() == 0:
|
||||||
|
@ -1280,7 +1275,9 @@ class Item(models.Model):
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def audio_tracks(self):
|
def audio_tracks(self):
|
||||||
tracks = [f['language'] for f in self.files.filter(selected=True).filter(Q(is_video=True)|Q(is_audio=True)).values('language') if f['language']]
|
tracks = [f['language']
|
||||||
|
for f in self.files.filter(selected=True).filter(Q(is_video=True) | Q(is_audio=True)).values('language')
|
||||||
|
if f['language']]
|
||||||
return sorted(set(tracks))
|
return sorted(set(tracks))
|
||||||
|
|
||||||
def streams(self, track=None):
|
def streams(self, track=None):
|
||||||
|
@ -1407,10 +1404,7 @@ class Item(models.Model):
|
||||||
if not os.path.exists(timeline) and os.path.exists(audio_timeline):
|
if not os.path.exists(timeline) and os.path.exists(audio_timeline):
|
||||||
timeline = audio_timeline
|
timeline = audio_timeline
|
||||||
|
|
||||||
cmd = [settings.ITEM_POSTER,
|
cmd = [settings.ITEM_POSTER, '-d', '-', '-p', poster]
|
||||||
'-d', '-',
|
|
||||||
'-p', poster
|
|
||||||
]
|
|
||||||
data = self.json.copy()
|
data = self.json.copy()
|
||||||
if frame:
|
if frame:
|
||||||
data['frame'] = frame
|
data['frame'] = frame
|
||||||
|
@ -1488,9 +1482,7 @@ class Item(models.Model):
|
||||||
audio_timeline = '%stimelineaudio64p.jpg' % self.timeline_prefix
|
audio_timeline = '%stimelineaudio64p.jpg' % self.timeline_prefix
|
||||||
if not os.path.exists(timeline) and os.path.exists(audio_timeline):
|
if not os.path.exists(timeline) and os.path.exists(audio_timeline):
|
||||||
timeline = audio_timeline
|
timeline = audio_timeline
|
||||||
cmd = [settings.ITEM_ICON,
|
cmd = [settings.ITEM_ICON, '-i', self.icon.path]
|
||||||
'-i', self.icon.path
|
|
||||||
]
|
|
||||||
if os.path.exists(timeline):
|
if os.path.exists(timeline):
|
||||||
cmd += ['-l', timeline]
|
cmd += ['-l', timeline]
|
||||||
if frame:
|
if frame:
|
||||||
|
@ -1644,7 +1636,7 @@ Item.facet_keys = []
|
||||||
Item.layer_facet_keys = []
|
Item.layer_facet_keys = []
|
||||||
Item.poster_keys = []
|
Item.poster_keys = []
|
||||||
for key in settings.CONFIG['itemKeys']:
|
for key in settings.CONFIG['itemKeys']:
|
||||||
if 'autocomplete' in key and not 'autocompleteSortKey' in key or \
|
if 'autocomplete' in key and 'autocompleteSortKey' not in key or \
|
||||||
key.get('filter'):
|
key.get('filter'):
|
||||||
Item.facet_keys.append(key['id'])
|
Item.facet_keys.append(key['id'])
|
||||||
elif key.get('type') == 'layer' and \
|
elif key.get('type') == 'layer' and \
|
||||||
|
@ -1653,7 +1645,7 @@ for key in settings.CONFIG['itemKeys']:
|
||||||
if key['id'] in ('title', 'director', 'year') or key.get('poster'):
|
if key['id'] in ('title', 'director', 'year') or key.get('poster'):
|
||||||
Item.poster_keys.append(key['id'])
|
Item.poster_keys.append(key['id'])
|
||||||
if key.get('type') == 'layer' and (
|
if key.get('type') == 'layer' and (
|
||||||
key.get('filter') or \
|
key.get('filter') or
|
||||||
utils.get_by_id(settings.CONFIG['layers'], key['id']).get('type') == 'string'
|
utils.get_by_id(settings.CONFIG['layers'], key['id']).get('type') == 'string'
|
||||||
):
|
):
|
||||||
Item.layer_facet_keys.append(key['id'])
|
Item.layer_facet_keys.append(key['id'])
|
||||||
|
|
Loading…
Reference in a new issue