Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
https://mangacross.jp の更新情報を取得
import { defineComponent } from "ironpipe"
import axios from "axios"
/**
* mangacross.ts
* MIT License (c) 2020 ci7lus
*/
module.exports = defineComponent({
name: "mangacross",
version: "0.0.1",
props: {
titles: {
type: "string",
label: "Target title list",
description: "List of target titles (separate with ,)",
},
timer: {
type: "$.interface.timer",
default: {
cron: "30 1,3 * * *",
},
},
},
methods: {},
dedupe: "unique",
async run() {
const titles = this.titles.split(",")
for (let title of titles) {
try {
const r = await axios.get<{ comic: Comic }>(
`https://mangacross.jp/api/comics/${title}.json`,
{
validateStatus: () => true,
timeout: 5000,
}
)
if (r.status !== 200) {
console.warn(`${title}の取得に失敗しました: ${r.status}`)
continue
}
const comic = r.data.comic
const comic2 = Object.assign({}, comic)
delete comic2.episodes
comic.episodes
.filter((episode) => episode.status === "public")
.reverse()
.map((episode) => {
this.$emit(
{
...episode,
comic: comic2,
},
{
id: `https://mangacross.jp${episode.page_url}`,
summary: [comic.title, episode.volume, episode.title]
.filter((s) => typeof s === "string")
.join(" "),
ts: new Date(episode.publish_start).getTime(),
}
)
})
} catch (error) {
console.error(error)
}
}
},
})
type Comic = {
dir_name: string
title: string
author: string
caption: string
image_sp_url: string
icon_url: string
latest_episode_publish_start: string
episodes: Episode[]
}
type Episode = {
id: number
volume: string
title: string
page_url: string
publish_start: string
list_image_double_url: string
status: "public" | "private"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.