1.3.11 • Published 8 months ago
trace-moe-api v1.3.11
trace-moe-api
API wrapper for the trace.moe API written in TypeScript.
Installing
Using yarn:
$ yarn add trace-moe-api
Using npm:
$ npm i trace-moe-api
TraceMoeAPIWrapper
searchForAnimeSceneWithMediaURL(mediaURL: string | URL, options?: SearchOptions): Promise<SearchResponse>;
searchForAnimeSceneWithMediaAtPath(mediaPath: string, options?: SearchOptions): Promise<SearchResponse>;
fetchAPILimits(): Promise<APILimitsResponse>;
downloadVideoFromResult(result: SearchResult, options?: MediaDownloadOptions): Promise<string>;
downloadImageFromResult(result: SearchResult, options?: MediaDownloadOptions): Promise<string>;
Search options
interface SearchOptions {
shouldCutBlackBorders?: boolean;
anilistID?: number | string;
shouldIncludeExtraAnilistInfo?: boolean;
}
Media download options
interface MediaDownloadOptions {
size?: MediaSize;
shouldMute?: boolean;
directory?: string;
name?: string;
}
Example
import { createTraceMoeAPIWrapper, MediaSize, SearchError } from "trace-moe-api";
const traceMoeAPIWrapper = createTraceMoeAPIWrapper();
// const traceMoeAPIWrapper = createTraceMoeAPIWrapper({ apiKey });
try {
const apiLimits = await traceMoeAPI.fetchAPILimits();
if (apiLimits.remainingQuota > 0) {
const mediaURL = "https://images.plurk.com/32B15UXxymfSMwKGTObY5e.jpg";
const response = await traceMoeAPIWrapper.searchForAnimeSceneWithMediaURL(mediaURL);
// const response = await traceMoeAPIWrapper.searchForAnimeSceneWithMediaAtPath(mediaPath);
if (response.results.length > 0) {
const result = response.results[0];
console.log(result.anilistInfo.id);
const downloadPath = await traceMoeAPIWrapper.downloadVideoFromResult(result, MediaSize.large);
// const downloadPath = await traceMoeAPIWrapper.downloadImageFromResult(result, MediaSize.large);
// Do something with `downloadPath`...
}
}
} catch (error) {
if (error instanceof SearchError) {
// Do something with `error`...
}
}
Sample responses
SearchResponse
object
{
checkedFramesCount: 5890247,
results: [] // Array of `SearchResult` objects
}
SearchResult
object without shouldIncludeExtraAnilistInfo
{
anilistInfo: { id: 21034 },
filename: "[Leopard-Raws] Gochuumon wa Usagi Desu ka 2nd - 01 RAW (KBS 1280x720 x264 AAC).mp4",
episode: 1,
fromTimestamp: 288.58,
toTimestamp: 292.67,
similarityPercentage: 99,
videoURL: "Video preview URL",
imageURL: "Image preview URL"
}
AnilistInfo
object with shouldIncludeExtraAnilistInfo
{
id: 21034,
malID: 29787,
synonyms: ["Gochiusa"],
title: {
nativeTitle: "ご注文はうさぎですか??",
romajiTitle: "Gochuumon wa Usagi desu ka??",
englishTitle: "Is the Order a Rabbit?? Season 2"
},
isNSFWAnime: false
}
APILimitsResponse
object
{
id: "Either your API key or your IP address",
priority: 0,
concurrency: 1,
totalQuota: 1000,
remainingQuota: 900
}
Links
1.3.7
9 months ago
1.3.6
9 months ago
1.3.5
9 months ago
1.3.4
9 months ago
1.3.3
10 months ago
1.3.2
11 months ago
1.3.1
11 months ago
1.3.10
8 months ago
1.3.11
8 months ago
1.3.9
9 months ago
1.3.8
9 months ago
1.3.0
12 months ago
1.2.1
12 months ago
1.2.0
12 months ago
1.1.7
12 months ago
1.1.6
12 months ago
1.1.5
12 months ago
1.1.4
12 months ago
1.1.3
12 months ago
1.1.2
12 months ago
1.1.1
12 months ago
1.1.0
12 months ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago