add video filter by height

This commit is contained in:
Simon
2025-08-12 13:58:14 +07:00
parent 445ef8ad05
commit f2da730aa2
9 changed files with 47 additions and 0 deletions

View File

@@ -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):

View File

@@ -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")

View File

@@ -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/"