mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 20:49:27 +00:00
consolidate channe overwrite endpoint
This commit is contained in:
@@ -344,4 +344,4 @@ def channel_overwrites(channel_id, overwrites):
|
|||||||
channel.upload_to_es()
|
channel.upload_to_es()
|
||||||
channel.sync_to_videos()
|
channel.sync_to_videos()
|
||||||
|
|
||||||
return channel.json_data["channel_overwrites"]
|
return channel.json_data
|
||||||
|
|||||||
@@ -19,11 +19,6 @@ urlpatterns = [
|
|||||||
views.ChannelApiView.as_view(),
|
views.ChannelApiView.as_view(),
|
||||||
name="api-channel",
|
name="api-channel",
|
||||||
),
|
),
|
||||||
path(
|
|
||||||
"<slug:channel_id>/about/",
|
|
||||||
views.ChannelApiAboutView.as_view(),
|
|
||||||
name="api-channel-view",
|
|
||||||
),
|
|
||||||
path(
|
path(
|
||||||
"<slug:channel_id>/aggs/",
|
"<slug:channel_id>/aggs/",
|
||||||
views.ChannelAggsApiView.as_view(),
|
views.ChannelAggsApiView.as_view(),
|
||||||
|
|||||||
@@ -87,6 +87,21 @@ class ChannelApiView(ApiBaseView):
|
|||||||
self.get_document(channel_id)
|
self.get_document(channel_id)
|
||||||
return Response(self.response, status=self.status_code)
|
return Response(self.response, status=self.status_code)
|
||||||
|
|
||||||
|
def post(self, request, channel_id):
|
||||||
|
"""modify channel overwrites"""
|
||||||
|
data = request.data
|
||||||
|
if not isinstance(data, dict) or not "channel_overwrites" in data:
|
||||||
|
return Response({"error": "invalid payload"}, status=400)
|
||||||
|
|
||||||
|
overwrites = data["channel_overwrites"]
|
||||||
|
|
||||||
|
try:
|
||||||
|
json_data = channel_overwrites(channel_id, overwrites)
|
||||||
|
except ValueError as err:
|
||||||
|
return Response({"error": str(err)}, status=400)
|
||||||
|
|
||||||
|
return Response(json_data, status=200)
|
||||||
|
|
||||||
def delete(self, request, channel_id):
|
def delete(self, request, channel_id):
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
"""delete channel"""
|
"""delete channel"""
|
||||||
@@ -102,38 +117,6 @@ class ChannelApiView(ApiBaseView):
|
|||||||
return Response(message, status=status_code)
|
return Response(message, status=status_code)
|
||||||
|
|
||||||
|
|
||||||
class ChannelApiAboutView(ApiBaseView):
|
|
||||||
"""resolves to /api/channel/<channel_id>/about/
|
|
||||||
GET: returns the channel specific settings
|
|
||||||
POST: sets the channel specific settings, returning current values
|
|
||||||
"""
|
|
||||||
|
|
||||||
permission_classes = [AdminWriteOnly]
|
|
||||||
|
|
||||||
def get(self, request, channel_id):
|
|
||||||
"""get channel overwrites"""
|
|
||||||
# pylint: disable=unused-argument
|
|
||||||
channel = YoutubeChannel(channel_id)
|
|
||||||
channel.get_from_es()
|
|
||||||
if not channel.json_data:
|
|
||||||
return Response({"error": "unknown channel id"}, status=404)
|
|
||||||
|
|
||||||
return Response(channel.get_overwrites())
|
|
||||||
|
|
||||||
def post(self, request, channel_id):
|
|
||||||
"""modify channel overwrites"""
|
|
||||||
data = request.data
|
|
||||||
if not isinstance(data, dict):
|
|
||||||
return Response({"error": "invalid payload"}, status=400)
|
|
||||||
|
|
||||||
try:
|
|
||||||
new_channel_overwrites = channel_overwrites(channel_id, data)
|
|
||||||
except ValueError as err:
|
|
||||||
return Response({"error": str(err)}, status=400)
|
|
||||||
|
|
||||||
return Response(new_channel_overwrites, status=200)
|
|
||||||
|
|
||||||
|
|
||||||
class ChannelAggsApiView(ApiBaseView):
|
class ChannelAggsApiView(ApiBaseView):
|
||||||
"""resolves to /api/channel/<channel_id>/aggs/
|
"""resolves to /api/channel/<channel_id>/aggs/
|
||||||
GET: get channel aggregations
|
GET: get channel aggregations
|
||||||
|
|||||||
Reference in New Issue
Block a user