Browse Source

initial commit

Ahoj Dziku
mrkvon 2 years ago
commit
69aee4f632
6 changed files with 5088 additions and 0 deletions
  1. 1
    0
      .gitignore
  2. 35
    0
      README.md
  3. 4923
    0
      events.json
  4. 36
    0
      index.mjs
  5. 14
    0
      package.json
  6. 79
    0
      yarn.lock

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
1
+node_modules

+ 35
- 0
README.md View File

@@ -0,0 +1,35 @@
1
+# list of events of sustainable communities
2
+
3
+A small gift for Dzik
4
+
5
+```
6
+    /
7
+<* |
8
+/\ /\
9
+```
10
+
11
+## About
12
+
13
+Download events of sustainable communities in JSON format.
14
+
15
+## Usage
16
+
17
+### Install packages
18
+
19
+```bash
20
+yarn
21
+# or
22
+npm install
23
+```
24
+
25
+### Run
26
+
27
+```bash
28
+yarn start
29
+# or
30
+npm start
31
+```
32
+
33
+## Prerequisities
34
+
35
+Node which supports `--experimental-modules`, that is node v8+

+ 4923
- 0
events.json
File diff suppressed because it is too large
View File


+ 36
- 0
index.mjs View File

@@ -0,0 +1,36 @@
1
+import axios from 'axios';
2
+import ical2json from 'ical2json';
3
+import fs from 'fs-extra';
4
+
5
+(async function () {
6
+  let events = [];
7
+  // get current events
8
+  events = events.concat(await getEvents());
9
+  // get past events
10
+  events = events.concat(await getEvents(true));
11
+
12
+  console.log(events.length);
13
+
14
+  await fs.writeJson('events.json', events, { spaces: 2 });
15
+}());
16
+
17
+async function getEventPage(i, past=false) {
18
+  const url = `https://www.sustainable-communities.net/events/list/?tribe_paged=${i}&tribe_event_display=${past ? 'past' : 'list'}&ical=1${past && '&tribe_display=past' || ''}`
19
+  const { data } = await axios.get(url);
20
+  return (ical2json.convert(data).VCALENDAR[0].VEVENT || []);
21
+}
22
+
23
+async function getEvents(past=false) {
24
+  let events = await getEventPage(1, past);
25
+
26
+  let newEvents = events;
27
+
28
+  let i = 2;
29
+  while (newEvents.length > 0) {
30
+    newEvents = await getEventPage(i, past);
31
+    events = events.concat(newEvents);
32
+    ++i;
33
+  }
34
+
35
+  return events;
36
+}

+ 14
- 0
package.json View File

@@ -0,0 +1,14 @@
1
+{
2
+  "name": "sustainable-communities",
3
+  "version": "1.0.0",
4
+  "main": "index.js",
5
+  "scripts": {
6
+    "start": "node --experimental-modules index.mjs"
7
+  },
8
+  "license": "MIT",
9
+  "dependencies": {
10
+    "axios": "^0.19.0",
11
+    "fs-extra": "^8.1.0",
12
+    "ical2json": "^2.0.0"
13
+  }
14
+}

+ 79
- 0
yarn.lock View File

@@ -0,0 +1,79 @@
1
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+# yarn lockfile v1
3
+
4
+
5
+axios@^0.19.0:
6
+  version "0.19.0"
7
+  resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.0.tgz#8e09bff3d9122e133f7b8101c8fbdd00ed3d2ab8"
8
+  integrity sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==
9
+  dependencies:
10
+    follow-redirects "1.5.10"
11
+    is-buffer "^2.0.2"
12
+
13
+commander@^2.11.0:
14
+  version "2.20.0"
15
+  resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422"
16
+  integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==
17
+
18
+debug@=3.1.0:
19
+  version "3.1.0"
20
+  resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
21
+  integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
22
+  dependencies:
23
+    ms "2.0.0"
24
+
25
+follow-redirects@1.5.10:
26
+  version "1.5.10"
27
+  resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
28
+  integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
29
+  dependencies:
30
+    debug "=3.1.0"
31
+
32
+fs-extra@^8.1.0:
33
+  version "8.1.0"
34
+  resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
35
+  integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
36
+  dependencies:
37
+    graceful-fs "^4.2.0"
38
+    jsonfile "^4.0.0"
39
+    universalify "^0.1.0"
40
+
41
+graceful-fs@^4.1.6, graceful-fs@^4.2.0:
42
+  version "4.2.2"
43
+  resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.2.tgz#6f0952605d0140c1cfdb138ed005775b92d67b02"
44
+  integrity sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==
45
+
46
+ical2json@^2.0.0:
47
+  version "2.0.0"
48
+  resolved "https://registry.yarnpkg.com/ical2json/-/ical2json-2.0.0.tgz#17b33fa109f879f00366cba38215f73e19eff6fb"
49
+  integrity sha512-nTjB+NDQ0dKSTw4SjNnRwn9PdLmnDnmZsYyDjBMzcwm+dwgL5c3GeSpFg+oId11XISF0iXWIt2kxGB4F9GoKmg==
50
+  dependencies:
51
+    commander "^2.11.0"
52
+    q "^1.5.1"
53
+
54
+is-buffer@^2.0.2:
55
+  version "2.0.3"
56
+  resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.3.tgz#4ecf3fcf749cbd1e472689e109ac66261a25e725"
57
+  integrity sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==
58
+
59
+jsonfile@^4.0.0:
60
+  version "4.0.0"
61
+  resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
62
+  integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
63
+  optionalDependencies:
64
+    graceful-fs "^4.1.6"
65
+
66
+ms@2.0.0:
67
+  version "2.0.0"
68
+  resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
69
+  integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
70
+
71
+q@^1.5.1:
72
+  version "1.5.1"
73
+  resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
74
+  integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=
75
+
76
+universalify@^0.1.0:
77
+  version "0.1.2"
78
+  resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
79
+  integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==