forked from filebot/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.groovy
58 lines (43 loc) · 1.61 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
51
52
53
54
55
56
57
58
#!/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() }
/* --------------------------------------------------------------------- */
if (Settings.getApplicationRevisionNumber() < 9072) {
// set login details (FileBot 4.9.4 r9071 or lower)
if (osdbUser && osdbPwd) {
log.config('Set OpenSubtitles login details')
UserData.forPackage(WebServices.class).put(WebServices.LOGIN_OPENSUBTITLES, String.join(WebServices.LOGIN_SEPARATOR, osdbUser, osdbPwd))
WebServices.OpenSubtitles.login(osdbUser, osdbPwd)
printAccountInformation()
}
// clear login details (FileBot 4.9.4 r9071 or lower)
if (!osdbUser && !osdbPwd) {
log.config('Reset OpenSubtitles login details')
UserData.forPackage(WebServices.class).remove(WebServices.LOGIN_OPENSUBTITLES)
}
return
}
// set login details (FileBot 4.9.5 r9072 or higher)
if (osdbUser && osdbPwd) {
log.config('Set OpenSubtitles login details')
WebServices.setLogin(WebServices.OpenSubtitles, osdbUser, osdbPwd)
printAccountInformation()
}
// clear login details (FileBot 4.9.5 r9072 or higher)
if (!osdbUser && !osdbPwd) {
log.config('Reset OpenSubtitles login details')
WebServices.setLogin(WebServices.OpenSubtitles, null, null)
}
/**
* Log in and retrieve account details.
*/
void printAccountInformation() {
tryLogCatch{
console.printf('Checking... ')
def info = WebServices.OpenSubtitles.getServerInfo()
console.printf('OK\n\n')
info.download_limits.each{ n, v ->
log.config("$n: $v")
}
}
}