Skip to content

Instantly share code, notes, and snippets.

@durancristhian
Last active June 9, 2020 16:14
Show Gist options
  • Save durancristhian/6f63fbb37831fd417f5d7d429714c2ac to your computer and use it in GitHub Desktop.
Save durancristhian/6f63fbb37831fd417f5d7d429714c2ac to your computer and use it in GitHub Desktop.
Backup a meetup.com event
/*
1. Go to https://www.meetup.com/es-ES/{{YOUR_EVENT_NAME}}/events/past/
Example: https://www.meetup.com/es-ES/burgerjs/events/past/
NOTE: Scroll down until all events are loaded in the page
2. Open your developer tools and run the following code on the Console tab
```js
const eventNodes = document.querySelectorAll('.eventList-list .eventCard--link')
const events = Array.from([...eventNodes])
const ids = events
.map(event => event.href)
.map(event => event.split('events/')[1])
.map(id => id.substr(0, id.length - 1))
copy(ids)
```
NOTE: This script will copy to your clipboard the id of each event in the meetup group
ordered from the newest to the oldest, as they appear on the page
3. Save the array you got from the script somewhere
4. Replace MEETUP_GROUP_NAME and EVENT_ID in this script in order to run it properly
NOTE: I tried to make this script to accept an array of ids but the meetup API gave me a bunch of HTTP 429 because I was doing a lot of requests at the same time. It's better to run one by one. I know it's not the best, but it works.
*/
const MEETUP_GROUP_NAME = 'burgerjs'
const EVENT_ID = '249981139'
require('es6-promise').polyfill()
require('isomorphic-fetch')
const fs = require('fs')
const path = require('path')
const request = require('request')
const download = (url, path, callback) => {
request.head(url, (err, res, body) => {
request(url)
.pipe(fs.createWriteStream(path))
.on('close', callback)
})
}
const get = url => new Promise((resolve, reject) => {
fetch(url)
.then(res => {
if (res.status !== 200) {
return reject(res)
}
return resolve(res.json())
})
.catch(error => {
return reject(error)
})
})
const doWork = async () => {
try {
const basePath = `https://api.meetup.com/${MEETUP_GROUP_NAME}/events/${EVENT_ID}`
const event = await get(`${basePath}`)
const attendance = await get(`${basePath}/attendance`)
const comments = await get(`${basePath}/comments`)
const photos = await get(`${basePath}/photos`)
const eventPath = path.join(__dirname, 'events', event.name)
const attendancePath = path.join(eventPath, 'attendance.json')
const commentsPath = path.join(eventPath, 'comments.json')
const eventInformationPath = path.join(eventPath, 'event.json')
const photosPath = path.join(eventPath, 'photos.json')
const photosFolderPath = path.join(eventPath, 'photos')
fs.mkdirSync(eventPath, { recursive: true })
fs.writeFileSync(attendancePath, JSON.stringify(attendance, null, 2))
fs.writeFileSync(commentsPath, JSON.stringify(comments, null, 2))
fs.writeFileSync(eventInformationPath, JSON.stringify(event, null, 2))
fs.writeFileSync(photosPath, JSON.stringify(photos, null, 2))
if (photos.length) {
fs.mkdirSync(photosFolderPath, { recursive: true })
Object.values(photos)
.map(photo => photo.highres_link || photo.photo_link)
.map((link, index) => ({
extension: link.substr(link.lastIndexOf('.')),
index,
url: link
}))
.forEach(({ extension, index, url }) => {
download(
url,
path.join(photosFolderPath, `${index}${extension}`),
() => { }
)
})
}
}
catch (error) {
throw new Error(error)
}
}
doWork()
{
"name": "backup-meetup-event",
"version": "1.0.0",
"scripts": {
"start": "node backup-meetup-event"
},
"author": "@durancristhian",
"dependencies": {
"es6-promise": "^4.2.8",
"isomorphic-fetch": "^2.2.1",
"request": "^2.88.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment