wyzie-lib 2.0.0 → 2.0.2

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/README.md CHANGED
@@ -37,8 +37,41 @@ yarn add wyzie-lib
37
37
  ```ts
38
38
  import { type SubtitleData, searchSubtitles } from "wyzie-lib";
39
39
 
40
- const data: SubtitleData[] = await searchSubtitles({ tmdb_id: 286217, language: "en" });
41
- console.log(data[0].id);
40
+ // IMDB is faster then TMDB due to less API calls behind the scenes
41
+ const data: SubtitleData[] = await searchSubtitles({ tmdb_id: 286217 });
42
+ console.log(data[0].id); // Prints the ID of the first subtitle provided in the search
43
+ ```
44
+ ### Types
45
+ - **SubtitleData**: All returned values from the API with their respective types.
46
+ - **SearchSubtitlesParams**: All valid parameters recognized by the API.
47
+ - **QueryParams**: All parameters (optional and required) available for the wyzie-subs API.
48
+ ```ts
49
+ interface SearchSubtitlesParams { // Parameters for the searchSubtitles() function
50
+ tmdb_id?: number; // Parsed automatically by the API to recognize if its TMDB or IMDB
51
+ imdb_id?: number; // Parsed automatically by the API to recognize if its TMDB or IMDB
52
+ season?: number;
53
+ episode?: number; // Season is required if episode is provided
54
+ language?: string; // ISO 3166 code
55
+ type?: string; // Subtitle file format
56
+ }
57
+
58
+ interface QueryParams { // Parameters for the wyzie-subs API
59
+ id: string; // (Required) The TMDB or IMDB ID of the movie or TV show
60
+ season?: number; // The season of the TV show (Required if episode is provided)
61
+ episode?: number; // The episode of the TV show (Required if season is provided)
62
+ language?: string; // ISO 3166 code
63
+ type?: string; // Subtitle file format
64
+ }
65
+
66
+ type SubtitleData = { // Data returned by the API
67
+ id: string; // Unique ID of the subtitle from opensubtitles
68
+ url: string; // Direct download link of the subtitle
69
+ type: string; // Subtitle file format
70
+ isHearingImpaired: boolean; // If the subtitle is hearing impaired
71
+ flagUrl: string; // Flag of the language
72
+ display: string; // Actual name of the language
73
+ language: string; // ISO 3166 code
74
+ };
42
75
  ```
43
76
 
