wyzie-lib 2.0.9 → 2.1.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/dist/wyzie-lib.cjs.js +8 -10
- package/dist/wyzie-lib.es.js +44 -52
- package/dist/wyzie-lib.iife.js +8 -10
- package/dist/wyzie-lib.umd.js +8 -10
- package/package.json +4 -2
- package/dist/types/funcs.d.ts +0 -7
- package/dist/types/main.d.ts +0 -4
- package/dist/types/types.d.ts +0 -28
package/dist/wyzie-lib.cjs.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function
|
|
2
|
-
`).
|
|
3
|
-
`).trim();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`).map(e=>e.trim()).filter(e=>e.length>0);if(s.length<2)continue;const i=s.findIndex(e=>/^\d{1,2}:\d{2}(?::\d{2})?[,\.]\d{3}(?:\.|,)?\s*-->\s*\d{1,2}:\d{2}(?::\d{2})?[,\.]\d{3}(?:\.|,)?$/.test(e));if(i===-1)continue;const a=s.slice(i+1).filter(e=>!/^\d+$/.test(e)).filter(e=>e.length>0);if(a.length===0)continue;let l=s[i];l=l.replace(/[,.](?=\s*-->)/,"").replace(/[,.]$/,""),l=l.replace(/,(\d{3})/g,".$1"),u+=`${l}
|
|
7
|
-
${a.join(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function p({tmdb_id:e,imdb_id:t,season:u,episode:d,language:c,format:a,hi:f}){const o=new URL("https://sub.wyzie.ru/search"),i={id:String(e||t),season:u,episode:d,language:c,format:a,hi:f};return Object.entries(i).forEach(([r,n])=>{n!==void 0&&o.searchParams.append(r,n)}),o}async function m(e){const t=await fetch(e.toString());if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}async function T(e){try{const t=await p(e);return await m(t)}catch(t){throw new Error(`Error fetching subtitles: ${t}`)}}async function w(e){try{const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch subtitle content: ${t.status}`);const c=(await t.text()).replace(/\r\n|\r/g,`
|
|
2
|
+
`).trim().split(/\n\n+/),a=/^\d{1,2}:\d{2}:\d{2}[,.]\d{3}\s*-->\s*\d{1,2}:\d{2}:\d{2}[,.]\d{3}$/;if(!c.some(i=>i.split(`
|
|
3
|
+
`).map(n=>n.trim()).some(n=>a.test(n))))throw new Error("Invalid subtitle format: not SRT");const o=["WEBVTT",""];for(const i of c){const r=i.split(`
|
|
4
|
+
`).map(s=>s.trim()).filter(s=>s.length>0);if(r.length<2)continue;const n=r.findIndex(s=>a.test(s));if(n===-1)continue;const h=r.slice(n+1).filter(s=>!/^\d+$/.test(s));if(h.length===0)continue;let l=r[n];l=l.replace(/[,.](?=\s*-->)/,"").replace(/[,.]$/,"").replace(/,(\d{3})/g,".$1"),o.push(`${l}
|
|
5
|
+
${h.join(`
|
|
8
6
|
`)}
|
|
9
|
-
|
|
10
|
-
`
|
|
7
|
+
`)}return o.join(`
|
|
8
|
+
`).replace(/\n{3,}/g,`
|
|
11
9
|
|
|
12
10
|
`).trim()+`
|
|
13
11
|
|
|
14
|
-
`}catch(t){throw console.error("Error in parseToVTT:",t),t}}
|
|
12
|
+
`}catch(t){throw console.error("Error in parseToVTT:",t),t}}exports.parseToVTT=w;exports.searchSubtitles=T;
|
package/dist/wyzie-lib.es.js
CHANGED
|
@@ -1,65 +1,68 @@
|
|
|
1
|
-
async function
|
|
1
|
+
async function p({
|
|
2
2
|
tmdb_id: e,
|
|
3
3
|
imdb_id: t,
|
|
4
|
-
season:
|
|
5
|
-
episode:
|
|
6
|
-
language:
|
|
7
|
-
format:
|
|
4
|
+
season: u,
|
|
5
|
+
episode: f,
|
|
6
|
+
language: c,
|
|
7
|
+
format: a,
|
|
8
8
|
hi: h
|
|
9
9
|
}) {
|
|
10
|
-
const
|
|
10
|
+
const o = new URL("https://sub.wyzie.ru/search"), i = {
|
|
11
11
|
id: String(e || t),
|
|
12
|
-
season:
|
|
13
|
-
episode:
|
|
14
|
-
language:
|
|
15
|
-
format:
|
|
12
|
+
season: u,
|
|
13
|
+
episode: f,
|
|
14
|
+
language: c,
|
|
15
|
+
format: a,
|
|
16
16
|
hi: h
|
|
17
17
|
};
|
|
18
|
-
return Object.entries(
|
|
19
|
-
|
|
20
|
-
}),
|
|
18
|
+
return Object.entries(i).forEach(([r, n]) => {
|
|
19
|
+
n !== void 0 && o.searchParams.append(r, n);
|
|
20
|
+
}), o;
|
|
21
21
|
}
|
|
22
|
-
async function
|
|
22
|
+
async function m(e) {
|
|
23
23
|
const t = await fetch(e.toString());
|
|
24
24
|
if (!t.ok)
|
|
25
25
|
throw new Error(`HTTP error! status: ${t.status}`);
|
|
26
26
|
return t.json();
|
|
27
27
|
}
|
|
28
28
|
async function w(e) {
|
|
29
|
+
try {
|
|
30
|
+
const t = await p(e);
|
|
31
|
+
return await m(t);
|
|
32
|
+
} catch (t) {
|
|
33
|
+
throw new Error(`Error fetching subtitles: ${t}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function T(e) {
|
|
29
37
|
try {
|
|
30
38
|
const t = await fetch(e);
|
|
31
39
|
if (!t.ok)
|
|
32
40
|
throw new Error(`Failed to fetch subtitle content: ${t.status}`);
|
|
33
|
-
const
|
|
34
|
-
`).
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const o = c.split(`
|
|
44
|
-
`).map((n) => n.trim()).filter((n) => n.length > 0);
|
|
45
|
-
if (o.length < 2)
|
|
41
|
+
const c = (await t.text()).replace(/\r\n|\r/g, `
|
|
42
|
+
`).trim().split(/\n\n+/), a = /^\d{1,2}:\d{2}:\d{2}[,.]\d{3}\s*-->\s*\d{1,2}:\d{2}:\d{2}[,.]\d{3}$/;
|
|
43
|
+
if (!c.some((i) => i.split(`
|
|
44
|
+
`).map((n) => n.trim()).some((n) => a.test(n))))
|
|
45
|
+
throw new Error("Invalid subtitle format: not SRT");
|
|
46
|
+
const o = ["WEBVTT", ""];
|
|
47
|
+
for (const i of c) {
|
|
48
|
+
const r = i.split(`
|
|
49
|
+
`).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
50
|
+
if (r.length < 2)
|
|
46
51
|
continue;
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
);
|
|
50
|
-
if (i === -1)
|
|
52
|
+
const n = r.findIndex((s) => a.test(s));
|
|
53
|
+
if (n === -1)
|
|
51
54
|
continue;
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
55
|
+
const d = r.slice(n + 1).filter((s) => !/^\d+$/.test(s));
|
|
56
|
+
if (d.length === 0)
|
|
54
57
|
continue;
|
|
55
|
-
let l =
|
|
56
|
-
l = l.replace(/[,.](?=\s*-->)/, "").replace(/[,.]$/, "")
|
|
57
|
-
${
|
|
58
|
+
let l = r[n];
|
|
59
|
+
l = l.replace(/[,.](?=\s*-->)/, "").replace(/[,.]$/, "").replace(/,(\d{3})/g, ".$1"), o.push(`${l}
|
|
60
|
+
${d.join(`
|
|
58
61
|
`)}
|
|
59
|
-
|
|
60
|
-
`;
|
|
62
|
+
`);
|
|
61
63
|
}
|
|
62
|
-
return
|
|
64
|
+
return o.join(`
|
|
65
|
+
`).replace(/\n{3,}/g, `
|
|
63
66
|
|
|
64
67
|
`).trim() + `
|
|
65
68
|
|
|
@@ -68,18 +71,7 @@ ${a.join(`
|
|
|
68
71
|
throw console.error("Error in parseToVTT:", t), t;
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
|
-
async function g(e) {
|
|
72
|
-
try {
|
|
73
|
-
const t = await d(e), r = await p(t);
|
|
74
|
-
if (e.parseVTT && r.length > 0) {
|
|
75
|
-
const s = await w(r[0].url);
|
|
76
|
-
return { subtitles: r, vttContent: s };
|
|
77
|
-
}
|
|
78
|
-
return r;
|
|
79
|
-
} catch (t) {
|
|
80
|
-
throw new Error(`Error fetching subtitles: ${t}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
74
|
export {
|
|
84
|
-
|
|
75
|
+
T as parseToVTT,
|
|
76
|
+
w as searchSubtitles
|
|
85
77
|
};
|
package/dist/wyzie-lib.iife.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
var WyzieLib=function(
|
|
2
|
-
`).
|
|
3
|
-
`).trim();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`).map(n=>n.trim()).filter(n=>n.length>0);if(o.length<2)continue;const i=o.findIndex(n=>/^\d{1,2}:\d{2}(?::\d{2})?[,\.]\d{3}(?:\.|,)?\s*-->\s*\d{1,2}:\d{2}(?::\d{2})?[,\.]\d{3}(?:\.|,)?$/.test(n));if(i===-1)continue;const a=o.slice(i+1).filter(n=>!/^\d+$/.test(n)).filter(n=>n.length>0);if(a.length===0)continue;let l=o[i];l=l.replace(/[,.](?=\s*-->)/,"").replace(/[,.]$/,""),l=l.replace(/,(\d{3})/g,".$1"),u+=`${l}
|
|
7
|
-
${a.join(`
|
|
1
|
+
var WyzieLib=function(c){"use strict";async function p({tmdb_id:e,imdb_id:t,season:f,episode:d,language:a,format:l,hi:h}){const o=new URL("https://sub.wyzie.ru/search"),i={id:String(e||t),season:f,episode:d,language:a,format:l,hi:h};return Object.entries(i).forEach(([r,n])=>{n!==void 0&&o.searchParams.append(r,n)}),o}async function T(e){const t=await fetch(e.toString());if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}async function w(e){try{const t=await p(e);return await T(t)}catch(t){throw new Error(`Error fetching subtitles: ${t}`)}}async function b(e){try{const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch subtitle content: ${t.status}`);const a=(await t.text()).replace(/\r\n|\r/g,`
|
|
2
|
+
`).trim().split(/\n\n+/),l=/^\d{1,2}:\d{2}:\d{2}[,.]\d{3}\s*-->\s*\d{1,2}:\d{2}:\d{2}[,.]\d{3}$/;if(!a.some(i=>i.split(`
|
|
3
|
+
`).map(n=>n.trim()).some(n=>l.test(n))))throw new Error("Invalid subtitle format: not SRT");const o=["WEBVTT",""];for(const i of a){const r=i.split(`
|
|
4
|
+
`).map(s=>s.trim()).filter(s=>s.length>0);if(r.length<2)continue;const n=r.findIndex(s=>l.test(s));if(n===-1)continue;const m=r.slice(n+1).filter(s=>!/^\d+$/.test(s));if(m.length===0)continue;let u=r[n];u=u.replace(/[,.](?=\s*-->)/,"").replace(/[,.]$/,"").replace(/,(\d{3})/g,".$1"),o.push(`${u}
|
|
5
|
+
${m.join(`
|
|
8
6
|
`)}
|
|
9
|
-
|
|
10
|
-
`
|
|
7
|
+
`)}return o.join(`
|
|
8
|
+
`).replace(/\n{3,}/g,`
|
|
11
9
|
|
|
12
10
|
`).trim()+`
|
|
13
11
|
|
|
14
|
-
`}catch(t){throw console.error("Error in parseToVTT:",t),t}}
|
|
12
|
+
`}catch(t){throw console.error("Error in parseToVTT:",t),t}}return c.parseToVTT=b,c.searchSubtitles=w,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),c}({});
|
package/dist/wyzie-lib.umd.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`).
|
|
3
|
-
`).trim();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`).map(e=>e.trim()).filter(e=>e.length>0);if(s.length<2)continue;const l=s.findIndex(e=>/^\d{1,2}:\d{2}(?::\d{2})?[,\.]\d{3}(?:\.|,)?\s*-->\s*\d{1,2}:\d{2}(?::\d{2})?[,\.]\d{3}(?:\.|,)?$/.test(e));if(l===-1)continue;const u=s.slice(l+1).filter(e=>!/^\d+$/.test(e)).filter(e=>e.length>0);if(u.length===0)continue;let f=s[l];f=f.replace(/[,.](?=\s*-->)/,"").replace(/[,.]$/,""),f=f.replace(/,(\d{3})/g,".$1"),d+=`${f}
|
|
7
|
-
${u.join(`
|
|
1
|
+
(function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.WyzieLib={}))})(this,function(n){"use strict";async function i({tmdb_id:r,imdb_id:t,season:d,episode:p,language:l,format:u,hi:h}){const c=new URL("https://sub.wyzie.ru/search"),a={id:String(r||t),season:d,episode:p,language:l,format:u,hi:h};return Object.entries(a).forEach(([o,e])=>{e!==void 0&&c.searchParams.append(o,e)}),c}async function T(r){const t=await fetch(r.toString());if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}async function w(r){try{const t=await i(r);return await T(t)}catch(t){throw new Error(`Error fetching subtitles: ${t}`)}}async function b(r){try{const t=await fetch(r);if(!t.ok)throw new Error(`Failed to fetch subtitle content: ${t.status}`);const l=(await t.text()).replace(/\r\n|\r/g,`
|
|
2
|
+
`).trim().split(/\n\n+/),u=/^\d{1,2}:\d{2}:\d{2}[,.]\d{3}\s*-->\s*\d{1,2}:\d{2}:\d{2}[,.]\d{3}$/;if(!l.some(a=>a.split(`
|
|
3
|
+
`).map(e=>e.trim()).some(e=>u.test(e))))throw new Error("Invalid subtitle format: not SRT");const c=["WEBVTT",""];for(const a of l){const o=a.split(`
|
|
4
|
+
`).map(s=>s.trim()).filter(s=>s.length>0);if(o.length<2)continue;const e=o.findIndex(s=>u.test(s));if(e===-1)continue;const m=o.slice(e+1).filter(s=>!/^\d+$/.test(s));if(m.length===0)continue;let f=o[e];f=f.replace(/[,.](?=\s*-->)/,"").replace(/[,.]$/,"").replace(/,(\d{3})/g,".$1"),c.push(`${f}
|
|
5
|
+
${m.join(`
|
|
8
6
|
`)}
|
|
9
|
-
|
|
10
|
-
`
|
|
7
|
+
`)}return c.join(`
|
|
8
|
+
`).replace(/\n{3,}/g,`
|
|
11
9
|
|
|
12
10
|
`).trim()+`
|
|
13
11
|
|
|
14
|
-
`}catch(t){throw console.error("Error in parseToVTT:",t),t}}
|
|
12
|
+
`}catch(t){throw console.error("Error in parseToVTT:",t),t}}n.parseToVTT=b,n.searchSubtitles=w,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wyzie-lib",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"icon": "https://i.postimg.cc/L5ppKYC5/cclogo.png",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"main": "dist/wyzie-lib.cjs.js",
|
|
19
19
|
"module": "dist/wyzie-lib.es.js",
|
|
20
20
|
"browser": "dist/wyzie-lib.iife.js",
|
|
21
|
+
"type": "module",
|
|
21
22
|
"files": [
|
|
22
23
|
"dist"
|
|
23
24
|
],
|
|
@@ -38,7 +39,8 @@
|
|
|
38
39
|
"prettier": "^3.4.2",
|
|
39
40
|
"typescript": "^5.7.2",
|
|
40
41
|
"typescript-eslint": "^8.19.0",
|
|
41
|
-
"vite": "^4.5.5"
|
|
42
|
+
"vite": "^4.5.5",
|
|
43
|
+
"vitest": "^2.1.8"
|
|
42
44
|
},
|
|
43
45
|
"scripts": {
|
|
44
46
|
"dev": "vite",
|
package/dist/types/funcs.d.ts
DELETED
package/dist/types/main.d.ts
DELETED
package/dist/types/types.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export interface SearchSubtitlesParams {
|
|
2
|
-
tmdb_id?: number;
|
|
3
|
-
imdb_id?: number;
|
|
4
|
-
season?: number;
|
|
5
|
-
episode?: number;
|
|
6
|
-
language?: string;
|
|
7
|
-
format?: string;
|
|
8
|
-
hi?: boolean;
|
|
9
|
-
parseVTT?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export type SubtitleData = {
|
|
12
|
-
id: string;
|
|
13
|
-
url: string;
|
|
14
|
-
format: string;
|
|
15
|
-
isHearingImpaired: boolean;
|
|
16
|
-
flagUrl: string;
|
|
17
|
-
media: string;
|
|
18
|
-
display: string;
|
|
19
|
-
language: string;
|
|
20
|
-
};
|
|
21
|
-
export interface QueryParams {
|
|
22
|
-
id: string;
|
|
23
|
-
season?: number;
|
|
24
|
-
episode?: number;
|
|
25
|
-
language?: string;
|
|
26
|
-
format?: string;
|
|
27
|
-
hi?: boolean;
|
|
28
|
-
}
|