[API] add reindex endpoing
This commit is contained in:
parent
0f6bc3a420
commit
018b578982
|
@ -38,6 +38,7 @@ Note:
|
||||||
**Additional**
|
**Additional**
|
||||||
- [Login](#login-view)
|
- [Login](#login-view)
|
||||||
- [Task](#task-view) WIP
|
- [Task](#task-view) WIP
|
||||||
|
- [Refresh](#refresh-view)
|
||||||
- [Cookie](#cookie-view)
|
- [Cookie](#cookie-view)
|
||||||
- [Search](#search-view)
|
- [Search](#search-view)
|
||||||
- [Ping](#ping-view)
|
- [Ping](#ping-view)
|
||||||
|
@ -306,6 +307,20 @@ List of valid task names:
|
||||||
- **download_pending**: Start the download queue
|
- **download_pending**: Start the download queue
|
||||||
- **rescan_pending**: Rescan your subscriptions
|
- **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
|
## Cookie View
|
||||||
Check your youtube cookie settings, *status* turns to `true` if cookie has been validated.
|
Check your youtube cookie settings, *status* turns to `true` if cookie has been validated.
|
||||||
|
|
|
@ -12,6 +12,7 @@ from api.views import (
|
||||||
PlaylistApiListView,
|
PlaylistApiListView,
|
||||||
PlaylistApiVideoView,
|
PlaylistApiVideoView,
|
||||||
PlaylistApiView,
|
PlaylistApiView,
|
||||||
|
RefreshView,
|
||||||
SearchView,
|
SearchView,
|
||||||
SnapshotApiListView,
|
SnapshotApiListView,
|
||||||
SnapshotApiView,
|
SnapshotApiView,
|
||||||
|
@ -98,6 +99,11 @@ urlpatterns = [
|
||||||
DownloadApiView.as_view(),
|
DownloadApiView.as_view(),
|
||||||
name="api-download",
|
name="api-download",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"refresh/",
|
||||||
|
RefreshView.as_view(),
|
||||||
|
name="api-refresh",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"task/",
|
"task/",
|
||||||
TaskApiView.as_view(),
|
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.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, RedisQueue
|
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 (
|
from rest_framework.authentication import (
|
||||||
SessionAuthentication,
|
SessionAuthentication,
|
||||||
TokenAuthentication,
|
TokenAuthentication,
|
||||||
|
@ -589,6 +589,26 @@ class SnapshotApiView(ApiBaseView):
|
||||||
return Response(response)
|
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):
|
class CookieView(ApiBaseView):
|
||||||
"""resolves to /api/cookie/
|
"""resolves to /api/cookie/
|
||||||
GET: check if cookie is enabled
|
GET: check if cookie is enabled
|
||||||
|
|
Loading…
Reference in New Issue