mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 18:09:33 +00:00
add video filter by height
This commit is contained in:
@@ -120,6 +120,7 @@ class VideoListQuerySerializer(serializers.Serializer):
|
||||
choices=VideoTypeEnum.values_known(), required=False
|
||||
)
|
||||
page = serializers.IntegerField(required=False)
|
||||
height = serializers.IntegerField(required=False)
|
||||
|
||||
|
||||
class CommentThreadItemSerializer(serializers.Serializer):
|
||||
|
||||
@@ -44,6 +44,11 @@ class QueryBuilder:
|
||||
type_list_list = self.parse_type(video_type)
|
||||
must_list.append(type_list_list)
|
||||
|
||||
height = self.request_params.get("height")
|
||||
if height:
|
||||
height_must = self.parse_height(height)
|
||||
must_list.append(height_must)
|
||||
|
||||
query = {"bool": {"must": must_list}}
|
||||
|
||||
return query
|
||||
@@ -83,6 +88,11 @@ class QueryBuilder:
|
||||
|
||||
return {"match": {"vid_type": vid_type}}
|
||||
|
||||
def parse_height(self, height: str):
|
||||
"""parse height to int"""
|
||||
|
||||
return {"term": {"streams.height": {"value": height}}}
|
||||
|
||||
def parse_sort(self) -> dict | None:
|
||||
"""build sort key"""
|
||||
playlist = self.request_params.get("playlist")
|
||||
|
||||
@@ -31,6 +31,7 @@ class VideoApiListView(ApiBaseView):
|
||||
- sort:enum=published|downloaded|views|likes|duration|filesize
|
||||
- order:enum=asc|desc
|
||||
- type:enum=videos|streams|shorts
|
||||
- height:int=px
|
||||
"""
|
||||
|
||||
search_base = "ta_video/_search/"
|
||||
|
||||
Reference in New Issue
Block a user