dsgstng-api
Advanced tools
Comparing version 0.0.2 to 0.0.3-a
71
app.js
const request = require('request'), | ||
origin = 'https://api.dsgstng.com' | ||
origin = 'https://api.dsgstng.com', | ||
util = require('util') | ||
class Api { | ||
/** | ||
* | ||
* @param {string} token | ||
* Api interface to iteract with dsgstng.com | ||
* @param {string} [token] Need for stream api access | ||
*/ | ||
constructor(token) { | ||
this.token = token | ||
this.token = token || '' | ||
this.stream = { | ||
resolution: { | ||
/** | ||
* @description Gets all available stream resolutions [Token needed] | ||
*/ | ||
get: () => { | ||
return new Promise((res, rej) => { | ||
request.get(`${origin}/${this.token}/stream/resolution`, (err, response, body) => { | ||
if (err) return rej(err) | ||
request.get({ | ||
url: `${origin}/stream/resolution`, | ||
qs: { | ||
token: this.token | ||
} | ||
}, (err, response, body) => { | ||
if (err) { | ||
util.log(err) | ||
return rej(err) | ||
} | ||
if (response.statusCode != 200){ | ||
util.log(body) | ||
return rej(body.data.message) | ||
} | ||
return res(JSON.parse(body).data) | ||
@@ -21,5 +37,13 @@ }) | ||
}, | ||
/** | ||
* @param {string} resolution Gets only this resolution [Token needed] | ||
*/ | ||
post: (resolution) => { | ||
return new Promise((res, rej) => { | ||
request.post(`${origin}/${this.token}/resolution`, { | ||
request.post({ | ||
url: `${origin}/stream/resolution` | ||
}, { | ||
qs: { | ||
token: this.token | ||
}, | ||
json: true, | ||
@@ -30,3 +54,10 @@ body: { | ||
}, (err, response, body) => { | ||
if (err) return rej(err) | ||
if (err) { | ||
util.log(err) | ||
return rej(err) | ||
} | ||
if (response.statusCode != 200){ | ||
util.log(body) | ||
return rej(body.data.message) | ||
} | ||
return res(JSON.parse(body).data) | ||
@@ -40,6 +71,24 @@ }) | ||
schedule: { | ||
get: () => { | ||
/**@description Calendar schedule [No token needed] | ||
* @param {object} params Calendar request params | ||
* @param {string} [params.year] Year (default gets from Date.now()) | ||
* @param {string} [params.season] Anime season (example:'summer'or'spring') | ||
*/ | ||
get: (params) => { | ||
return new Promise((res, rej) => { | ||
request.get(`${origin}/${this.token}/calendar/schedule`, (err, response, body) => { | ||
if (err) return rej(err) | ||
request.get({ | ||
uri: `${origin}/calendar/schedule`, | ||
qs: { | ||
year: params.year, | ||
season: params.season | ||
} | ||
}, (err, response, body) => { | ||
if (err) { | ||
util.log(err) | ||
return rej(err) | ||
} | ||
if (response.statusCode != 200){ | ||
util.log(body) | ||
return rej(body.data.message) | ||
} | ||
return res(JSON.parse(body).data) | ||
@@ -46,0 +95,0 @@ }) |
{ | ||
"name": "dsgstng-api", | ||
"version": "0.0.2", | ||
"version": "0.0.3a", | ||
"description": "Interface of interaction with dsgstng.com api", | ||
@@ -5,0 +5,0 @@ "main": "app.js", |
@@ -1,1 +0,16 @@ | ||
Interface of interaction with [dsgstng.com](https://dsgstng.com) api | ||
Interface of interaction with [dsgstng.com](https://dsgstng.com) api | ||
Docs soon | ||
``` | ||
// api usage example | ||
const Api = require('dsgstng-api') | ||
const dsgstngApi = new Api() // OR if you had token, put it there. | ||
dsgstngApi.stream.resolution.get() | ||
.then(resolution => { | ||
// Do something | ||
}) | ||
.catch(err => { | ||
// Display error | ||
}) | ||
``` | ||
For more details contact [him](https://t.me/ejnshtein) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4942
99
16
1