-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest.js
24 lines (22 loc) · 797 Bytes
/
test.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
// to run, use `node test.js`
const apikey = '<FILL ME>'
const username = '<FILL ME>'
const password = '<FILL ME>'
// Load module
const os = new (require('./opensubtitles.js'))({
apikey: apikey,
//endpoint: "https://stoplight.io/mocks/opensubtitles/opensubtitles-api/2781383" // mock server
})
// Log-in
os.login({username: username,password: password}).then(response => {
// search for 'steal this film 2006'
return os.subtitles({query: 'steal this film 2006'})
}).then(response => {
// get the download link for the first result
return os.download({file_id: response.data[0].attributes.files[0].file_id})
}).then(response => {
console.log('response.body is', response)
}).catch(err => {
console.log('error message:', err.message)
console.log('response is:', err.response)
})