skystream-cli 1.4.8 → 1.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +14 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const program = new Command();
|
|
|
12
12
|
program
|
|
13
13
|
.name('skystream')
|
|
14
14
|
.description('SkyStream Plugin Development Kit CLI (Sky Gen 2)')
|
|
15
|
-
.version('1.4.
|
|
15
|
+
.version('1.4.9');
|
|
16
16
|
// Schemas
|
|
17
17
|
const pluginSchema = z.object({
|
|
18
18
|
packageName: z.string().min(5).regex(/^[a-z0-9._-]+$/),
|
|
@@ -95,10 +95,9 @@ const JS_TEMPLATE = `(function() {
|
|
|
95
95
|
/**
|
|
96
96
|
* Searches for media items.
|
|
97
97
|
* @param {string} query
|
|
98
|
-
* @param {number} page
|
|
99
98
|
* @param {(res: Response) => void} cb
|
|
100
99
|
*/
|
|
101
|
-
async function search(query,
|
|
100
|
+
async function search(query, cb) {
|
|
102
101
|
try {
|
|
103
102
|
// Standard: Return a List of items
|
|
104
103
|
// Samples show both a movie and a series
|
|
@@ -465,44 +464,38 @@ program.command('test')
|
|
|
465
464
|
if (!Object.keys(finalHeaders).some(k => k.toLowerCase() === 'user-agent')) {
|
|
466
465
|
finalHeaders['User-Agent'] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36";
|
|
467
466
|
}
|
|
468
|
-
const res = await axios.get(url, { headers: finalHeaders });
|
|
467
|
+
const res = await axios.get(url, { headers: finalHeaders, method: 'GET' });
|
|
469
468
|
const body = typeof res.data === 'string' ? res.data : JSON.stringify(res.data);
|
|
470
469
|
const response = { status: res.status, statusCode: res.status, body, headers: res.headers };
|
|
471
470
|
if (cb)
|
|
472
471
|
cb(response);
|
|
473
|
-
return response
|
|
472
|
+
return response;
|
|
474
473
|
}
|
|
475
474
|
catch (e) {
|
|
476
|
-
const
|
|
475
|
+
const response = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
|
|
477
476
|
if (cb)
|
|
478
|
-
cb(
|
|
479
|
-
return
|
|
477
|
+
cb(response);
|
|
478
|
+
return response;
|
|
480
479
|
}
|
|
481
480
|
},
|
|
482
|
-
http_post: async (url,
|
|
481
|
+
http_post: async (url, headers, body, cb) => {
|
|
483
482
|
try {
|
|
484
|
-
let headers = headers_or_options;
|
|
485
|
-
let body = body_arg;
|
|
486
|
-
if (typeof headers_or_options === 'object' && headers_or_options !== null && !body_arg && (headers_or_options.body || headers_or_options.headers)) {
|
|
487
|
-
body = headers_or_options.body;
|
|
488
|
-
headers = headers_or_options.headers;
|
|
489
|
-
}
|
|
490
483
|
const finalHeaders = { ...(headers || {}) };
|
|
491
484
|
if (!Object.keys(finalHeaders).some(k => k.toLowerCase() === 'user-agent')) {
|
|
492
485
|
finalHeaders['User-Agent'] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36";
|
|
493
486
|
}
|
|
494
|
-
const res = await axios.post(url, body, { headers: finalHeaders });
|
|
487
|
+
const res = await axios.post(url, body, { headers: finalHeaders, method: 'POST' });
|
|
495
488
|
const resBody = typeof res.data === 'string' ? res.data : JSON.stringify(res.data);
|
|
496
489
|
const response = { status: res.status, statusCode: res.status, body: resBody, headers: res.headers };
|
|
497
490
|
if (cb)
|
|
498
491
|
cb(response);
|
|
499
|
-
return response
|
|
492
|
+
return response;
|
|
500
493
|
}
|
|
501
494
|
catch (e) {
|
|
502
|
-
const
|
|
495
|
+
const response = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
|
|
503
496
|
if (cb)
|
|
504
|
-
cb(
|
|
505
|
-
return
|
|
497
|
+
cb(response);
|
|
498
|
+
return response;
|
|
506
499
|
}
|
|
507
500
|
},
|
|
508
501
|
registerSettings: (schema) => {
|
|
@@ -678,7 +671,7 @@ program.command('test')
|
|
|
678
671
|
if (options.function === 'getHome')
|
|
679
672
|
await fn(callback);
|
|
680
673
|
else if (options.function === 'search')
|
|
681
|
-
await fn(options.query,
|
|
674
|
+
await fn(options.query, callback);
|
|
682
675
|
else if (!options.query || options.query.trim() === "") {
|
|
683
676
|
console.warn('\x1b[33mWarning: Function \'' + options.function + '\' usually requires a query/URL (-q), but none was provided.\x1b[0m');
|
|
684
677
|
await fn(options.query, callback);
|