diff --git a/tubearchivist/api/README.md b/tubearchivist/api/README.md index 7b64748..3c133bb 100644 --- a/tubearchivist/api/README.md +++ b/tubearchivist/api/README.md @@ -38,6 +38,7 @@ Note: **Additional** - [Login](#login-view) - [Task](#task-view) WIP +- [Refresh](#refresh-view) - [Cookie](#cookie-view) - [Search](#search-view) - [Ping](#ping-view) @@ -306,6 +307,20 @@ List of valid task names: - **download_pending**: Start the download queue - **rescan_pending**: Rescan your subscriptions +## Refresh View +GET /api/refresh/ +POST /api/refresh/ +Parameter: +- extract_videos: to refresh all videos for channels/playlists, default False + +Manually start a refresh task: post list of *videos*, *channels*, *playlists* +```json +{ + "videos": ["video1", "video2", "video3"], + "channels": ["channel1", "channel2", "channel3"], + "playlists": ["playlist1", "playlist2"] +} +``` ## Cookie View Check your youtube cookie settings, *status* turns to `true` if cookie has been validated. diff --git a/tubearchivist/api/urls.py b/tubearchivist/api/urls.py index 8662ad0..0476719 100644 --- a/tubearchivist/api/urls.py +++ b/tubearchivist/api/urls.py @@ -12,6 +12,7 @@ from api.views import ( PlaylistApiListView, PlaylistApiVideoView, PlaylistApiView, + RefreshView, SearchView, SnapshotApiListView, SnapshotApiView, @@ -98,6 +99,11 @@ urlpatterns = [ DownloadApiView.as_view(), name="api-download", ), + path( + "refresh/", + RefreshView.as_view(), + name="api-refresh", + ), path( "task/", TaskApiView.as_view(), diff --git a/tubearchivist/api/views.py b/tubearchivist/api/views.py index 3e5d79e..aebbf29 100644 --- a/tubearchivist/api/views.py +++ b/tubearchivist/api/views.py @@ -12,7 +12,7 @@ from home.src.index.video import SponsorBlock from home.src.ta.config import AppConfig from home.src.ta.helper import UrlListParser from home.src.ta.ta_redis import RedisArchivist, RedisQueue -from home.tasks import extrac_dl, subscribe_to +from home.tasks import check_reindex, extrac_dl, subscribe_to from rest_framework.authentication import ( SessionAuthentication, TokenAuthentication, @@ -589,6 +589,26 @@ class SnapshotApiView(ApiBaseView): return Response(response) +class RefreshView(ApiBaseView): + """resolves to /api/refresh/ + GET: get refresh progress + POST: start a manual refresh task + """ + + def get(self, request): + """handle get request""" + # pylint: disable=unused-argument + return Response({"status": False}) + + def post(self, request): + """handle post request""" + data = request.data + extract_videos = bool(request.GET.get("extract_videos", False)) + check_reindex.delay(data=data, extract_videos=extract_videos) + + return Response(data) + + class CookieView(ApiBaseView): """resolves to /api/cookie/ GET: check if cookie is enabled