Skip to content

Commit 0568af9

Browse files
committed
Add makefile target - generate-youtube-playlists-json
1 parent b506d59 commit 0568af9

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/data/conferences.json
22
/data/youtube-channels.json
3+
/data/youtube-playlists.json
34
/sitemap.txt

Diff for: Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ generate-youtube-channels-json: build-image
6060
$(IMAGE_NAME) \
6161
node ./tools/generate-youtube-channels-json.js
6262

63+
# Generate /data/youtube-playlists.json
64+
.PHONY: generate-youtube-playlists-json
65+
generate-youtube-playlists-json: build-image
66+
> data/youtube-playlists.json
67+
docker run -t --rm \
68+
--workdir $(TARGET_DIR) \
69+
--mount type=bind,source=$(CURDIR),target=$(TARGET_DIR) \
70+
$(IMAGE_NAME) \
71+
node ./tools/generate-youtube-playlists-json.js
72+
6373
# Build Docker image for tests and tooling
6474
.PHONY: build-image
6575
build-image:

Diff for: Makefile-netlify

+5
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ generate-conferences-json:
2929
.PHONY: generate-youtube-channels-json
3030
generate-youtube-channels-json:
3131
node ./tools/generate-youtube-channels-json.js
32+
33+
# Generate /data/youtube-playlists.json
34+
.PHONY: generate-youtube-playlists-json
35+
generate-youtube-playlists-json:
36+
node ./tools/generate-youtube-playlists-json.js

Diff for: tools/generate-youtube-playlists-json.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const glob = require('glob');
5+
6+
const utils = require('../js/utils/utils-node');
7+
8+
const YOUTUBE_PLAYLISTS_JSON_FILE = './data/youtube-playlists.json';
9+
const CONFERENCES_GLOB_PATTERN = './data/conferences/*/*.yaml';
10+
11+
let conferenceFiles = glob.sync(CONFERENCES_GLOB_PATTERN);
12+
13+
// Build playlist IDs object
14+
let playlistIds = new Set();
15+
16+
conferenceFiles.forEach(conferenceFile => {
17+
let playlistUrl = utils.getJSON(conferenceFile).conference.links.playlist;
18+
let playlistMatch = playlistUrl && playlistUrl.match(utils.REGEX_URL_YOUTUBE_PLAYLIST);
19+
if (playlistMatch) {
20+
playlistIds.add(playlistMatch[1]);
21+
}
22+
});
23+
24+
// TODO: save
25+
fs.writeFileSync(YOUTUBE_PLAYLISTS_JSON_FILE, JSON.stringify([...playlistIds], null, 2));
26+
27+
console.log(`YouTube playlists JSON file generated at: ${YOUTUBE_PLAYLISTS_JSON_FILE}`);

0 commit comments

Comments
 (0)