Merge branch 'testing' of https://github.com/bbilly1/tubearchivist into feat/react-frontend

This commit is contained in:
Sean Norwood 2022-04-17 04:30:34 +00:00
commit 5e5680a661
3 changed files with 69 additions and 11 deletions

View File

@ -123,12 +123,18 @@ POST /api/channel/
## Channel Item View
/api/channel/\<channel_id>/
## Channel Videos View
/api/channel/\<channel_id>/video/
## Playlist List View
/api/playlist/
## Playlists Item View
/api/playlist/\<playlist_id>/
## Playlist Videos View
/api/playlist/\<playlist_id>/video/
## Download Queue List View
/api/download/

View File

@ -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/<slug:playlist_id>/",
PlaylistApiView.as_view(),
name="api-playlist",
"channel/<slug:channel_id>/video/",
ChannelApiVideoView.as_view(),
name="api-channel-video",
),
path(
"playlist/",
PlaylistApiListView.as_view(),
name="api-playlist-list",
),
path(
"playlist/<slug:playlist_id>/",
PlaylistApiView.as_view(),
name="api-playlist",
),
path(
"playlist/<slug:playlist_id>/video/",
PlaylistApiVideoView.as_view(),
name="api-playlist-video",
),
path(
"download/",
DownloadApiListView.as_view(),

View File

@ -52,7 +52,10 @@ class ApiBaseView(APIView):
print(self.search_base)
response, status_code = ElasticWrap(self.search_base).get(data=data)
self.response["data"] = SearchProcess(response).process()
if self.response["data"]:
self.status_code = status_code
else:
self.status_code = 404
class VideoApiView(ApiBaseView):
@ -222,17 +225,22 @@ class ChannelApiListView(ApiBaseView):
return Response(data)
class PlaylistApiView(ApiBaseView):
"""resolves to /api/playlist/<playlist_id>/
GET: returns metadata dict of playlist
class ChannelApiVideoView(ApiBaseView):
"""resolves to /api/channel/<channel-id>/video
GET: returns a list of videos of channel
"""
search_base = "ta_playlist/_doc/"
search_base = "ta_video/_search/"
def get(self, request, playlist_id):
def get(self, request, channel_id):
# pylint: disable=unused-argument
"""get request"""
self.get_document(playlist_id)
"""handle get request"""
data = {
"query": {"term": {"channel.channel_id": {"value": channel_id}}}
}
self.get_document_list(data)
self.get_paginate()
return Response(self.response, status=self.status_code)
@ -252,6 +260,38 @@ class PlaylistApiListView(ApiBaseView):
return Response(self.response)
class PlaylistApiView(ApiBaseView):
"""resolves to /api/playlist/<playlist_id>/
GET: returns metadata dict of playlist
"""
search_base = "ta_playlist/_doc/"
def get(self, request, playlist_id):
# pylint: disable=unused-argument
"""get request"""
self.get_document(playlist_id)
return Response(self.response, status=self.status_code)
class PlaylistApiVideoView(ApiBaseView):
"""resolves to /api/playlist/<playlist_id>/video
GET: returns list of videos in playlist
"""
search_base = "ta_video/_search/"
def get(self, request, playlist_id):
# pylint: disable=unused-argument
"""handle get request"""
data = {
"query": {"term": {"playlist.keyword": {"value": playlist_id}}}
}
self.get_document_list(data)
self.get_paginate()
return Response(self.response, status=self.status_code)
class DownloadApiView(ApiBaseView):
"""resolves to /api/download/<video_id>/
GET: returns metadata dict of an item in the download queue