mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50:14 +00:00
simulate sponsorblock post request
This commit is contained in:
parent
bace7d41af
commit
286b1cf9b6
@ -11,6 +11,7 @@ from api.views import (
|
|||||||
VideoApiListView,
|
VideoApiListView,
|
||||||
VideoApiView,
|
VideoApiView,
|
||||||
VideoProgressView,
|
VideoProgressView,
|
||||||
|
VideoSponsorView,
|
||||||
)
|
)
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
@ -32,6 +33,11 @@ urlpatterns = [
|
|||||||
VideoProgressView.as_view(),
|
VideoProgressView.as_view(),
|
||||||
name="api-video-progress",
|
name="api-video-progress",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"video/<slug:video_id>/sponsor/",
|
||||||
|
VideoSponsorView.as_view(),
|
||||||
|
name="api-video-sponsor",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"channel/",
|
"channel/",
|
||||||
ChannelApiListView.as_view(),
|
ChannelApiListView.as_view(),
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from api.src.search_processor import SearchProcess
|
from api.src.search_processor import SearchProcess
|
||||||
from home.src.download.thumbnails import ThumbManager
|
from home.src.download.thumbnails import ThumbManager
|
||||||
from home.src.es.connect import ElasticWrap
|
from home.src.es.connect import ElasticWrap
|
||||||
|
from home.src.index.video import SponsorBlock
|
||||||
from home.src.ta.config import AppConfig
|
from home.src.ta.config import AppConfig
|
||||||
from home.src.ta.helper import UrlListParser
|
from home.src.ta.helper import UrlListParser
|
||||||
from home.src.ta.ta_redis import RedisArchivist
|
from home.src.ta.ta_redis import RedisArchivist
|
||||||
@ -144,6 +145,35 @@ class VideoProgressView(ApiBaseView):
|
|||||||
return Response(self.response)
|
return Response(self.response)
|
||||||
|
|
||||||
|
|
||||||
|
class VideoSponsorView(ApiBaseView):
|
||||||
|
"""resolves to /api/video/<video_id>/
|
||||||
|
handle sponsor block integration
|
||||||
|
"""
|
||||||
|
|
||||||
|
search_base = "ta_video/_doc/"
|
||||||
|
|
||||||
|
def get(self, request, video_id):
|
||||||
|
"""get sponsor info"""
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
|
||||||
|
self.get_document(video_id)
|
||||||
|
sponsorblock = self.response["data"].get("sponsorblock")
|
||||||
|
|
||||||
|
return Response(sponsorblock)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def post(request, video_id):
|
||||||
|
"""post verification and timestamps"""
|
||||||
|
start_time = request.data.get("startTime")
|
||||||
|
end_time = request.data.get("endTime")
|
||||||
|
|
||||||
|
response, status_code = SponsorBlock(request.user.id).post_timestamps(
|
||||||
|
video_id, start_time, end_time
|
||||||
|
)
|
||||||
|
|
||||||
|
return Response(response, status=status_code)
|
||||||
|
|
||||||
|
|
||||||
class ChannelApiView(ApiBaseView):
|
class ChannelApiView(ApiBaseView):
|
||||||
"""resolves to /api/channel/<channel_id>/
|
"""resolves to /api/channel/<channel_id>/
|
||||||
GET: returns metadata dict of channel
|
GET: returns metadata dict of channel
|
||||||
|
Loading…
Reference in New Issue
Block a user