wyzie-lib 2.2.3 → 2.2.4
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/package.json +2 -2
- package/lib/main.amd.js +0 -90
- package/lib/main.cjs +0 -88
- package/lib/main.iife.js +0 -91
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wyzie-lib",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"icon": "https://i.postimg.cc/L5ppKYC5/cclogo.png",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"prettier": "^3.5.3",
|
|
64
64
|
"typescript": "^5.8.3",
|
|
65
65
|
"vite": "^4.5.14",
|
|
66
|
-
"vite-plugin-dts": "^4.5.
|
|
66
|
+
"vite-plugin-dts": "^4.5.4",
|
|
67
67
|
"vitest": "^2.1.9"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
package/lib/main.amd.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
define(["exports"], function(exports) {
|
|
2
|
-
"use strict";
|
|
3
|
-
async function constructUrl({
|
|
4
|
-
tmdb_id,
|
|
5
|
-
imdb_id,
|
|
6
|
-
season,
|
|
7
|
-
episode,
|
|
8
|
-
encoding,
|
|
9
|
-
language,
|
|
10
|
-
format,
|
|
11
|
-
source,
|
|
12
|
-
hi
|
|
13
|
-
}) {
|
|
14
|
-
const url = new URL("https://sub.wyzie.ru/search");
|
|
15
|
-
const queryParams = {
|
|
16
|
-
id: String(tmdb_id || imdb_id),
|
|
17
|
-
season,
|
|
18
|
-
episode,
|
|
19
|
-
encoding: Array.isArray(encoding) ? encoding.join(",") : encoding,
|
|
20
|
-
language: Array.isArray(language) ? language.join(",") : language,
|
|
21
|
-
format: Array.isArray(format) ? format.join(",") : format,
|
|
22
|
-
source: Array.isArray(source) ? source.join(",") : source,
|
|
23
|
-
hi
|
|
24
|
-
};
|
|
25
|
-
Object.entries(queryParams).forEach(([key, value]) => {
|
|
26
|
-
if (value !== void 0) {
|
|
27
|
-
url.searchParams.append(key, String(value));
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return url;
|
|
31
|
-
}
|
|
32
|
-
async function fetchSubtitles(url) {
|
|
33
|
-
const response = await fetch(url.toString());
|
|
34
|
-
if (!response.ok) {
|
|
35
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
36
|
-
}
|
|
37
|
-
return response.json();
|
|
38
|
-
}
|
|
39
|
-
async function searchSubtitles(params) {
|
|
40
|
-
try {
|
|
41
|
-
const url = await constructUrl(params);
|
|
42
|
-
return await fetchSubtitles(url);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
throw new Error(`Error fetching subtitles: ${error}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async function parseToVTT(subtitleUrl) {
|
|
48
|
-
try {
|
|
49
|
-
const response = await fetch(subtitleUrl);
|
|
50
|
-
if (!response.ok) {
|
|
51
|
-
throw new Error(`Failed to fetch subtitle content: ${response.status}`);
|
|
52
|
-
}
|
|
53
|
-
const content = await response.text();
|
|
54
|
-
const normalizedContent = content.replace(/\r\n|\r/g, "\n").trim();
|
|
55
|
-
const blocks = normalizedContent.split(/\n\n+/);
|
|
56
|
-
const timestampRegex = /^\d{1,2}:\d{2}:\d{2}[,.]\d{3}\s*-->\s*\d{1,2}:\d{2}:\d{2}[,.]\d{3}$/;
|
|
57
|
-
const hasValidSRTFormat = blocks.some((block) => {
|
|
58
|
-
const lines = block.split("\n").map((line) => line.trim());
|
|
59
|
-
return lines.some((line) => timestampRegex.test(line));
|
|
60
|
-
});
|
|
61
|
-
if (!hasValidSRTFormat) {
|
|
62
|
-
throw new Error("Invalid subtitle format: not SRT");
|
|
63
|
-
}
|
|
64
|
-
const vttLines = ["WEBVTT", ""];
|
|
65
|
-
for (const block of blocks) {
|
|
66
|
-
const lines = block.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
67
|
-
if (lines.length < 2)
|
|
68
|
-
continue;
|
|
69
|
-
const timestampIndex = lines.findIndex((line) => timestampRegex.test(line));
|
|
70
|
-
if (timestampIndex === -1)
|
|
71
|
-
continue;
|
|
72
|
-
const textLines = lines.slice(timestampIndex + 1).filter((line) => !/^\d+$/.test(line));
|
|
73
|
-
if (textLines.length === 0)
|
|
74
|
-
continue;
|
|
75
|
-
let timestampLine = lines[timestampIndex];
|
|
76
|
-
timestampLine = timestampLine.replace(/[,.](?=\s*-->)/, "").replace(/[,.]$/, "").replace(/,(\d{3})/g, ".$1");
|
|
77
|
-
vttLines.push(`${timestampLine}
|
|
78
|
-
${textLines.join("\n")}
|
|
79
|
-
`);
|
|
80
|
-
}
|
|
81
|
-
return vttLines.join("\n").replace(/\n{3,}/g, "\n\n").trim() + "\n\n";
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error("Error in parseToVTT:", error);
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.parseToVTT = parseToVTT;
|
|
88
|
-
exports.searchSubtitles = searchSubtitles;
|
|
89
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
90
|
-
});
|
package/lib/main.cjs
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
async function constructUrl({
|
|
4
|
-
tmdb_id,
|
|
5
|
-
imdb_id,
|
|
6
|
-
season,
|
|
7
|
-
episode,
|
|
8
|
-
encoding,
|
|
9
|
-
language,
|
|
10
|
-
format,
|
|
11
|
-
source,
|
|
12
|
-
hi
|
|
13
|
-
}) {
|
|
14
|
-
const url = new URL("https://sub.wyzie.ru/search");
|
|
15
|
-
const queryParams = {
|
|
16
|
-
id: String(tmdb_id || imdb_id),
|
|
17
|
-
season,
|
|
18
|
-
episode,
|
|
19
|
-
encoding: Array.isArray(encoding) ? encoding.join(",") : encoding,
|
|
20
|
-
language: Array.isArray(language) ? language.join(",") : language,
|
|
21
|
-
format: Array.isArray(format) ? format.join(",") : format,
|
|
22
|
-
source: Array.isArray(source) ? source.join(",") : source,
|
|
23
|
-
hi
|
|
24
|
-
};
|
|
25
|
-
Object.entries(queryParams).forEach(([key, value]) => {
|
|
26
|
-
if (value !== void 0) {
|
|
27
|
-
url.searchParams.append(key, String(value));
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return url;
|
|
31
|
-
}
|
|
32
|
-
async function fetchSubtitles(url) {
|
|
33
|
-
const response = await fetch(url.toString());
|
|
34
|
-
if (!response.ok) {
|
|
35
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
36
|
-
}
|
|
37
|
-
return response.json();
|
|
38
|
-
}
|
|
39
|
-
async function searchSubtitles(params) {
|
|
40
|
-
try {
|
|
41
|
-
const url = await constructUrl(params);
|
|
42
|
-
return await fetchSubtitles(url);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
throw new Error(`Error fetching subtitles: ${error}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async function parseToVTT(subtitleUrl) {
|
|
48
|
-
try {
|
|
49
|
-
const response = await fetch(subtitleUrl);
|
|
50
|
-
if (!response.ok) {
|
|
51
|
-
throw new Error(`Failed to fetch subtitle content: ${response.status}`);
|
|
52
|
-
}
|
|
53
|
-
const content = await response.text();
|
|
54
|
-
const normalizedContent = content.replace(/\r\n|\r/g, "\n").trim();
|
|
55
|
-
const blocks = normalizedContent.split(/\n\n+/);
|
|
56
|
-
const timestampRegex = /^\d{1,2}:\d{2}:\d{2}[,.]\d{3}\s*-->\s*\d{1,2}:\d{2}:\d{2}[,.]\d{3}$/;
|
|
57
|
-
const hasValidSRTFormat = blocks.some((block) => {
|
|
58
|
-
const lines = block.split("\n").map((line) => line.trim());
|
|
59
|
-
return lines.some((line) => timestampRegex.test(line));
|
|
60
|
-
});
|
|
61
|
-
if (!hasValidSRTFormat) {
|
|
62
|
-
throw new Error("Invalid subtitle format: not SRT");
|
|
63
|
-
}
|
|
64
|
-
const vttLines = ["WEBVTT", ""];
|
|
65
|
-
for (const block of blocks) {
|
|
66
|
-
const lines = block.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
67
|
-
if (lines.length < 2)
|
|
68
|
-
continue;
|
|
69
|
-
const timestampIndex = lines.findIndex((line) => timestampRegex.test(line));
|
|
70
|
-
if (timestampIndex === -1)
|
|
71
|
-
continue;
|
|
72
|
-
const textLines = lines.slice(timestampIndex + 1).filter((line) => !/^\d+$/.test(line));
|
|
73
|
-
if (textLines.length === 0)
|
|
74
|
-
continue;
|
|
75
|
-
let timestampLine = lines[timestampIndex];
|
|
76
|
-
timestampLine = timestampLine.replace(/[,.](?=\s*-->)/, "").replace(/[,.]$/, "").replace(/,(\d{3})/g, ".$1");
|
|
77
|
-
vttLines.push(`${timestampLine}
|
|
78
|
-
${textLines.join("\n")}
|
|
79
|
-
`);
|
|
80
|
-
}
|
|
81
|
-
return vttLines.join("\n").replace(/\n{3,}/g, "\n\n").trim() + "\n\n";
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error("Error in parseToVTT:", error);
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.parseToVTT = parseToVTT;
|
|
88
|
-
exports.searchSubtitles = searchSubtitles;
|
package/lib/main.iife.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
var main = function(exports) {
|
|
2
|
-
"use strict";
|
|
3
|
-
async function constructUrl({
|
|
4
|
-
tmdb_id,
|
|
5
|
-
imdb_id,
|
|
6
|
-
season,
|
|
7
|
-
episode,
|
|
8
|
-
encoding,
|
|
9
|
-
language,
|
|
10
|
-
format,
|
|
11
|
-
source,
|
|
12
|
-
hi
|
|
13
|
-
}) {
|
|
14
|
-
const url = new URL("https://sub.wyzie.ru/search");
|
|
15
|
-
const queryParams = {
|
|
16
|
-
id: String(tmdb_id || imdb_id),
|
|
17
|
-
season,
|
|
18
|
-
episode,
|
|
19
|
-
encoding: Array.isArray(encoding) ? encoding.join(",") : encoding,
|
|
20
|
-
language: Array.isArray(language) ? language.join(",") : language,
|
|
21
|
-
format: Array.isArray(format) ? format.join(",") : format,
|
|
22
|
-
source: Array.isArray(source) ? source.join(",") : source,
|
|
23
|
-
hi
|
|
24
|
-
};
|
|
25
|
-
Object.entries(queryParams).forEach(([key, value]) => {
|
|
26
|
-
if (value !== void 0) {
|
|
27
|
-
url.searchParams.append(key, String(value));
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return url;
|
|
31
|
-
}
|
|
32
|
-
async function fetchSubtitles(url) {
|
|
33
|
-
const response = await fetch(url.toString());
|
|
34
|
-
if (!response.ok) {
|
|
35
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
36
|
-
}
|
|
37
|
-
return response.json();
|
|
38
|
-
}
|
|
39
|
-
async function searchSubtitles(params) {
|
|
40
|
-
try {
|
|
41
|
-
const url = await constructUrl(params);
|
|
42
|
-
return await fetchSubtitles(url);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
throw new Error(`Error fetching subtitles: ${error}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async function parseToVTT(subtitleUrl) {
|
|
48
|
-
try {
|
|
49
|
-
const response = await fetch(subtitleUrl);
|
|
50
|
-
if (!response.ok) {
|
|
51
|
-
throw new Error(`Failed to fetch subtitle content: ${response.status}`);
|
|
52
|
-
}
|
|
53
|
-
const content = await response.text();
|
|
54
|
-
const normalizedContent = content.replace(/\r\n|\r/g, "\n").trim();
|
|
55
|
-
const blocks = normalizedContent.split(/\n\n+/);
|
|
56
|
-
const timestampRegex = /^\d{1,2}:\d{2}:\d{2}[,.]\d{3}\s*-->\s*\d{1,2}:\d{2}:\d{2}[,.]\d{3}$/;
|
|
57
|
-
const hasValidSRTFormat = blocks.some((block) => {
|
|
58
|
-
const lines = block.split("\n").map((line) => line.trim());
|
|
59
|
-
return lines.some((line) => timestampRegex.test(line));
|
|
60
|
-
});
|
|
61
|
-
if (!hasValidSRTFormat) {
|
|
62
|
-
throw new Error("Invalid subtitle format: not SRT");
|
|
63
|
-
}
|
|
64
|
-
const vttLines = ["WEBVTT", ""];
|
|
65
|
-
for (const block of blocks) {
|
|
66
|
-
const lines = block.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
67
|
-
if (lines.length < 2)
|
|
68
|
-
continue;
|
|
69
|
-
const timestampIndex = lines.findIndex((line) => timestampRegex.test(line));
|
|
70
|
-
if (timestampIndex === -1)
|
|
71
|
-
continue;
|
|
72
|
-
const textLines = lines.slice(timestampIndex + 1).filter((line) => !/^\d+$/.test(line));
|
|
73
|
-
if (textLines.length === 0)
|
|
74
|
-
continue;
|
|
75
|
-
let timestampLine = lines[timestampIndex];
|
|
76
|
-
timestampLine = timestampLine.replace(/[,.](?=\s*-->)/, "").replace(/[,.]$/, "").replace(/,(\d{3})/g, ".$1");
|
|
77
|
-
vttLines.push(`${timestampLine}
|
|
78
|
-
${textLines.join("\n")}
|
|
79
|
-
`);
|
|
80
|
-
}
|
|
81
|
-
return vttLines.join("\n").replace(/\n{3,}/g, "\n\n").trim() + "\n\n";
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error("Error in parseToVTT:", error);
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.parseToVTT = parseToVTT;
|
|
88
|
-
exports.searchSubtitles = searchSubtitles;
|
|
89
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
90
|
-
return exports;
|
|
91
|
-
}({});
|