mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2025-01-14 12:50:13 +00:00
[API] add reindex endpoing
This commit is contained in:
parent
0f6bc3a420
commit
018b578982
@ -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.
|
||||
|
@ -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(),
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user