wyzie-lib 2.0.7 → 2.0.9
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 +22 -69
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
Wyzie Lib is a package made for easily implementing [Wyzie Subs](https://sub.wyzie.ru) into your
|
|
4
4
|
project without all the fuss. [Read our source code!](https://github.com/itzcozi/wyzie-lib)
|
|
5
5
|
|
|
6
|
-
<sup>
|
|
6
|
+
<sup>New VTT Parser!</sup>
|
|
7
7
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
10
|
+
- **VTT Parser**: Convert SRT subtitles to VTT format quickly.
|
|
10
11
|
- **Simple**: Just one function for searching subtitles using Wyzie Subs API.
|
|
11
12
|
- **Fast**: This package was written in Vite with TypeScript, so it's fast and reliable.
|
|
12
13
|
- **Open-Source**: The API and package are open-source.
|
|
@@ -34,32 +35,30 @@ yarn add wyzie-lib
|
|
|
34
35
|
## Usage
|
|
35
36
|
|
|
36
37
|
```ts
|
|
37
|
-
import { type SubtitleData, searchSubtitles } from "wyzie-lib";
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.log(vttContent); // Prints the VTT formatted subtitle content
|
|
38
|
+
import { type SubtitleData, searchSubtitles, parseToVTT } from "wyzie-lib";
|
|
39
|
+
|
|
40
|
+
// Fetches all subtitles for the media with the TMDB ID 286217
|
|
41
|
+
// -----------------------------------------------------------
|
|
42
|
+
const data: SubtitleData[] = await searchSubtitles({ tmdb_id: 286217, format: "srt" });
|
|
43
|
+
console.log(data[0].id); // Prints the ID of the first subtitle object
|
|
44
|
+
|
|
45
|
+
// Converts the first subtitle from SRT to VTT format
|
|
46
|
+
// --------------------------------------------------
|
|
47
|
+
const vttContent = await parseToVTT(data[0].url); // Passes the first subtitle URL
|
|
48
|
+
console.log(vttContent); // Prints the raw VTT content
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
### Parameters
|
|
52
52
|
|
|
53
|
-
| Parameter
|
|
54
|
-
|
|
|
55
|
-
| **tmdb_id** - _number_
|
|
56
|
-
| **imdb_id** - _number_
|
|
57
|
-
| **format** - _string_
|
|
58
|
-
| **season** - _number_
|
|
59
|
-
| **episode** - _number_
|
|
60
|
-
| **language** - _string_
|
|
61
|
-
| **hi** - _boolean_
|
|
62
|
-
| **parseVTT** - _boolean_ | parseVTT | Parse and return the first subtitle in VTT format. |
|
|
53
|
+
| Parameter | Name | Description |
|
|
54
|
+
| ----------------------- | ----------------- | ----------------------------------------------------------------------------------------- |
|
|
55
|
+
| **tmdb_id** - _number_ | TmdbId | The TMDB ID of the movie or TV show. _(tmdb_id or imdb_id is required)_ |
|
|
56
|
+
| **imdb_id** - _number_ | ImdbId | The IMDB ID of the movie or TV show. _(imdb_id or tmdb_id is required)_ |
|
|
57
|
+
| **format** - _string_ | format | The file format of the subtitles returned. _(srt, ass, vtt, txt, sub, mpl, webvtt, dfxp)_ |
|
|
58
|
+
| **season** - _number_ | season | Disired season of subtites _(this requires episode parameter aswell)_ |
|
|
59
|
+
| **episode** - _number_ | episode | The episode of the given season. |
|
|
60
|
+
| **language** - _string_ | language | The ISO 3166 code of the provided subtitles. |
|
|
61
|
+
| **hi** - _boolean_ | isHearingImpaired | A boolean indicating if the subtitles are hearing impaired. |
|
|
63
62
|
|
|
64
63
|
### Types
|
|
65
64
|
|
|
@@ -102,52 +101,6 @@ type SubtitleData = {
|
|
|
102
101
|
};
|
|
103
102
|
```
|
|
104
103
|
|
|
105
|
-
### VTT Parsing Features
|
|
106
|
-
|
|
107
|
-
The VTT parser now includes several improvements for handling subtitle files:
|
|
108
|
-
|
|
109
|
-
- **Robust Format Handling**: Automatically handles both SRT and VTT input formats
|
|
110
|
-
- **Timestamp Normalization**: Converts all timestamps to WebVTT format (HH:MM:SS.mmm)
|
|
111
|
-
- **Smart Block Processing**:
|
|
112
|
-
- Maintains proper spacing between subtitle blocks
|
|
113
|
-
- Removes subtitle numbers
|
|
114
|
-
- Handles multi-line subtitles
|
|
115
|
-
- Preserves text formatting
|
|
116
|
-
- **Error Handling**: Gracefully handles malformed input and network errors
|
|
117
|
-
|
|
118
|
-
Example VTT output:
|
|
119
|
-
|
|
120
|
-
```vtt
|
|
121
|
-
WEBVTT
|
|
122
|
-
|
|
123
|
-
00:02:05.872 --> 00:02:08.024
|
|
124
|
-
All right, team,
|
|
125
|
-
stay in sight of each other.
|
|
126
|
-
|
|
127
|
-
00:02:08.124 --> 00:02:10.484
|
|
128
|
-
Let's make NASA proud today.
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Error Handling
|
|
132
|
-
|
|
133
|
-
The library provides detailed error messages for common issues:
|
|
134
|
-
|
|
135
|
-
```ts
|
|
136
|
-
try {
|
|
137
|
-
const { subtitles, vttContent } = await searchSubtitles({
|
|
138
|
-
tmdb_id: 286217,
|
|
139
|
-
parseVTT: true,
|
|
140
|
-
});
|
|
141
|
-
} catch (error) {
|
|
142
|
-
// Handles various error cases:
|
|
143
|
-
// - Network errors
|
|
144
|
-
// - Invalid subtitle format
|
|
145
|
-
// - Missing required parameters
|
|
146
|
-
// - API errors
|
|
147
|
-
console.error(error);
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
104
|
<hr />
|
|
152
105
|
|
|
153
106
|
<sup>
|