diff --git a/api.yml b/api.yml index f51890c..07b8493 100644 --- a/api.yml +++ b/api.yml @@ -1,4 +1,4 @@ -openapi: "3.0.3" +openapi: "3.1.0" info: title: EH Downloader API version: "1.0" @@ -33,7 +33,7 @@ components: properties: data: type: object - example: {ok: true, status: 0, data: {}} + example: { ok: true, status: 0, data: {} } ApiResponseError: description: Api response with a error allOf: @@ -59,6 +59,163 @@ components: type: string - type: string description: The data of configuration + ConfigOptional: + description: Configuration of server + type: object + properties: + cookies: + type: string + description: Cookies + db_path: + type: string + description: The folder where the database is stored + ua: + type: string + description: User Agent + ex: + type: boolean + description: Whether to use exhentai.org + base: + type: string + description: Download location + max_task_count: + type: integer + description: Maximum number of parallel tasks + mpv: + type: boolean + description: Fetch page data from Multi-Page Viewer + max_retry_count: + type: integer + description: Maximum retry count + max_download_img_count: + type: integer + description: Maximum number of parallel downloads of images + download_original_img: + type: boolean + description: Whether to download original images + port: + type: integer + description: Listening port + export_zip_jpn_title: + type: boolean + description: Whether to use japanese title first when exporting zip + hostname: + type: string + description: Listening host + meili_host: + type: string + description: Meilisearch server host + meili_search_api_key: + type: string + description: Meilisearch API key for searching + meili_update_api_key: + type: string + description: Meilisearch API key for updating gallery metadata + ffmpeg_path: + type: string + description: The path to the ffmpeg binary + thumbnail_method: + $ref: "#/components/schemas/ThumbnailMethod" + thumbnail_dir: + type: string + description: The folder used to store thumbnails + remove_previous_gallery: + type: boolean + description: Whether to remove old galleries which replaced by new ones + img_verify_secret: + type: string + description: The secret of image verify + meili_hosts: + type: object + additionalProperties: + type: string + description: Meilisearch server hostname for specific domains + cors_credentials_hosts: + type: array + items: + type: string + description: The URL origins which are allowed to send CORS requests with credentials + flutter_frontend: + type: string + description: The path of flutter frontend + fetch_timeout: + type: integer + description: Fetch timeout in milliseconds + download_timeout: + type: integer + description: Download timeout in milliseconds + ffprobe_path: + type: string + description: The path to the ffprobe binary + redirect_to_flutter: + type: boolean + description: Whether to redirect to Flutter frontend when accessing the root URL + download_timeout_check_interval: + type: integer + description: The interval of checking download timeout in milliseconds + eh_metadata_cache_time: + type: integer + description: The time to cache the metadata of the gallery from E-Hentai in hours + random_file_secret: + type: string + description: The secret of token to access random file without login + use_path_based_img_url: + type: boolean + description: Whether to put parameters to image URL path + check_file_hash: + type: boolean + description: Whether to verify file integrity when downloading or importing + import_method: + $ref: "#/components/schemas/ImportMethod" + max_import_img_count: + type: integer + description: Maximum number of images to be imported in parallel + enable_server_timing: + type: boolean + description: Whether to enable server time tracking + Config: + allOf: + - $ref: "#/components/schemas/ConfigOptional" + - properties: + cookies: + type: boolean + description: True if Cookies is set + required: + - cookies + - ex + - base + - max_task_count + - mpv + - max_retry_count + - max_download_img_count + - download_original_img + - port + - export_zip_jpn_title + - hostname + - ffmpeg_path + - thumbnail_method + - thumbnail_dir + - remove_previous_gallery + - cors_credentials_hosts + - fetch_timeout + - download_timeout + - ffprobe_path + - redirect_to_flutter + - download_timeout_check_interval + - eh_metadata_cache_time + - use_path_based_img_url + - check_file_hash + - import_method + - max_import_img_count + - enable_server_timing + ConfigUpdated: + description: result of updateConfig + type: object + properties: + is_unsafe: + type: boolean + description: True if some modification of configuration only works after server restart + required: [is_unsafe] EhFileBasic: description: Basic data for file type: object @@ -92,6 +249,45 @@ components: properties: data: $ref: "#/components/schemas/EhFiles" + EHImageLimit: + description: E-Hentai image limits + type: object + properties: + current: + type: integer + description: Current used + max: + type: integer + description: Maximum limit + EHImageLimitApiResult: + description: Api response for getEhImageLimit + allOf: + - $ref: "#/components/schemas/ApiResponse" + - type: object + required: [data] + properties: + data: + $ref: "#/components/schemas/EHImageLimit" + EHMetaInfo: + description: E-Hentai metadata information map + type: object + additionalProperties: + allOf: + - $ref: "#/components/schemas/ApiResponse" + - type: object + required: [data] + properties: + data: + $ref: "#/components/schemas/GalleryMetadataSingle" + EHMetaInfoApiResult: + description: Api response for getEhMetadata + allOf: + - $ref: "#/components/schemas/ApiResponse" + - type: object + required: [data] + properties: + data: + $ref: "#/components/schemas/EHMetaInfo" ExtendedPMeta: description: Page metadata with extended information type: object @@ -152,19 +348,17 @@ components: description: Gallery metadata type: object required: - [ - gid, - token, - title, - title_jpn, - category, - uploader, - posted, - filecount, - filesize, - expunged, - rating, - ] + - gid + - token + - title + - title_jpn + - category + - uploader + - posted + - filecount + - filesize + - expunged + - rating properties: gid: type: integer @@ -188,7 +382,7 @@ components: posted: type: integer format: int64 - description: Posted epoch time in milliseconds + description: Posted epoch time filecount: type: integer description: File count in gallery @@ -216,6 +410,121 @@ components: first_token: type: string description: First gallery token + GalleryMetadataSingle: + description: Gallery metadata from E-Hentai api + type: object + required: + - gid + - token + - archiver_key + - title + - title_jpn + - category + - thumb + - uploader + - posted + - filecount + - filesize + - expunged + - rating + - torrentcount + - torrents + - tags + properties: + gid: + type: number + format: int64 + description: Gallery id + token: + type: string + description: Gallery token + archiver_key: + type: string + title: + type: string + description: HTML Escaped title + title_jpn: + type: string + description: HTML Escaped japanese title + category: + type: string + description: Category + thumb: + type: string + description: Thumbnail URL + uploader: + type: string + description: HTML Escaped uploader name + posted: + type: string + description: Posted epoch time + filecount: + type: string + description: File count in gallery + filesize: + type: integer + format: int64 + description: Total size of files + expunged: + type: boolean + description: True if gallery is not visible + rating: + type: number + description: Rating + torrentcount: + type: integer + description: Torrent count + torrents: + type: array + items: + $ref: "#/components/schemas/GalleryMetadataTorrentInfo" + description: Torrents + tags: + type: array + items: + type: string + description: List of tags + parent_gid: + type: integer + format: int64 + description: Parent gallery id + parent_token: + type: string + description: Parent gallery token + first_gid: + type: integer + format: int64 + description: First gallery id + first_token: + type: string + description: First gallery token + GalleryMetadataTorrentInfo: + description: Torrent information + type: object + required: [hash, added, name, tsize, fsize] + properties: + hash: + type: string + added: + type: string + name: + type: string + tsize: + type: string + fsize: + type: string + ImportMethod: + description: import method + type: integer + oneOf: + - title: Copy + const: 0 + - title: CopyThenDelete + const: 1 + - title: Move + const: 2 + - title: Keep + const: 3 Tag: description: Gallery Tag type: object @@ -233,6 +542,16 @@ components: intro: type: string description: Chinese introduction of tag + ThumbnailMethod: + description: Thumbnail method + type: integer + oneOf: + - title: FFMPEG_API + const: 0 + description: ffmpeg API + - title: FFMPEG_BINARY + const: 1 + description: ffmpeg BINARY securitySchemes: TokenAuth: type: apiKey @@ -269,14 +588,15 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApiResponseEmpty' + $ref: "#/components/schemas/ApiResponseEmpty" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ApiResponseError" - example: { "ok": false, "status": 2, "error": "client is needed." } + example: + { "ok": false, "status": 2, "error": "client is needed." } "401": description: Authorization information is missing or invalid content: @@ -313,14 +633,15 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ClientConfigApiResult' + $ref: "#/components/schemas/ClientConfigApiResult" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ApiResponseError" - example: { "ok": false, "status": 2, "error": "client is needed." } + example: + { "ok": false, "status": 2, "error": "client is needed." } "401": description: Authorization information is missing or invalid content: @@ -342,8 +663,7 @@ paths: application/json: schema: $ref: "#/components/schemas/ApiResponseError" - example: - { "ok": false, "status": 404, "error": "Not found" } + example: { "ok": false, "status": 404, "error": "Not found" } put: operationId: putClientConfig summary: Create/Update client configuration @@ -369,14 +689,15 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ApiResponseEmpty' + $ref: "#/components/schemas/ApiResponseEmpty" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ApiResponseError" - example: { "ok": false, "status": 2, "error": "client is needed." } + example: + { "ok": false, "status": 2, "error": "client is needed." } "401": description: Authorization information is missing or invalid content: @@ -392,6 +713,266 @@ paths: $ref: "#/components/schemas/ApiResponseError" example: { "ok": false, "status": 403, "error": "Permission denied." } + /config: + get: + operationId: getConfig + summary: Get server's configuration + parameters: + - name: current + in: query + schema: + type: boolean + description: Whether to return current server's configuration + - name: type + in: query + schema: + enum: ["ws"] + description: Connection protocol + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/Config" + "401": + description: Authorization information is missing or invalid + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponseError" + example: { "ok": false, "status": 401, "error": "Unauthorized" } + "403": + description: Permission denied + content: + text/plain: + example: Permission denied + post: + operationId: updateConfig + summary: Update server's configuration + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/ConfigOptional" + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ConfigUpdated" + "400": + description: Bad Request + content: + text/plain: + example: Bad Request + "401": + description: Authorization information is missing or invalid + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponseError" + example: { "ok": false, "status": 401, "error": "Unauthorized" } + "403": + description: Permission denied + content: + text/plain: + example: Permission denied + /deploy_id: + get: + operationId: getDeployId + summary: Get deployment id + responses: + "200": + description: OK + content: + application/json: + schema: + type: object + properties: + id: + type: string + description: Deployment id + required: [id] + "401": + description: Authorization information is missing or invalid + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponseError" + example: { "ok": false, "status": 401, "error": "Unauthorized" } + /eh/image_limit: + get: + operationId: getEhImageLimit + summary: Get E-Hentai image limits + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/EHImageLimitApiResult" + "400": + description: Bad request + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponseError" + example: + { "ok": false, "status": 1, "error": "Not logged in." } + "401": + description: Authorization information is missing or invalid + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponseError" + example: { "ok": false, "status": 401, "error": "Unauthorized" } + "403": + description: Permission denied + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponseError" + example: + { "ok": false, "status": 403, "error": "Permission denied." } + /eh/metadata: + get: + operationId: getEhMetadata + summary: Get gallery metadata from E-Hentai api + parameters: + - name: gid + in: query + schema: + type: array + items: + type: integer + format: int64 + required: true + description: List of gallery ids + - name: token + in: query + schema: + type: array + items: + type: string + required: true + description: List of gallery tokens + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/EHMetaInfoApiResult" + "400": + description: Bad request + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponseError" + example: + { "ok": false, "status": 3, "error": "Length of gids and tokens do not match." } + "401": + description: Authorization information is missing or invalid + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponseError" + example: { "ok": false, "status": 401, "error": "Unauthorized" } + "403": + description: Permission denied + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponseError" + example: + { "ok": false, "status": 403, "error": "Permission denied." } + /exit: + post: + operationId: closeServer + summary: Close Server + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + force: + type: boolean + description: Force close server + default: false + responses: + "200": + description: OK + content: + text/plain: + example: Aborted + "401": + description: Authorization information is missing or invalid + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponseError" + example: { "ok": false, "status": 401, "error": "Unauthorized" } + "403": + description: Permission denied + content: + text/plain: + example: Permission denied + /export/gallery/zip/{gid}: + parameters: + - name: gid + in: path + description: Gallery id + required: true + schema: + type: integer + format: int64 + get: + operationId: exportGalleryZip + summary: Export gallery as Zip file + parameters: + - name: jpn_title + in: query + description: Use japanese title + schema: + type: boolean + default: false + - name: max_length + in: query + description: Maximum length of filenames in Zip files. 0 means disable + schema: + type: integer + default: 0 + - name: export_ad + in: query + description: Export pages which marked as advertisements + schema: + type: boolean + default: false + responses: + "200": + description: OK + content: + application/zip: {} + "400": + description: Bad Request + content: + text/plain: + example: Bad Request + "401": + description: Authorization information is missing or invalid + content: + application/json: + schema: + $ref: "#/components/schemas/ApiResponseError" + example: { "ok": false, "status": 401, "error": "Unauthorized" } + "403": + description: Permission denied + content: + text/plain: + example: Permission denied /files/{token}: parameters: - name: token