import { Mwn } from 'npm:mwn' import process from "node:process"; import { parseSummary } from "./parse.ts"; async function getWorkshopVideos(bot: Mwn): Promise { const response = await bot.request({ action: 'query', list: 'allimages', aiprefix: 'WCS ', // Search prefix ailimit: 'max', // Maximum number of results }); if (response.query === undefined) { throw new Error("Did not receive response to file query") } // Extract and print the file titles return response.query.allimages.map(function (image: { title: string }) { return image.title }); } export interface VideoDescription { teachers: string[] location: string event: string level: string date: string patterns: string notes: string } async function main() { const bot = new Mwn({ apiUrl: 'https://dancing.thasky.one/api.php', username: process.env.BOTNAME, password: process.env.BOTPW, userAgent: 'mwn bot', }); try { await bot.login(); const relevantFiles = await getWorkshopVideos(bot) const file_content = await bot.read(relevantFiles[0]) if (file_content.revisions === undefined) { throw new Error("Page has no revisions") } const content = file_content.revisions[0].content if (content === undefined) { throw new Error("Latest revision has no content") } console.log(content) parseSummary(content, relevantFiles[0]) } catch (error) { console.error('Error:', error); } finally { await bot.logout(); } } main();