Last active
September 13, 2020 07:56
-
-
Save ci7lus/ad23531f902ac32a572c935a183fc063 to your computer and use it in GitHub Desktop.
https://seiga.nicovideo.jp/manga/ の新規公式連載情報を取得
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
import { defineComponent } from "ironpipe" | |
import axios from "axios" | |
/** | |
* nicomanga.ts | |
* MIT License (c) 2020 ci7lus | |
*/ | |
module.exports = defineComponent({ | |
name: "nicomanga", | |
version: "0.0.1", | |
props: { | |
timer: { | |
type: "$.interface.timer", | |
default: { | |
cron: "30 2 * * *", // 11:30 JST | |
}, | |
}, | |
}, | |
dedupe: "unique", | |
async run() { | |
try { | |
const r = await axios.get<NewConntents>( | |
`https://manga-api.nicoseiga.jp/api/v1/app/manga/attentions/new/contents?offset=0&limit=100`, | |
{ timeout: 5000 } | |
) | |
if (r.data.meta.status !== 200) throw new Error(JSON.stringify(r.data)) | |
r.data.data.result | |
.filter((comic) => comic.meta.content_type === "official") | |
.reverse() | |
.map((comic) => { | |
const data = { | |
...comic.meta, | |
id: comic.id, | |
square_thumbnail_url: comic.square_thumbnail_url, | |
} | |
this.$emit(data, { | |
id: comic.id, | |
summary: `${data.title} / ${data.display_author_name}`, | |
ts: data.updated_at, | |
}) | |
}) | |
} catch (error) { | |
console.error(error) | |
} | |
}, | |
}) | |
type NewConntents = { | |
meta: { status: number } | |
data: { | |
result: { | |
id: number | |
square_thumbnail_url: string | |
meta: { | |
title: string | |
display_author_name: string | |
authors: { | |
nico_id: number | |
name: string | |
commet: string | |
thumbnail_url: string | |
}[] | |
promotion_text: string | null | |
description: string | |
content_type: "user" | "official" | |
official: { | |
id: number | |
meta: { | |
name: string | |
short_name: string | |
thumbnail_url: string | |
share_url: string | |
description: string | |
} | |
} | null | |
created_at: number | |
updated_at: number | |
} | |
}[] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment