From 78eff229ea2ad529a8579ccb0aa6ca7049c3a042 Mon Sep 17 00:00:00 2001 From: MerlinScheurer Date: Mon, 13 May 2024 14:53:05 +0200 Subject: [PATCH 1/3] Add notification api --- mkdocs/docs/api/additional.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mkdocs/docs/api/additional.md b/mkdocs/docs/api/additional.md index abf73d5..21f7384 100644 --- a/mkdocs/docs/api/additional.md +++ b/mkdocs/docs/api/additional.md @@ -140,3 +140,28 @@ When valid returns message with user id and TubeArchivist version: "version": "v0.4.7" } ``` + +## Notification List +Get all current notifications. +**GET** `/api/notification/` + +Parameter: + +- filter: "download" | "settings" | "channel" + +```json +[ + { + "title": "Rescan your Subscriptions", + "group": "download:scan", + "api-start": true, + "api-stop": true, + "level": "info", + "id": "1111111-1111-1111-1111-1111111", + "command": false, // false || "STOP" || "KILL" + "messages": ["Task completed successfully"], + "progress": 0.000001 + } +] +``` + From 256ee8c7688419020bc88d4a09f5202aa6fbb8de Mon Sep 17 00:00:00 2001 From: MerlinScheurer Date: Mon, 13 May 2024 14:55:48 +0200 Subject: [PATCH 2/3] Refac remove comment from json --- mkdocs/docs/api/additional.md | 110 ++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 44 deletions(-) diff --git a/mkdocs/docs/api/additional.md b/mkdocs/docs/api/additional.md index 21f7384..a4f7d97 100644 --- a/mkdocs/docs/api/additional.md +++ b/mkdocs/docs/api/additional.md @@ -1,149 +1,170 @@ # Additional API endpoints ## Login + Return token and user ID for username and password: **POST** `/api/login/` + ```json { - "username": "tubearchivist", - "password": "verysecret" + "username": "tubearchivist", + "password": "verysecret" } ``` -after successful login returns +after successful login returns + ```json { - "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", - "user_id": 1 + "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "user_id": 1 } ``` ## Refresh -**GET** `/api/refresh/` + +**GET** `/api/refresh/` Parameters: -- **type**: one of *video*, *channel*, *playlist*, optional +- **type**: one of _video_, _channel_, _playlist_, optional - **id**: item id, optional without specifying type: return total for all queued items: + ```json { - "total_queued": 2, - "type": "all", - "state": "running" + "total_queued": 2, + "type": "all", + "state": "running" } ``` specify type: return total items queue of this type: + ```json { - "total_queued": 2, - "type": "video", - "state": "running" + "total_queued": 2, + "type": "video", + "state": "running" } ``` -specify type *and* id to get state of item in queue: +specify type _and_ id to get state of item in queue: + ```json { - "total_queued": 2, - "type": "video", - "state": "in_queue", - "id": "video-id" + "total_queued": 2, + "type": "video", + "state": "in_queue", + "id": "video-id" } ``` -**POST** `/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 *video*, *channel*, *playlist* IDs: +Manually start a refresh task: post list of _video_, _channel_, _playlist_ IDs: + ```json { - "video": ["video1", "video2", "video3"], - "channel": ["channel1", "channel2", "channel3"], - "playlist": ["playlist1", "playlist2"] + "video": ["video1", "video2", "video3"], + "channel": ["channel1", "channel2", "channel3"], + "playlist": ["playlist1", "playlist2"] } ``` ## Cookie -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. **GET** `/api/cookie/` + ```json { - "cookie_enabled": true, - "status": true, - "validated": 1680953715, - "validated_str": "timestamp" + "cookie_enabled": true, + "status": true, + "validated": 1680953715, + "validated_str": "timestamp" } ``` **POST** `/api/cookie/` Send empty post request to validate cookie. + ```json { - "cookie_validated": true + "cookie_validated": true } ``` **PUT** `/api/cookie/` Send put request containing the cookie as a string: + ```json { - "cookie": "your-cookie-as-string" + "cookie": "your-cookie-as-string" } ``` + Imports and validates cookie, returns on success: + ```json { - "cookie_import": "done", - "cookie_validated": true + "cookie_import": "done", + "cookie_validated": true } ``` + Or returns status code 400 on failure: + ```json { - "cookie_import": "fail", - "cookie_validated": false + "cookie_import": "fail", + "cookie_validated": false } ``` ## Search -**GET** `/api/search/?query=` + +**GET** `/api/search/?query=` Returns search results from your query. ## Watched -**POST** `/api/watched/` + +**POST** `/api/watched/` Change watched state, where the `id` can be a single video, or channel/playlist to change all videos belonging to that channel/playlist. ```json { - "id": "xxxxxxx", - "is_watched": true + "id": "xxxxxxx", + "is_watched": true } ``` ## Ping + Validate your connection and authentication with the API **GET** `/api/ping/` -When valid returns message with user id and TubeArchivist version: +When valid returns message with user id and TubeArchivist version: + ```json { - "response": "pong", - "user": 1, - "version": "v0.4.7" + "response": "pong", + "user": 1, + "version": "v0.4.7" } ``` ## Notification List + Get all current notifications. -**GET** `/api/notification/` +**GET** `/api/notification/` Parameter: @@ -158,10 +179,11 @@ Parameter: "api-stop": true, "level": "info", "id": "1111111-1111-1111-1111-1111111", - "command": false, // false || "STOP" || "KILL" + "command": false, "messages": ["Task completed successfully"], "progress": 0.000001 } ] ``` +"command" can be false || "STOP" || "KILL". From 674de5fa697d019a52270b81c3f467c24d4fa4b2 Mon Sep 17 00:00:00 2001 From: MerlinScheurer Date: Mon, 13 May 2024 14:56:39 +0200 Subject: [PATCH 3/3] Fix formatting --- mkdocs/docs/api/additional.md | 108 ++++++++++++++-------------------- 1 file changed, 44 insertions(+), 64 deletions(-) diff --git a/mkdocs/docs/api/additional.md b/mkdocs/docs/api/additional.md index a4f7d97..5031a21 100644 --- a/mkdocs/docs/api/additional.md +++ b/mkdocs/docs/api/additional.md @@ -1,170 +1,149 @@ # Additional API endpoints ## Login - Return token and user ID for username and password: **POST** `/api/login/` - ```json { - "username": "tubearchivist", - "password": "verysecret" + "username": "tubearchivist", + "password": "verysecret" } ``` -after successful login returns - +after successful login returns ```json { - "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", - "user_id": 1 + "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "user_id": 1 } ``` ## Refresh - -**GET** `/api/refresh/` +**GET** `/api/refresh/` Parameters: -- **type**: one of _video_, _channel_, _playlist_, optional +- **type**: one of *video*, *channel*, *playlist*, optional - **id**: item id, optional without specifying type: return total for all queued items: - ```json { - "total_queued": 2, - "type": "all", - "state": "running" + "total_queued": 2, + "type": "all", + "state": "running" } ``` specify type: return total items queue of this type: - ```json { - "total_queued": 2, - "type": "video", - "state": "running" + "total_queued": 2, + "type": "video", + "state": "running" } ``` -specify type _and_ id to get state of item in queue: - +specify type *and* id to get state of item in queue: ```json { - "total_queued": 2, - "type": "video", - "state": "in_queue", - "id": "video-id" + "total_queued": 2, + "type": "video", + "state": "in_queue", + "id": "video-id" } ``` -**POST** `/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 _video_, _channel_, _playlist_ IDs: - +Manually start a refresh task: post list of *video*, *channel*, *playlist* IDs: ```json { - "video": ["video1", "video2", "video3"], - "channel": ["channel1", "channel2", "channel3"], - "playlist": ["playlist1", "playlist2"] + "video": ["video1", "video2", "video3"], + "channel": ["channel1", "channel2", "channel3"], + "playlist": ["playlist1", "playlist2"] } ``` ## Cookie - -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. **GET** `/api/cookie/` - ```json { - "cookie_enabled": true, - "status": true, - "validated": 1680953715, - "validated_str": "timestamp" + "cookie_enabled": true, + "status": true, + "validated": 1680953715, + "validated_str": "timestamp" } ``` **POST** `/api/cookie/` Send empty post request to validate cookie. - ```json { - "cookie_validated": true + "cookie_validated": true } ``` **PUT** `/api/cookie/` Send put request containing the cookie as a string: - ```json { - "cookie": "your-cookie-as-string" + "cookie": "your-cookie-as-string" } ``` - Imports and validates cookie, returns on success: - ```json { - "cookie_import": "done", - "cookie_validated": true + "cookie_import": "done", + "cookie_validated": true } ``` - Or returns status code 400 on failure: - ```json { - "cookie_import": "fail", - "cookie_validated": false + "cookie_import": "fail", + "cookie_validated": false } ``` ## Search - -**GET** `/api/search/?query=` +**GET** `/api/search/?query=` Returns search results from your query. ## Watched - -**POST** `/api/watched/` +**POST** `/api/watched/` Change watched state, where the `id` can be a single video, or channel/playlist to change all videos belonging to that channel/playlist. ```json { - "id": "xxxxxxx", - "is_watched": true + "id": "xxxxxxx", + "is_watched": true } ``` ## Ping - Validate your connection and authentication with the API **GET** `/api/ping/` -When valid returns message with user id and TubeArchivist version: - +When valid returns message with user id and TubeArchivist version: ```json { - "response": "pong", - "user": 1, - "version": "v0.4.7" + "response": "pong", + "user": 1, + "version": "v0.4.7" } ``` ## Notification List - Get all current notifications. -**GET** `/api/notification/` +**GET** `/api/notification/` Parameter: @@ -187,3 +166,4 @@ Parameter: ``` "command" can be false || "STOP" || "KILL". +