wyzie-lib 1.0.5 → 2.0.1
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 +50 -13
- package/dist/wyzie-lib.cjs.js +1 -0
- package/dist/wyzie-lib.es.js +26 -19
- package/dist/wyzie-lib.iife.js +1 -0
- package/dist/wyzie-lib.umd.js +1 -1
- package/package.json +14 -10
package/README.md
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
<a href="https://www.npmjs.com/package/wyzie-lib">
|
|
3
|
-
<img src="https://i.postimg.cc/L5ppKYC5/cclogo.png" height="120">
|
|
4
|
-
<h1 align="center">Wyzie Lib</h1>
|
|
5
|
-
</a>
|
|
6
|
-
</p>
|
|
1
|
+
# Wyzie Lib
|
|
7
2
|
|
|
8
3
|
Wyzie Lib is a package made for easily implementing [Wyzie Subs](https://subs.wyzie.ru) into your project without all the fuss.
|
|
9
4
|
|
|
5
|
+
<sup>2.0 Out Now!</sup>
|
|
6
|
+
|
|
10
7
|
## Features
|
|
11
8
|
- **Simple**: Just one function for searching subtitles using Wyzie Subs API.
|
|
12
9
|
- **Fast**: This package was written in Vite with TypeScript, so it's fast and reliable.
|
|
@@ -21,23 +18,63 @@ npm install wyzie-lib
|
|
|
21
18
|
```bash
|
|
22
19
|
pnpm install wyzie-lib
|
|
23
20
|
```
|
|
21
|
+
### Yarn
|
|
22
|
+
```bash
|
|
23
|
+
yarn add wyzie-lib
|
|
24
|
+
```
|
|
25
|
+
|
|
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.
|
|
24
35
|
|
|
25
36
|
## Usage
|
|
26
37
|
```ts
|
|
27
38
|
import { type SubtitleData, searchSubtitles } from "wyzie-lib";
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
31
43
|
```
|
|
32
|
-
|
|
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.
|
|
33
48
|
```ts
|
|
34
|
-
|
|
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
|
+
}
|
|
35
65
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
};
|
|
39
75
|
```
|
|
40
76
|
|
|
77
|
+
<hr />
|
|
41
78
|
|
|
42
79
|
<sup>
|
|
43
80
|
Created by <a href="https://github.com/itzcozi" alt="github" title="itzCozi on Github">BadDeveloper</a> with 💙
|
|
@@ -0,0 +1 @@
|
|
|
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
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
async function h(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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,
|
|
5
12
|
episode: c,
|
|
6
|
-
language:
|
|
7
|
-
|
|
13
|
+
language: o,
|
|
14
|
+
type: a
|
|
8
15
|
};
|
|
9
|
-
return Object.
|
|
10
|
-
|
|
11
|
-
}),
|
|
16
|
+
return Object.entries(i).forEach(([u, n]) => {
|
|
17
|
+
n !== void 0 && s.searchParams.append(u, n);
|
|
18
|
+
}), s;
|
|
12
19
|
}
|
|
13
|
-
async function f(
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
throw new Error(`HTTP error! status: ${
|
|
17
|
-
return
|
|
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();
|
|
18
25
|
}
|
|
19
|
-
async function w(
|
|
26
|
+
async function w(t) {
|
|
20
27
|
try {
|
|
21
|
-
const
|
|
22
|
-
return await f(
|
|
23
|
-
} catch (
|
|
24
|
-
throw
|
|
28
|
+
const r = await h(t);
|
|
29
|
+
return await f(r);
|
|
30
|
+
} catch (r) {
|
|
31
|
+
throw new Error(`Error fetching subtitles: ${r}`);
|
|
25
32
|
}
|
|
26
33
|
}
|
|
27
34
|
export {
|
|
@@ -0,0 +1 @@
|
|
|
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
CHANGED
|
@@ -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(
|
|
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,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wyzie-lib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"icon": "https://i.postimg.cc/L5ppKYC5/cclogo.png",
|
|
5
|
+
"license": "MIT",
|
|
4
6
|
"keywords": [
|
|
5
7
|
"wyzie-subs",
|
|
6
8
|
"wyzie subs",
|
|
@@ -13,28 +15,30 @@
|
|
|
13
15
|
"scraper",
|
|
14
16
|
"subtitle scraper"
|
|
15
17
|
],
|
|
16
|
-
"main": "dist/wyzie-lib.
|
|
18
|
+
"main": "dist/wyzie-lib.cjs.js",
|
|
17
19
|
"module": "dist/wyzie-lib.es.js",
|
|
20
|
+
"browser": "dist/wyzie-lib.iife.js",
|
|
18
21
|
"files": [
|
|
19
|
-
"dist"
|
|
20
|
-
"dist/types"
|
|
22
|
+
"dist"
|
|
21
23
|
],
|
|
22
24
|
"exports": {
|
|
23
25
|
".": {
|
|
24
26
|
"import": "./dist/wyzie-lib.es.js",
|
|
25
|
-
"require": "./dist/wyzie-lib.
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
"require": "./dist/wyzie-lib.cjs.js",
|
|
28
|
+
"umd": "./dist/wyzie-lib.umd.js"
|
|
29
|
+
}
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
30
|
-
"@eslint/js": "^9.
|
|
31
|
-
"eslint": "^9.
|
|
32
|
+
"@eslint/js": "^9.11.1",
|
|
33
|
+
"eslint": "^9.11.1",
|
|
32
34
|
"eslint-config-prettier": "^9.1.0",
|
|
35
|
+
"eslint-plugin-import": "^2.30.0",
|
|
33
36
|
"eslint-plugin-prettier": "^5.2.1",
|
|
34
37
|
"globals": "^15.9.0",
|
|
35
38
|
"prettier": "^3.3.3",
|
|
36
39
|
"typescript": "^5.6.2",
|
|
37
|
-
"
|
|
40
|
+
"typescript-eslint": "^8.7.0",
|
|
41
|
+
"vite": "^4.5.5"
|
|
38
42
|
},
|
|
39
43
|
"scripts": {
|
|
40
44
|
"dev": "vite",
|