-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerateRichMeetupData.js
99 lines (77 loc) · 3.32 KB
/
generateRichMeetupData.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// @ts-check
// Given that COVID dropped meetups, lets disable this
// until things pick up again in 2021
const { join } = require("path")
const { writeFileSync } = require("fs")
const { meetups } = require("./meetups")
// const xml2js = require("xml2js")
// const icalToolkit = require("ical-utils")
const { format } = require("prettier")
// const moment = require("moment")
// require("moment-timezone")
const chalk = require("chalk")
const tick = chalk.bold.greenBright("✓")
const cross = chalk.bold.redBright("⤫")
const go = async () => {
let meetupDeets = []
console.log("Looking at meetups: ")
for (const meetup of meetups) {
if (meetup !== meetups[0]) process.stdout.write(", ")
const meetupURL = meetup.meetup || meetup.url
// if (meetupURL.includes('meetup.com')) {
// try {
// const meetupID = meetupURL.split('/').pop()
// process.stdout.write(meetupID)
// const icalResponse = await fetch(`https://www.meetup.com/${meetupID}/events/ical/`)
// const icalText = await icalResponse.text()
// const ical = await icalToolkit.parseToJSON(icalText)
// const upcomingEvent = ical.events[0]
// if (!upcomingEvent) {
// process.stdout.write(' -')
// meetupDeets.push({ meetup })
// continue
// }
// const id = upcomingEvent.uid.split('_')[1].split('@')[0]
// const title = upcomingEvent.summary.replace(/\\,/g, ',')
// const location = upcomingEvent.location.replace(/\\,/g, ',')
// const textDescription = upcomingEvent.description.replace(/\\,/g, ',').replace(/\\n/g, '<br />')
// const date = moment(upcomingEvent.start.value).tz(upcomingEvent.start.tzid)
// const url = upcomingEvent.additionalTags.URL
// let richDescription = '<p>' + upcomingEvent.description + '</p>'
// // Best to not assume meetup.com's long term health, and it's rss
// const rssResponse = await fetch(`https://www.meetup.com/${meetupID}/events/rss/`)
// const rssText = await rssResponse.text()
// const rss = await xml2js.parseStringPromise(rssText)
// // const removeDoubleLinks =
// const upcoming = rss.rss.channel[0].item[0]
// if (upcoming.title[0] === title) {
// richDescription = upcoming.description[0]
// }
// const linkifiedRegex = new RegExp(`<a href="[^>]+" class="linkified">`, "g")
// let filteredRichText = richDescription.replace(linkifiedRegex, "").replace(new RegExp("</a></a>"), "</a>")
// const event = {
// id,
// url,
// date,
// location,
// textDescription,
// richDescription: filteredRichText,
// title,
// }
// meetupDeets.push({ meetup, event })
// process.stdout.write(' ' + tick)
// } catch (error) {
// console.log(error)
// meetupDeets.push({ meetup })
// process.stdout.write(' ' + cross)
// }
// } else {
process.stdout.write(meetup.title)
meetupDeets.push({ meetup })
// }
}
if (meetups.length !== meetupDeets.length) throw new Error("\n\nMeetup Deets was not the same length\n\n")
const path = join(__dirname, "..", "generated", "meetups.json")
writeFileSync(path, format(JSON.stringify(meetupDeets), { filepath: path }))
}
go()