-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hker9527
committed
Nov 11, 2023
1 parent
a983551
commit cbaf169
Showing
6 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { BaseMultipleCheck, CheckFunctions } from '../../../../../checks' | ||
import { PixivUgoiraItem, PixivUgoiraItemCheck } from '../../../../pixiv-ugoira' | ||
|
||
/** | ||
* GET /v1/illust/ugoira/detail のリクエスト | ||
*/ | ||
export interface GetV1IllustUgoiraMetadataRequest { | ||
/** | ||
* イラストID | ||
*/ | ||
illust_id: number | ||
} | ||
|
||
/** | ||
* GET /v1/illust/ugoira/detail のレスポンス | ||
*/ | ||
export interface GetV1IllustUgoiraMetadataResponse { | ||
/** | ||
* うごイラの詳細情報 | ||
*/ | ||
ugoira_metadata: PixivUgoiraItem | ||
} | ||
|
||
export class GetV1IllustUgoiraMetadataCheck extends BaseMultipleCheck< | ||
GetV1IllustUgoiraMetadataRequest, | ||
GetV1IllustUgoiraMetadataResponse | ||
> { | ||
requestChecks(): CheckFunctions<GetV1IllustUgoiraMetadataRequest> { | ||
return { | ||
illust_id: (data) => typeof data.illust_id === 'number', | ||
} | ||
} | ||
|
||
responseChecks(): CheckFunctions<GetV1IllustUgoiraMetadataResponse> { | ||
return { | ||
ugoira_metadata: (data) => | ||
typeof data.ugoira_metadata === 'object' && | ||
new PixivUgoiraItemCheck().throwIfFailed(data.ugoira_metadata), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { BaseSimpleCheck, CheckFunctions } from "src/checks" | ||
|
||
/** | ||
* 圧縮されたフレームのURL | ||
* | ||
* ここのURLも {@link ImageUrls} と同様に、適切なリファラを付与する必要がある | ||
*/ | ||
export interface ZipUrls { | ||
/** | ||
* 長辺が最大 600px | ||
* | ||
* "600x600" を "1920x1080" に変換したらオリジナル画像が得られる? | ||
*/ | ||
medium: string | ||
} | ||
|
||
/** | ||
* フレーム情報 | ||
*/ | ||
export interface Frames { | ||
/** | ||
* フレームのファイル名 | ||
*/ | ||
file: string | ||
/** | ||
* フレームの表示時間(ms) | ||
*/ | ||
delay: number | ||
} | ||
|
||
/** | ||
* pixiv うごイラアイテム | ||
*/ | ||
export interface PixivUgoiraItem { | ||
/** | ||
* 圧縮されたフレームのURL | ||
*/ | ||
zip_urls: ZipUrls | ||
/** | ||
* フレーム情報 | ||
*/ | ||
frames: Frames[] | ||
} | ||
|
||
export class ZipUrlsCheck extends BaseSimpleCheck<ZipUrls> { | ||
checks(): CheckFunctions<ZipUrls> { | ||
return { | ||
medium: (data) => typeof data.medium === 'string', | ||
} | ||
} | ||
} | ||
|
||
export class FramesCheck extends BaseSimpleCheck<Frames> { | ||
checks(): CheckFunctions<Frames> { | ||
return { | ||
file: (data) => typeof data.file === 'string', | ||
delay: (data) => typeof data.delay === 'number', | ||
} | ||
} | ||
} | ||
|
||
export class PixivUgoiraItemCheck extends BaseSimpleCheck<PixivUgoiraItem> { | ||
checks(): CheckFunctions<PixivUgoiraItem> { | ||
return { | ||
zip_urls: (data) => | ||
typeof data.zip_urls === 'object' && | ||
new ZipUrlsCheck().throwIfFailed(data.zip_urls), | ||
frames: (data) => | ||
typeof data.frames === 'object' && | ||
Array.isArray(data.frames) && | ||
data.frames.every((frame) => new FramesCheck().throwIfFailed(frame)), | ||
} | ||
} | ||
} |