diff --git a/tubearchivist/api/README.md b/tubearchivist/api/README.md index 65cab1f..f6e10f4 100644 --- a/tubearchivist/api/README.md +++ b/tubearchivist/api/README.md @@ -123,12 +123,18 @@ POST /api/channel/ ## Channel Item View /api/channel/\/ +## Channel Videos View +/api/channel/\/video/ + ## Playlist List View /api/playlist/ ## Playlists Item View /api/playlist/\/ +## Playlist Videos View +/api/playlist/\/video/ + ## Download Queue List View /api/download/ diff --git a/tubearchivist/api/urls.py b/tubearchivist/api/urls.py index cb70e4c..b19f5c7 100644 --- a/tubearchivist/api/urls.py +++ b/tubearchivist/api/urls.py @@ -2,12 +2,14 @@ from api.views import ( ChannelApiListView, + ChannelApiVideoView, ChannelApiView, DownloadApiListView, DownloadApiView, LoginApiView, PingView, PlaylistApiListView, + PlaylistApiVideoView, PlaylistApiView, VideoApiListView, VideoApiView, @@ -50,15 +52,25 @@ urlpatterns = [ name="api-channel", ), path( - "playlist//", - PlaylistApiView.as_view(), - name="api-playlist", + "channel//video/", + ChannelApiVideoView.as_view(), + name="api-channel-video", ), path( "playlist/", PlaylistApiListView.as_view(), name="api-playlist-list", ), + path( + "playlist//", + PlaylistApiView.as_view(), + name="api-playlist", + ), + path( + "playlist//video/", + PlaylistApiVideoView.as_view(), + name="api-playlist-video", + ), path( "download/", DownloadApiListView.as_view(), diff --git a/tubearchivist/api/views.py b/tubearchivist/api/views.py index 60f2ba3..72dfeaa 100644 --- a/tubearchivist/api/views.py +++ b/tubearchivist/api/views.py @@ -222,6 +222,41 @@ class ChannelApiListView(ApiBaseView): return Response(data) +class ChannelApiVideoView(ApiBaseView): + """resolves to /api/channel//video + GET: returns a list of videos of channel + """ + + search_base = "ta_video/_search/" + + def get(self, request, channel_id): + # pylint: disable=unused-argument + """handle get request""" + data = { + "query": {"term": {"channel.channel_id": {"value": channel_id}}} + } + self.get_document_list(data) + self.get_paginate() + + return Response(self.response) + + +class PlaylistApiListView(ApiBaseView): + """resolves to /api/playlist/ + GET: returns list of indexed playlists + """ + + search_base = "ta_playlist/_search/" + + def get(self, request): + # pylint: disable=unused-argument + """handle get request""" + data = {"query": {"match_all": {}}} + self.get_document_list(data) + self.get_paginate() + return Response(self.response) + + class PlaylistApiView(ApiBaseView): """resolves to /api/playlist// GET: returns metadata dict of playlist @@ -236,17 +271,19 @@ class PlaylistApiView(ApiBaseView): return Response(self.response, status=self.status_code) -class PlaylistApiListView(ApiBaseView): - """resolves to /api/playlist/ - GET: returns list of indexed playlists +class PlaylistApiVideoView(ApiBaseView): + """resolves to /api/playlist//video + GET: returns list of videos in playlist """ - search_base = "ta_playlist/_search/" + search_base = "ta_video/_search/" - def get(self, request): + def get(self, request, playlist_id): # pylint: disable=unused-argument """handle get request""" - data = {"query": {"match_all": {}}} + data = { + "query": {"term": {"playlist.keyword": {"value": playlist_id}}} + } self.get_document_list(data) self.get_paginate() return Response(self.response)