skystream-cli 1.4.7 → 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.
Files changed (2) hide show
  1. package/dist/index.js +16 -13
  2. 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.7');
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, page, cb) {
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
@@ -455,13 +454,17 @@ program.command('test')
455
454
  log: (...args) => console.log(' [JS]:', ...args),
456
455
  error: (...args) => console.error(' [JS ERR]:', ...args)
457
456
  },
458
- http_get: async (url, headers, cb) => {
457
+ http_get: async (url, headers_or_options, cb) => {
459
458
  try {
459
+ let headers = headers_or_options;
460
+ if (typeof headers_or_options === 'object' && headers_or_options !== null && (headers_or_options.headers || headers_or_options.body)) {
461
+ headers = headers_or_options.headers;
462
+ }
460
463
  const finalHeaders = { ...(headers || {}) };
461
464
  if (!Object.keys(finalHeaders).some(k => k.toLowerCase() === 'user-agent')) {
462
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";
463
466
  }
464
- const res = await axios.get(url, { headers: finalHeaders });
467
+ const res = await axios.get(url, { headers: finalHeaders, method: 'GET' });
465
468
  const body = typeof res.data === 'string' ? res.data : JSON.stringify(res.data);
466
469
  const response = { status: res.status, statusCode: res.status, body, headers: res.headers };
467
470
  if (cb)
@@ -469,10 +472,10 @@ program.command('test')
469
472
  return response;
470
473
  }
471
474
  catch (e) {
472
- const res = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
475
+ const response = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
473
476
  if (cb)
474
- cb(res);
475
- return res;
477
+ cb(response);
478
+ return response;
476
479
  }
477
480
  },
478
481
  http_post: async (url, headers, body, cb) => {
@@ -481,7 +484,7 @@ program.command('test')
481
484
  if (!Object.keys(finalHeaders).some(k => k.toLowerCase() === 'user-agent')) {
482
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";
483
486
  }
484
- const res = await axios.post(url, body, { headers: finalHeaders });
487
+ const res = await axios.post(url, body, { headers: finalHeaders, method: 'POST' });
485
488
  const resBody = typeof res.data === 'string' ? res.data : JSON.stringify(res.data);
486
489
  const response = { status: res.status, statusCode: res.status, body: resBody, headers: res.headers };
487
490
  if (cb)
@@ -489,10 +492,10 @@ program.command('test')
489
492
  return response;
490
493
  }
491
494
  catch (e) {
492
- const res = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
495
+ const response = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
493
496
  if (cb)
494
- cb(res);
495
- return res;
497
+ cb(response);
498
+ return response;
496
499
  }
497
500
  },
498
501
  registerSettings: (schema) => {
@@ -668,7 +671,7 @@ program.command('test')
668
671
  if (options.function === 'getHome')
669
672
  await fn(callback);
670
673
  else if (options.function === 'search')
671
- await fn(options.query, 1, callback);
674
+ await fn(options.query, callback);
672
675
  else if (!options.query || options.query.trim() === "") {
673
676
  console.warn('\x1b[33mWarning: Function \'' + options.function + '\' usually requires a query/URL (-q), but none was provided.\x1b[0m');
674
677
  await fn(options.query, callback);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skystream-cli",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
4
4
  "type": "module",
5
5
  "description": "SkyStream Plugin Development Kit & Repository Manager",
6
6
  "main": "dist/index.js",