Commit 1dcc1eaf authored by nanahira's avatar nanahira

use CNOCG fetcher

parent 06c758c2
Pipeline #942 passed with stages
in 1 minute and 28 seconds
import { DBReader } from "./src/dbreader"; import { DBReader } from "./src/dbreader";
import { NWFetcher } from "./src/nwfetcher"; import { NWFetcher } from "./src/nwfetcher";
import _ from "underscore"; import _ from "underscore";
import { CNOCGFetcher } from "./src/cnocg";
async function main() { async function main() {
const dbreader = new DBReader({ name: "Database", level: "debug" }); const dbreader = new DBReader({ name: "Database", level: "debug" });
await dbreader.init(); await dbreader.init();
const cards = await NWFetcher.fetchOnce(dbreader); const cards = await CNOCGFetcher.fetchOnce();
await dbreader.run(cards); await dbreader.run(cards);
process.exit(); process.exit();
} }
......
import Base from "./base";
import axios from "axios";
import { Card } from "./dbreader";
export class CNOCGFetcher extends Base {
static async fetchOnce() {
const fetcher = new CNOCGFetcher({ name: "Temp NW Fetcher" });
await fetcher.init();
return await fetcher.fetch();
}
async fetch(): Promise<Card[]> {
this.log.debug(`Started fetching from CNOCG source...`);
const allCardStrings: string[] = (await axios.get("https://api.tcgcardgame.com/api/cards/sc", {
responseType: "json"
})).data;
const allCards = allCardStrings.map(m => new Card(parseInt(m)));
return allCards;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment