From 6f5969f520c058c88924bf694a3b9b5bb89a0ce0 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 29 Mar 2022 17:05:22 +0700 Subject: [PATCH] add video list api view --- tubearchivist/api/README.md | 3 +++ tubearchivist/api/urls.py | 6 ++++++ tubearchivist/api/views.py | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/tubearchivist/api/README.md b/tubearchivist/api/README.md index 75fafae..8620e3b 100644 --- a/tubearchivist/api/README.md +++ b/tubearchivist/api/README.md @@ -38,6 +38,9 @@ after successful login returns } ``` +## Video List View +/api/video/ + ## Video Item View /api/video/\/ diff --git a/tubearchivist/api/urls.py b/tubearchivist/api/urls.py index 677682d..9c0ed3e 100644 --- a/tubearchivist/api/urls.py +++ b/tubearchivist/api/urls.py @@ -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//", VideoApiView.as_view(), diff --git a/tubearchivist/api/views.py b/tubearchivist/api/views.py index 423f591..e9608c1 100644 --- a/tubearchivist/api/views.py +++ b/tubearchivist/api/views.py @@ -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// handle progress status for video