-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
73 lines (56 loc) · 1.77 KB
/
index.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
const { update_playlist } = require('./cytube_auto.js')
const { logErr, log, setErrDelay, blacklist_check } = require('./utils.js')
require('dotenv').config()
function get(variable) {
if (variable === undefined || variable.toLowerCase() === "false")
return false
if (variable.toLowerCase() === "true")
return true
throw new Error(`\"${variable}\" used for boolean variable. Expected \"true\" or \"false\"`)
}
function int(v) {
if (v === undefined)
return 1000
const ret = parseInt(v)
if (isNaN(ret))
throw new Error(`\"${v}\" given instead of an integer. Expected a number`)
return parseInt(v)
}
async function main() {
if (!process.env.CHANNEL) {
logErr('No Channel specificed in .env', false)
return
}
const channel_url = `https://cytu.be/r/${process.env.CHANNEL}`
log()
const
q_delay = int(process.env.QUEUE_DELAY),
error_delay = int(process.env.ERROR_DELAY)
const
show = get(process.env.SHOW),
blacklist_check = get(process.env.CHECK_BLACKLISTED),
use_auth_cookie = get(process.env.USE_AUTH_COOKIE),
report_contradictions = get(process.env.REPORT_CONTRADICTORY_VIDEOS)
let add_if_missing_setting
switch (process.env.ADD_IF_MISSING.toLowerCase()) {
case "true":
add_if_missing_setting = 2
break
case "ask":
add_if_missing_setting = 1
break
default:
add_if_missing_setting = 0
}
setErrDelay(error_delay)
update_playlist(
use_cookie = use_auth_cookie,
headless = !show,
queue_delay = q_delay,
url = channel_url,
check_blacklisted = blacklist_check,
add_if_missing = add_if_missing_setting,
report_contradictory = report_contradictions
)
}
main()