44
77
  <hr />
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function u({tmdb_id:t,imdb_id:r,season:n,episode:o,language:c,type:a}){const e=new URL("https://subs.wyzie.ru/search");return Object.entries({id:t||r,season:n,episode:o,language:c,type:a}).forEach(([i,s])=>{s!==void 0&&e.searchParams.append(i,String(s))}),e}async function h(t){const r=await fetch(t.toString());if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}async function f(t){try{const r=await u(t);return await h(r)}catch(r){throw console.error("Error fetching subtitles:",r),r}}exports.searchSubtitles=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function h({tmdb_id:r,imdb_id:t,season:n,episode:c,language:o,type:a}){const e=new URL("https://subs.wyzie.ru/search"),i={id:String(r||t),season:n,episode:c,language:o,type:a};return Object.entries(i).forEach(([u,s])=>{s!==void 0&&e.searchParams.append(u,s)}),e}async function f(r){const t=await fetch(r.toString());if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}async function l(r){try{const t=await h(r);return await f(t)}catch(t){throw new Error(`Error fetching subtitles: ${t}`)}}exports.searchSubtitles=l;
@@ -1,23 +1,23 @@
1
- async function u({
1
+ async function h({
2
2
  tmdb_id: t,
3
3
  imdb_id: r,
4
- season: n,
5
- episode: o,
6
- language: c,
4
+ season: e,
5
+ episode: c,
6
+ language: o,
7
7
  type: a
8
8
  }) {
9
- const s = new URL("https://subs.wyzie.ru/search");
10
- return Object.entries({
11
- id: t || r,
12
- season: n,
13
- episode: o,
14
- language: c,
9
+ const s = new URL("https://subs.wyzie.ru/search"), i = {
10
+ id: String(t || r),
11
+ season: e,
12
+ episode: c,
13
+ language: o,
15
14
  type: a
16
- }).forEach(([i, e]) => {
17
- e !== void 0 && s.searchParams.append(i, String(e));
15
+ };
16
+ return Object.entries(i).forEach(([u, n]) => {
17
+ n !== void 0 && s.searchParams.append(u, n);
18
18
  }), s;
19
19
  }
20
- async function h(t) {
20
+ async function f(t) {
21
21
  const r = await fetch(t.toString());
22
22
  if (!r.ok)
23
23
  throw new Error(`HTTP error! status: ${r.status}`);
@@ -25,10 +25,10 @@ async function h(t) {
25
25
  }
26
26
  async function w(t) {
27
27
  try {
28
- const r = await u(t);
29
- return await h(r);
28
+ const r = await h(t);
29
+ return await f(r);
30
30
  } catch (r) {
31
- throw console.error("Error fetching subtitles:", r), r;
31
+ throw new Error(`Error fetching subtitles: ${r}`);
32
32
  }
33
33
  }
34
34
  export {
@@ -1 +1 @@
1
- var WyzieLib=function(e){"use strict";async function c({tmdb_id:t,imdb_id:r,season:i,episode:u,language:h,type:f}){const n=new URL("https://subs.wyzie.ru/search");return Object.entries({id:t||r,season:i,episode:u,language:h,type:f}).forEach(([l,s])=>{s!==void 0&&n.searchParams.append(l,String(s))}),n}async function a(t){const r=await fetch(t.toString());if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}async function o(t){try{const r=await c(t);return await a(r)}catch(r){throw console.error("Error fetching subtitles:",r),r}}return e.searchSubtitles=o,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
1
+ var WyzieLib=function(e){"use strict";async function c({tmdb_id:r,imdb_id:t,season:o,episode:u,language:h,type:f}){const n=new URL("https://subs.wyzie.ru/search"),b={id:String(r||t),season:o,episode:u,language:h,type:f};return Object.entries(b).forEach(([l,s])=>{s!==void 0&&n.searchParams.append(l,s)}),n}async function i(r){const t=await fetch(r.toString());if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}async function a(r){try{const t=await c(r);return await i(t)}catch(t){throw new Error(`Error fetching subtitles: ${t}`)}}return e.searchSubtitles=a,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
@@ -1 +1 @@
1
- (function(e,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(e=typeof globalThis<"u"?globalThis:e||self,r(e.WyzieLib={}))})(this,function(e){"use strict";async function r({tmdb_id:n,imdb_id:t,season:u,episode:a,language:f,type:h}){const s=new URL("https://subs.wyzie.ru/search");return Object.entries({id:n||t,season:u,episode:a,language:f,type:h}).forEach(([d,o])=>{o!==void 0&&s.searchParams.append(d,String(o))}),s}async function i(n){const t=await fetch(n.toString());if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}async function c(n){try{const t=await r(n);return await i(t)}catch(t){throw console.error("Error fetching subtitles:",t),t}}e.searchSubtitles=c,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1
+ (function(e,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(e=typeof globalThis<"u"?globalThis:e||self,r(e.WyzieLib={}))})(this,function(e){"use strict";async function r({tmdb_id:n,imdb_id:t,season:u,episode:a,language:f,type:h}){const s=new URL("https://subs.wyzie.ru/search"),d={id:String(n||t),season:u,episode:a,language:f,type:h};return Object.entries(d).forEach(([l,i])=>{i!==void 0&&s.searchParams.append(l,i)}),s}async function o(n){const t=await fetch(n.toString());if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}async function c(n){try{const t=await r(n);return await o(t)}catch(t){throw new Error(`Error fetching subtitles: ${t}`)}}e.searchSubtitles=c,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "wyzie-lib",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "icon": "https://i.postimg.cc/L5ppKYC5/cclogo.png",
5
+ "license": "MIT",
5
6
  "keywords": [
6
7
  "wyzie-subs",
7
8
  "wyzie subs",
@@ -28,16 +29,16 @@
28
29
  }
29
30
  },
30
31
  "devDependencies": {
31
- "@eslint/js": "^9.10.0",
32
- "eslint": "^9.10.0",
32
+ "@eslint/js": "^9.12.0",
33
+ "eslint": "^9.12.0",
33
34
  "eslint-config-prettier": "^9.1.0",
35
+ "eslint-plugin-import": "^2.31.0",
34
36
  "eslint-plugin-prettier": "^5.2.1",
35
- "globals": "^15.9.0",
37
+ "globals": "^15.11.0",
36
38
  "prettier": "^3.3.3",
37
- "typescript": "^5.6.2",
38
- "vite": "^4.5.5",
39
- "eslint-plugin-import": "^2.30.0",
40
- "typescript-eslint": "^8.6.0"
39
+ "typescript": "^5.6.3",
40
+ "typescript-eslint": "^8.8.1",
41
+ "vite": "^4.5.5"
41
42
  },
42
43
  "scripts": {
43
44
  "dev": "vite",