forked from filebot/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.groovy
executable file
·50 lines (35 loc) · 1.28 KB
/
configure.groovy
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
#!/usr/bin/env filebot -script
osdbUser = any{ osdbUser }{ console.printf('Enter OpenSubtitles username: '); console.readLine() }
osdbPwd = any{ osdbPwd }{ console.printf('Enter OpenSubtitles password: '); console.readLine() }
/* --------------------------------------------------------------------- */
// user preferences are per-user and not per-device
log.fine "Store user preferences to [${UserData.root()}]"
// set login details
if (osdbUser && osdbPwd) {
log.config('Set OpenSubtitles login details')
try {
WebServices.setLogin(WebServices.OpenSubtitles, osdbUser, osdbPwd)
printAccountInformation()
} catch(e) {
if (e.message == /401 Unauthorized/) {
log.warning 'Your login details are incorrect. Please go to www.opensubtitles.org (and not www.opensubtitles.com) to check your login details and reset your password if necessary.'
}
die e.message
}
}
// clear login details
if (!osdbUser && !osdbPwd) {
log.config('Reset OpenSubtitles login details')
WebServices.setLogin(WebServices.OpenSubtitles, null, null)
}
/**
* Log in and retrieve account details.
*/
void printAccountInformation() {
console.printf('Checking... ')
def info = WebServices.OpenSubtitles.getServerInfo()
console.printf('OK\n\n')
info.download_limits.each{ n, v ->
log.config("$n: $v")
}
}