This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathback.js
56 lines (46 loc) · 1.63 KB
/
back.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
async function ata(){
let lol = await pdi.Inv.find({})
lol.forEach(canal => {
let json = `https://youtube.googleapis.com/youtube/v3/channels?part=snippet&id=${channelid(canal.link)}&key=${process.env["ytkey"]}`
axios.get(json).then(res => {
let pfp = res.data.items[0].snippet.thumbnails.medium.url || "https://i.kym-cdn.com/entries/icons/original/000/034/421/cover1.jpg";
if (!canal.pfp) {
pdi.inv.findOneAndUpdate({
nome: canal.nome
}, {
pfp: pfp
})
} else if (canal.pfp !== pfp) {
pdi.inv.findOneAndUpdate({
nome: canal.nome
}, {
pfp: pfp
})
}
})
})
lol.forEach(canal => {
canal.series.forEach(r2d2 => {
r2d2.temps.forEach(tempse => {
axios.get(`https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=${playlistId(tempse.link)}&key=${process.env["ytkey"]}`).then(res => {
pdi.inv.series.forEach(b => {
b.temps.forEach(tempo => {
tempo.findOneAndUpdate({link: tempo.link}, { eps: res.data.items })
})
})
/*
inventario.update(
a => a.series.forEach(b => {
b.temps.forEach(tempo => {
if (tempo.link === tempse.link) {
tempo.eps = res.data.items
}
})
})
) */
})
})
})
})
}
ata()