add video list api view

This commit is contained in:
simon 2022-03-29 17:05:22 +07:00
parent 0c8fa8f49e
commit 6f5969f520
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
3 changed files with 26 additions and 0 deletions

View File

@ -38,6 +38,9 @@ after successful login returns
}
```
## Video List View
/api/video/
## Video Item View
/api/video/\<video_id>/

View File

@ -7,6 +7,7 @@ from api.views import (
DownloadApiView,
LoginApiView,
PlaylistApiView,
VideoApiListView,
VideoApiView,
VideoProgressView,
)
@ -14,6 +15,11 @@ from django.urls import path
urlpatterns = [
path("login/", LoginApiView.as_view(), name="api-login"),
path(
"video/",
VideoApiListView.as_view(),
name="api-video-list",
),
path(
"video/<slug:video_id>/",
VideoApiView.as_view(),

View File

@ -89,6 +89,23 @@ class VideoApiView(ApiBaseView):
return Response(self.response, status=self.status_code)
class VideoApiListView(ApiBaseView):
"""resolves to /api/video/
GET: returns list of videos
"""
search_base = "ta_video/_search/"
def get(self, request):
# pylint: disable=unused-argument
"""get request"""
data = {"query": {"match_all": {}}}
self.get_document_list(data)
self.get_paginate()
return Response(self.response)
class VideoProgressView(ApiBaseView):
"""resolves to /api/video/<video_id>/
handle progress status for video