-
Notifications
You must be signed in to change notification settings - Fork 20
/
soundcloud.js
99 lines (86 loc) · 2.61 KB
/
soundcloud.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
'use strict';
const episodes = require('./src/content/episodes.json');
const panelInfo = require('./content/panelists.json');
const createUrl = require('./lib/create-url');
const args = process.argv.slice(2);
const identifier = args[0];
function createDetails(num) {
let epNum;
let epTitle;
let fullTitle;
let desc = '';
epNum = episodes[num].episode;
epTitle = episodes[num].title;
fullTitle = `Episode ${epNum} - ${epTitle}`;
// desctription details
const epDesc = episodes[num].description;
desc += `${epDesc}\n`;
// create URL for episode transcript
const link = createUrl(epTitle);
// links of items mentioned in the episode
const links = episodes[num].links;
//if there are links get the items
if(links.length !== 0) {
//add heading for items
desc += `\nItems mentioned in the episode:\n`;
for(let link in links) {
desc += links[link].title;
// add comma
if(parseInt(link) + 1 !== links.length) {
desc += ', ';
}else{
desc += '\n';
}
}
}
const guests = episodes[num].guests;
//if there are guests get the names and twitter
if(guests.length !== 0) {
//add heading for guests
desc += `\nGuests:\n`;
for(let guest in guests) {
desc += guests[guest].name;
// check to see if they have a twitter
if(guests[guest].twitter !== '') {
desc += ' - @' + guests[guest].twitter + `\n`;
}else{
desc += `\n`;
}
}
}
// get panelist details
const panelists = episodes[num].panel;
desc += `\nPanelists:\n`;
for(let panelist in panelists) {
desc += panelists[panelist];
// find panelist twitter
for(let p in panelInfo) {
if(panelInfo[p].name === panelists[panelist]) {
desc += ` - @${panelInfo[p].twitter}\n`;
}
}
}
// get pick details
const picks = episodes[num].picks;
if(picks.length !== 0) {
//add heading for guests
desc += `\nPicks:\n`;
for(let pick in picks) {
desc += picks[pick].from + ' - ' + picks[pick].title + ' ' + picks[pick].url + `\n`;
}
}
// display final details
console.log(`\n${fullTitle}\n\n${desc}\nEpisode transcript: https://www.frontendhappyhour.com/episodes/${link}\n`);
}
// if an argument has been passed for a specific episode find the episode info
if(identifier !== undefined) {
for(let ep in episodes) {
// check if the identifer is equal to an episode number or episode title
if(identifier === episodes[ep].episode || identifier === episodes[ep].title) {
createDetails(ep);
}
}
// if there wasn't an argument passed find the last episode details
}else{
createDetails(0);
}