wyzie-lib 2.0.3 → 2.0.5
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 +57 -38
- package/package.json +3 -3
- package/dist/wyzie-lib.cjs.js +0 -1
- package/dist/wyzie-lib.es.js +0 -36
- package/dist/wyzie-lib.iife.js +0 -1
- package/dist/wyzie-lib.umd.js +0 -1
package/README.md
CHANGED
|
@@ -1,77 +1,96 @@
|
|
|
1
1
|
# Wyzie Lib
|
|
2
2
|
|
|
3
|
-
Wyzie Lib is a package made for easily implementing [Wyzie Subs](https://subs.wyzie.ru) into your
|
|
3
|
+
Wyzie Lib is a package made for easily implementing [Wyzie Subs](https://subs.wyzie.ru) into your
|
|
4
|
+
project without all the fuss. [Read our source code!](https://github.com/itzcozi/wyzie-lib)
|
|
4
5
|
|
|
5
6
|
<sup>2.0 Out Now!</sup>
|
|
6
7
|
|
|
7
8
|
## Features
|
|
9
|
+
|
|
8
10
|
- **Simple**: Just one function for searching subtitles using Wyzie Subs API.
|
|
9
11
|
- **Fast**: This package was written in Vite with TypeScript, so it's fast and reliable.
|
|
10
12
|
- **Open-Source**: The API and package are open-source.
|
|
11
|
-
|
|
13
|
+
|
|
12
14
|
## Installation
|
|
13
|
-
|
|
15
|
+
|
|
16
|
+
**NPM**
|
|
17
|
+
|
|
14
18
|
```bash
|
|
15
19
|
npm install wyzie-lib
|
|
16
20
|
```
|
|
17
|
-
|
|
21
|
+
|
|
22
|
+
**PNPM**
|
|
23
|
+
|
|
18
24
|
```bash
|
|
19
25
|
pnpm install wyzie-lib
|
|
20
26
|
```
|
|
21
|
-
|
|
27
|
+
|
|
28
|
+
**Yarn**
|
|
29
|
+
|
|
22
30
|
```bash
|
|
23
31
|
yarn add wyzie-lib
|
|
24
32
|
```
|
|
25
33
|
|
|
26
|
-
## Parameters
|
|
27
|
-
- **tmdb_id**: The TMDB ID of the movie or TV show. *(tmdb_id or imdb_id is required)*
|
|
28
|
-
- **imdb_id**: The IMDB ID of the movie or TV show. *(imdb_id or tmdb_id is required)*
|
|
29
|
-
- **type**: The file format of the subtitles returned. *(srt, ass, vtt, txt, sub, mpl, webvtt, dfxp)*
|
|
30
|
-
- **season**: Disired season of subtites *(this requires episode parameter aswell)*
|
|
31
|
-
- **episode**: The episode of the given season.
|
|
32
|
-
- **language**: The ISO 3166 code of the provided subtitles.
|
|
33
|
-
- **display**: The actual name of the language capitalized.
|
|
34
|
-
- **isHearingImpaired**: A boolean indicating if the subtitles are hearing impaired.
|
|
35
|
-
|
|
36
34
|
## Usage
|
|
35
|
+
|
|
37
36
|
```ts
|
|
38
37
|
import { type SubtitleData, searchSubtitles } from "wyzie-lib";
|
|
39
38
|
|
|
40
39
|
// IMDB is faster then TMDB due to less API calls behind the scenes
|
|
41
40
|
const data: SubtitleData[] = await searchSubtitles({ tmdb_id: 286217 });
|
|
42
|
-
console.log(data[0]
|
|
41
|
+
console.log(data[0]); // Prints the object of the first subtitle provided in the search
|
|
43
42
|
```
|
|
43
|
+
|
|
44
|
+
### Parameters
|
|
45
|
+
|
|
46
|
+
| Parameter | Name | Description |
|
|
47
|
+
| ----------------------- | ----------------- | ----------------------------------------------------------------------------------------- |
|
|
48
|
+
| **tmdb_id** - _number_ | TmdbId | The TMDB ID of the movie or TV show. _(tmdb_id or imdb_id is required)_ |
|
|
49
|
+
| **imdb_id** - _number_ | ImdbId | The IMDB ID of the movie or TV show. _(imdb_id or tmdb_id is required)_ |
|
|
50
|
+
| **format** - _string_ | format | The file format of the subtitles returned. _(srt, ass, vtt, txt, sub, mpl, webvtt, dfxp)_ |
|
|
51
|
+
| **season** - _number_ | season | Disired season of subtites _(this requires episode parameter aswell)_ |
|
|
52
|
+
| **episode** - _number_ | episode | The episode of the given season. |
|
|
53
|
+
| **language** - _string_ | language | The ISO 3166 code of the provided subtitles. |
|
|
54
|
+
| **hi** - _boolean_ | isHearingImpaired | A boolean indicating if the subtitles are hearing impaired. |
|
|
55
|
+
|
|
44
56
|
### Types
|
|
45
|
-
|
|
57
|
+
|
|
46
58
|
- **SearchSubtitlesParams**: All valid parameters recognized by the API.
|
|
47
|
-
- **QueryParams**: All parameters (optional and required) available for the wyzie-subs API.
|
|
59
|
+
- **QueryParams**: All parameters (optional and required) available for the wyzie-subs API.
|
|
60
|
+
- **SubtitleData**: All returned values from the API with their respective types.
|
|
61
|
+
|
|
48
62
|
```ts
|
|
49
|
-
interface SearchSubtitlesParams {
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
interface SearchSubtitlesParams {
|
|
64
|
+
// Parameters for the searchSubtitles() function
|
|
65
|
+
tmdb_id?: number; // Parsed automatically by the API to recognize if its TMDB or IMDB
|
|
66
|
+
imdb_id?: number; // Parsed automatically by the API to recognize if its TMDB or IMDB
|
|
52
67
|
season?: number;
|
|
53
|
-
episode?: number;
|
|
54
|
-
language?: string;
|
|
55
|
-
|
|
68
|
+
episode?: number; // Season is required if episode is provided
|
|
69
|
+
language?: string; // ISO 3166 code
|
|
70
|
+
format?: string; // Subtitle file format
|
|
71
|
+
hi?: boolean; // If the subtitle is hearing impaired
|
|
56
72
|
}
|
|
57
73
|
|
|
58
|
-
interface QueryParams {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
interface QueryParams {
|
|
75
|
+
// Parameters for the wyzie-subs API
|
|
76
|
+
id: string; // (Required) The TMDB or IMDB ID of the movie or TV show
|
|
77
|
+
season?: number; // The season of the TV show (Required if episode is provided)
|
|
78
|
+
episode?: number; // The episode of the TV show (Required if season is provided)
|
|
79
|
+
language?: string; // ISO 3166 code
|
|
80
|
+
format?: string; // Subtitle file format
|
|
81
|
+
hi?: boolean; // If the subtitle is hearing impaired
|
|
64
82
|
}
|
|
65
83
|
|
|
66
|
-
type SubtitleData = {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
type SubtitleData = {
|
|
85
|
+
// Data returned by the API
|
|
86
|
+
id: string; // Unique ID of the subtitle from opensubtitles
|
|
87
|
+
url: string; // Direct download link of the subtitle
|
|
88
|
+
format: string; // Subtitle file format
|
|
70
89
|
isHearingImpaired: boolean; // If the subtitle is hearing impaired
|
|
71
|
-
flagUrl: string;
|
|
72
|
-
media: string;
|
|
73
|
-
display: string;
|
|
74
|
-
language: string;
|
|
90
|
+
flagUrl: string; // Flag of the language
|
|
91
|
+
media: string; // Media name of the subtitle
|
|
92
|
+
display: string; // Actual name of the language
|
|
93
|
+
language: string; // ISO 3166 code
|
|
75
94
|
};
|
|
76
95
|
```
|
|
77
96
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wyzie-lib",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"icon": "https://i.postimg.cc/L5ppKYC5/cclogo.png",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"globals": "^15.12.0",
|
|
38
38
|
"prettier": "^3.3.3",
|
|
39
39
|
"typescript": "^5.6.3",
|
|
40
|
-
"typescript-eslint": "^8.
|
|
40
|
+
"typescript-eslint": "^8.13.0",
|
|
41
41
|
"vite": "^4.5.5"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"build": "vite build && tsc",
|
|
46
46
|
"lint": "eslint src",
|
|
47
47
|
"lint:fix": "eslint --fix src",
|
|
48
|
-
"format": "prettier --log-level warn --write \"src/**/*.{
|
|
48
|
+
"format": "prettier --log-level warn --write \"{src/**/*.{ts,js,html,css},*.{ts,js,html,css,json,md,xml}}\"",
|
|
49
49
|
"preview": "vite preview"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/dist/wyzie-lib.cjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;
|
package/dist/wyzie-lib.es.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
async function h({
|
|
2
|
-
tmdb_id: t,
|
|
3
|
-
imdb_id: r,
|
|
4
|
-
season: e,
|
|
5
|
-
episode: c,
|
|
6
|
-
language: o,
|
|
7
|
-
type: a
|
|
8
|
-
}) {
|
|
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,
|
|
14
|
-
type: a
|
|
15
|
-
};
|
|
16
|
-
return Object.entries(i).forEach(([u, n]) => {
|
|
17
|
-
n !== void 0 && s.searchParams.append(u, n);
|
|
18
|
-
}), s;
|
|
19
|
-
}
|
|
20
|
-
async function f(t) {
|
|
21
|
-
const r = await fetch(t.toString());
|
|
22
|
-
if (!r.ok)
|
|
23
|
-
throw new Error(`HTTP error! status: ${r.status}`);
|
|
24
|
-
return r.json();
|
|
25
|
-
}
|
|
26
|
-
async function w(t) {
|
|
27
|
-
try {
|
|
28
|
-
const r = await h(t);
|
|
29
|
-
return await f(r);
|
|
30
|
-
} catch (r) {
|
|
31
|
-
throw new Error(`Error fetching subtitles: ${r}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
w as searchSubtitles
|
|
36
|
-
};
|
package/dist/wyzie-lib.iife.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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}({});
|
package/dist/wyzie-lib.umd.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"})});
|