Commit 4d1643aa authored by nanahira's avatar nanahira

shortens

parent c83061bd
Pipeline #938 passed with stages
in 1 minute and 27 seconds
......@@ -2,17 +2,10 @@ import { DBReader } from "./src/dbreader";
import { NWFetcher } from "./src/nwfetcher";
import _ from "underscore";
async function fetchCardsFromNW(dbreader: DBReader) {
const fetcher = new NWFetcher({ name: "NW Fetcher", level: "debug" });
await fetcher.init();
const strings = await fetcher.fetch();
return await dbreader.getAllCardsFromJapaneseNames(strings);
}
async function main() {
const dbreader = new DBReader({ name: "Database", level: "debug" });
await dbreader.init();
const cards = await fetchCardsFromNW(dbreader);
const cards = await NWFetcher.fetchOnce(dbreader);
await dbreader.run(cards);
process.exit();
}
......
......@@ -3,6 +3,7 @@
import axios from "axios";
import _ from "underscore";
import Base from "./base";
import { DBReader } from "./dbreader";
function convertCharToFullSize(char: string) {
......@@ -14,6 +15,12 @@ function convertCharToFullSize(char: string) {
}
export class NWFetcher extends Base {
static async fetchOnce(dbreader: DBReader) {
const fetcher = new NWFetcher({ name: "Temp NW Fetcher" });
await fetcher.init();
const strings = await fetcher.fetch();
return await dbreader.getAllCardsFromJapaneseNames(strings);
}
private async fetchPage(url: string): Promise<string> {
this.log.debug(`Downloading content from ${url} .`);
const { data } = await axios.get(url, {
......
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