This repository has been archived by the owner on Nov 11, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
k21.js
79 lines (75 loc) · 3.38 KB
/
k21.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
//events.servicenow.com/widget/servicenow/knowledge2021/library?showKnowledgeConnect=false
var arrOfVideos = [];
var sessions = $$('.catalog-result');
//sessions.length = 3;
sessions.forEach(function (session) {
//try{
//let session = sessions[0];
//$$('.catalog-result-title').forEach((element)=>{
//console.log(session);
//console.log(session.querySelector('.badges').querySelector('.rf-time').innerText);
//console.log(session.querySelector('.badges').querySelector('.rf-time').innerText.split(' ')[4]);
var title = session.querySelector('.session-title').querySelector('.title-text').innerText;
var videoObj = {
title: session.querySelector('.session-title').querySelector('.title-text').innerText,
date: (function () {
if (session.querySelector('.badges').querySelector('.rf-time')) {
return new Date(`2021-05-${session.querySelector('.badges').querySelector('.rf-time').innerText.split(' ')[4]}`).toISOString()
} else {
console.log(session.querySelector('.badges').querySelector('.rf-time'));
return "?"
}
})(),
category: "Video",
site: (function () {
if (session.querySelector('.badges').querySelector('.rf-session-type')) {
return "Knowledge 21 " + session.querySelector('.badges').querySelector('.rf-session-type').innerText;
} else {
return "Knowledge 21"
}
})(),
author: (function () {
var returnArr = [];
if (session.querySelector('.rf-attribute > .speaker-details')) {
var authorsElements = session.querySelector('.rf-attribute > .speaker-details').children;
authorsElements.forEach(function (authorElement) {
returnArr.push(authorElement.querySelector('.speaker-trigger').innerText)
})
return returnArr.toString()
}
})(),
link: (function () {
/**
* CCE *doesnt work
* KEY *doenst work (mostly)
* ACT *doesnt work
* CCG *doesnt work
* CCHACK *doesnt work
* LAB *doenst work
* CCL *works
* SPN *works
* DEM *works
* CCB *works
*/
if (title && (title.includes('[CCE') || title.includes('[KEY') || title.includes('[ACT') || title.includes('[CCG') || title.includes('[CCHACK') || title.includes('[LAB'))) {
session.querySelector('.session-title').querySelector('.collapsed').href
return session.querySelector('.session-title').querySelector('.collapsed').href;
} else {
//remove a/b/c from key string
let keystr = title.split('[')[1].split(']')[0];
const regex = /([A-Z]{3}[0-9]{4})([a-z]?)(\-K21)/gm;
const subst = `$1$3`;
const result = keystr.replace(regex, subst);
return 'https://players.brightcove.net/5703385908001/zKNjJ2k2DM_default/index.html?videoId=ref:' + result
}
})()
}
arrOfVideos.push(videoObj)
//} catch(e){
//console.log(`${session.children[1].innerText} issue`, e)
//}
//console.log(videoObj)
//console.log( session[0]);
});
console.log(arrOfVideos.length)
console.log(JSON.stringify(arrOfVideos));