forked from 0x2620/pandora
list/enum, support find resolution
This commit is contained in:
parent
e92fff7f42
commit
72c0917d2c
3 changed files with 22 additions and 7 deletions
|
@ -306,7 +306,9 @@
|
||||||
"id": "resolution",
|
"id": "resolution",
|
||||||
"title": "Resolution",
|
"title": "Resolution",
|
||||||
"type": ["integer"],
|
"type": ["integer"],
|
||||||
"columnWidth": 90
|
"capability": "canSeeFiles",
|
||||||
|
"columnWidth": 90,
|
||||||
|
"format": {"type": "resolution", "args": ["px"]}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "aspectratio",
|
"id": "aspectratio",
|
||||||
|
@ -319,6 +321,7 @@
|
||||||
"id": "pixels",
|
"id": "pixels",
|
||||||
"title": "Pixels",
|
"title": "Pixels",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
"capability": "canSeeFiles",
|
||||||
"columnWidth": 90,
|
"columnWidth": 90,
|
||||||
"format": {"type": "value", "args": ["px"]}
|
"format": {"type": "value", "args": ["px"]}
|
||||||
},
|
},
|
||||||
|
@ -393,7 +396,7 @@
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"capability": "canSeeFiles",
|
"capability": "canSeeFiles",
|
||||||
"columnWidth": 60,
|
"columnWidth": 60,
|
||||||
"format": {"type": "value", "args": ["bps"]}
|
"format": {"type": "unit", "args": ["kbps", 0, 0.001]}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "parts",
|
"id": "parts",
|
||||||
|
@ -447,13 +450,13 @@
|
||||||
{
|
{
|
||||||
"id": "rightslevel",
|
"id": "rightslevel",
|
||||||
"title": "Rights Level",
|
"title": "Rights Level",
|
||||||
"type": "list",
|
"type": "enum",
|
||||||
"columnWidth": 90,
|
"columnWidth": 90,
|
||||||
"format": {"type": "ColorLevel", "args": [
|
"format": {"type": "ColorLevel", "args": [
|
||||||
["Public", "Relaxed", "Regular", "Restricted", "Private"]
|
["Public", "Relaxed", "Regular", "Restricted", "Private"]
|
||||||
]},
|
]},
|
||||||
"list": ["Public", "Relaxed", "Regular", "Restricted", "Private", "Unknown"],
|
"sortOperator": "+",
|
||||||
"sortOperator": "+"
|
"values": ["Public", "Relaxed", "Regular", "Restricted", "Private", "Unknown"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "canplayvideo",
|
"id": "canplayvideo",
|
||||||
|
|
|
@ -59,6 +59,12 @@ def parseCondition(condition, user):
|
||||||
elif k == 'filename' and (user.is_anonymous() or \
|
elif k == 'filename' and (user.is_anonymous() or \
|
||||||
not user.get_profile().capability('canSeeFiles')):
|
not user.get_profile().capability('canSeeFiles')):
|
||||||
return Q(id=0)
|
return Q(id=0)
|
||||||
|
elif k == 'resolution':
|
||||||
|
q = parseCondition({'key': 'width', 'value': v[0], 'operator': op}, user) \
|
||||||
|
& parseCondition({'key': 'height', 'value': v[1], 'operator': op}, user)
|
||||||
|
if exclude:
|
||||||
|
q = ~q
|
||||||
|
return q
|
||||||
elif isinstance(v, list) and len(v) == 2:
|
elif isinstance(v, list) and len(v) == 2:
|
||||||
q = parseCondition({'key': k, 'value': v[0], 'operator': '>='}, user) \
|
q = parseCondition({'key': k, 'value': v[0], 'operator': '>='}, user) \
|
||||||
& parseCondition({'key': k, 'value': v[1], 'operator': '<'}, user)
|
& parseCondition({'key': k, 'value': v[1], 'operator': '<'}, user)
|
||||||
|
|
|
@ -606,6 +606,8 @@ class Item(models.Model):
|
||||||
'pixels',
|
'pixels',
|
||||||
'timesaccessed',
|
'timesaccessed',
|
||||||
'resolution',
|
'resolution',
|
||||||
|
'width',
|
||||||
|
'height',
|
||||||
'rightslevel',
|
'rightslevel',
|
||||||
'saturation',
|
'saturation',
|
||||||
'size',
|
'size',
|
||||||
|
@ -678,6 +680,8 @@ class Item(models.Model):
|
||||||
s.duration = sum([v.duration for v in videos])
|
s.duration = sum([v.duration for v in videos])
|
||||||
v = videos[0]
|
v = videos[0]
|
||||||
s.resolution = v.width * v.height
|
s.resolution = v.width * v.height
|
||||||
|
s.width = v.width
|
||||||
|
s.height = v.height
|
||||||
if not s.aspectratio:
|
if not s.aspectratio:
|
||||||
s.aspectratio = float(utils.parse_decimal(v.display_aspect_ratio))
|
s.aspectratio = float(utils.parse_decimal(v.display_aspect_ratio))
|
||||||
s.pixels = sum([v.pixels for v in videos])
|
s.pixels = sum([v.pixels for v in videos])
|
||||||
|
@ -1156,8 +1160,10 @@ attrs = {
|
||||||
'__module__': 'item.models',
|
'__module__': 'item.models',
|
||||||
'item': models.OneToOneField('Item', related_name='sort', primary_key=True),
|
'item': models.OneToOneField('Item', related_name='sort', primary_key=True),
|
||||||
'duration': models.FloatField(null=True, blank=True, db_index=True),
|
'duration': models.FloatField(null=True, blank=True, db_index=True),
|
||||||
|
'width': models.BigIntegerField(null=True, blank=True, db_index=True),
|
||||||
|
'height': models.BigIntegerField(null=True, blank=True, db_index=True),
|
||||||
}
|
}
|
||||||
for key in filter(lambda k: 'columnWidth' in k or k['type'] in ('integer', 'time', 'float', 'date', 'list'), settings.CONFIG['itemKeys']):
|
for key in filter(lambda k: 'columnWidth' in k or k['type'] in ('integer', 'time', 'float', 'date', 'enum'), settings.CONFIG['itemKeys']):
|
||||||
name = key['id']
|
name = key['id']
|
||||||
name = {'id': 'itemId'}.get(name, name)
|
name = {'id': 'itemId'}.get(name, name)
|
||||||
sort_type = key.get('sort', key['type'])
|
sort_type = key.get('sort', key['type'])
|
||||||
|
@ -1179,7 +1185,7 @@ for key in filter(lambda k: 'columnWidth' in k or k['type'] in ('integer', 'time
|
||||||
'date': 'date',
|
'date': 'date',
|
||||||
'hue': 'float',
|
'hue': 'float',
|
||||||
'time': 'integer',
|
'time': 'integer',
|
||||||
'list': 'integer',
|
'enum': 'integer',
|
||||||
}.get(sort_type, sort_type)]
|
}.get(sort_type, sort_type)]
|
||||||
attrs[name] = model[0](**model[1])
|
attrs[name] = model[0](**model[1])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue