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 ''
|
||||
|
||||
# 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]:
|
||||
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',
|
||||
|
@ -220,7 +218,7 @@ class Item(models.Model):
|
|||
def editable(self, user):
|
||||
if user.is_anonymous():
|
||||
return False
|
||||
if user.profile.capability('canEditMetadata') == True or \
|
||||
if user.profile.capability('canEditMetadata') or \
|
||||
user.is_staff or \
|
||||
self.user == user or \
|
||||
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.save()
|
||||
for key in data:
|
||||
if data[key] == None:
|
||||
if data[key] is None:
|
||||
if key in self.data:
|
||||
del self.data[key]
|
||||
else:
|
||||
|
@ -508,7 +506,7 @@ class Item(models.Model):
|
|||
'width': 640,
|
||||
'height': 1024,
|
||||
'source': settings.URL,
|
||||
'selected': url == None,
|
||||
'selected': url is None,
|
||||
'index': index.index(settings.URL)
|
||||
})
|
||||
|
||||
|
@ -592,7 +590,6 @@ class Item(models.Model):
|
|||
if not keys or 'posterRatio' in keys:
|
||||
i['posterRatio'] = self.poster_width / self.poster_height
|
||||
|
||||
|
||||
streams = self.streams()
|
||||
i['durations'] = [s.duration for s in streams]
|
||||
i['duration'] = sum(i['durations'])
|
||||
|
@ -644,8 +641,7 @@ class Item(models.Model):
|
|||
i['%sdescription' % key] = {}
|
||||
if key == 'name':
|
||||
values = []
|
||||
for ikey in filter(lambda i: i.get('sortType') == 'person',
|
||||
settings.CONFIG['itemKeys']):
|
||||
for ikey in filter(lambda i: i.get('sortType') == 'person', settings.CONFIG['itemKeys']):
|
||||
values += i.get(ikey['id'], [])
|
||||
values = list(set(values))
|
||||
else:
|
||||
|
@ -766,7 +762,6 @@ class Item(models.Model):
|
|||
titles += [a[0] for a in at]
|
||||
return titles
|
||||
|
||||
|
||||
with transaction.atomic():
|
||||
for key in settings.CONFIG['itemKeys']:
|
||||
i = key['id']
|
||||
|
@ -818,7 +813,7 @@ class Item(models.Model):
|
|||
isSeries = self.get('series',
|
||||
self.get('episodeTitle',
|
||||
self.get('episode',
|
||||
self.get('seriesTitle')))) != None
|
||||
self.get('seriesTitle')))) is not None
|
||||
save('series', isSeries)
|
||||
|
||||
def update_sort(self):
|
||||
|
@ -1206,7 +1201,7 @@ class Item(models.Model):
|
|||
return ox.torrent.bencode(data)
|
||||
|
||||
def make_torrent(self):
|
||||
if settings.CONFIG['video'].get('torrent') == False:
|
||||
if not settings.CONFIG['video'].get('torrent'):
|
||||
return
|
||||
streams = self.streams()
|
||||
if streams.count() == 0:
|
||||
|
@ -1280,7 +1275,9 @@ class Item(models.Model):
|
|||
self.save()
|
||||
|
||||
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))
|
||||
|
||||
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):
|
||||
timeline = audio_timeline
|
||||
|
||||
cmd = [settings.ITEM_POSTER,
|
||||
'-d', '-',
|
||||
'-p', poster
|
||||
]
|
||||
cmd = [settings.ITEM_POSTER, '-d', '-', '-p', poster]
|
||||
data = self.json.copy()
|
||||
if frame:
|
||||
data['frame'] = frame
|
||||
|
@ -1488,9 +1482,7 @@ class Item(models.Model):
|
|||
audio_timeline = '%stimelineaudio64p.jpg' % self.timeline_prefix
|
||||
if not os.path.exists(timeline) and os.path.exists(audio_timeline):
|
||||
timeline = audio_timeline
|
||||
cmd = [settings.ITEM_ICON,
|
||||
'-i', self.icon.path
|
||||
]
|
||||
cmd = [settings.ITEM_ICON, '-i', self.icon.path]
|
||||
if os.path.exists(timeline):
|
||||
cmd += ['-l', timeline]
|
||||
if frame:
|
||||
|
@ -1644,7 +1636,7 @@ Item.facet_keys = []
|
|||
Item.layer_facet_keys = []
|
||||
Item.poster_keys = []
|
||||
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'):
|
||||
Item.facet_keys.append(key['id'])
|
||||
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'):
|
||||
Item.poster_keys.append(key['id'])
|
||||
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'
|
||||
):
|
||||
Item.layer_facet_keys.append(key['id'])
|
||||
|
|
Loading…
Reference in a new issue