wyzie-lib 2.0.8 → 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 +24 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ project without all the fuss. [Read our source code!](https://github.com/itzcozi
|
|
|
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.
|
|
@@ -36,16 +37,14 @@ yarn add wyzie-lib
|
|
|
36
37
|
```ts
|
|
37
38
|
import { type SubtitleData, searchSubtitles, parseToVTT } from "wyzie-lib";
|
|
38
39
|
|
|
39
|
-
const params = { tmdb_id: 286217 };
|
|
40
|
-
|
|
41
40
|
// Fetches all subtitles for the media with the TMDB ID 286217
|
|
42
41
|
// -----------------------------------------------------------
|
|
43
|
-
const data: SubtitleData[] = await searchSubtitles(
|
|
42
|
+
const data: SubtitleData[] = await searchSubtitles({ tmdb_id: 286217, format: "srt" });
|
|
44
43
|
console.log(data[0].id); // Prints the ID of the first subtitle object
|
|
45
44
|
|
|
46
|
-
// Converts the first subtitle to VTT format
|
|
47
|
-
//
|
|
48
|
-
const vttContent = await parseToVTT(
|
|
45
|
+
// Converts the first subtitle from SRT to VTT format
|
|
46
|
+
// --------------------------------------------------
|
|
47
|
+
const vttContent = await parseToVTT(data[0].url); // Passes the first subtitle URL
|
|
49
48
|
console.log(vttContent); // Prints the raw VTT content
|
|
50
49
|
```
|
|
51
50
|
|
|
@@ -70,35 +69,35 @@ console.log(vttContent); // Prints the raw VTT content
|
|
|
70
69
|
```ts
|
|
71
70
|
interface SearchSubtitlesParams {
|
|
72
71
|
// Parameters for the searchSubtitles() function
|
|
73
|
-
tmdb_id?: number;
|
|
74
|
-
imdb_id?: number;
|
|
72
|
+
tmdb_id?: number; // Parsed automatically by the API to recognize if its TMDB or IMDB
|
|
73
|
+
imdb_id?: number; // Parsed automatically by the API to recognize if its TMDB or IMDB
|
|
75
74
|
season?: number;
|
|
76
|
-
episode?: number;
|
|
77
|
-
language?: string;
|
|
78
|
-
format?: string;
|
|
79
|
-
hi?: boolean;
|
|
75
|
+
episode?: number; // Season is required if episode is provided
|
|
76
|
+
language?: string; // ISO 3166 code
|
|
77
|
+
format?: string; // Subtitle file format
|
|
78
|
+
hi?: boolean; // If the subtitle is hearing impaired
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
interface QueryParams {
|
|
83
82
|
// Parameters for the wyzie-subs API
|
|
84
|
-
id: string;
|
|
85
|
-
season?: number;
|
|
86
|
-
episode?: number;
|
|
87
|
-
language?: string;
|
|
88
|
-
format?: string;
|
|
89
|
-
hi?: boolean;
|
|
83
|
+
id: string; // (Required) The TMDB or IMDB ID of the movie or TV show
|
|
84
|
+
season?: number; // The season of the TV show (Required if episode is provided)
|
|
85
|
+
episode?: number; // The episode of the TV show (Required if season is provided)
|
|
86
|
+
language?: string; // ISO 3166 code
|
|
87
|
+
format?: string; // Subtitle file format
|
|
88
|
+
hi?: boolean; // If the subtitle is hearing impaired
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
type SubtitleData = {
|
|
93
92
|
// Data returned by the API
|
|
94
|
-
id: string;
|
|
95
|
-
url: string;
|
|
96
|
-
format: string;
|
|
93
|
+
id: string; // Unique ID of the subtitle from opensubtitles
|
|
94
|
+
url: string; // Direct download link of the subtitle
|
|
95
|
+
format: string; // Subtitle file format
|
|
97
96
|
isHearingImpaired: boolean; // If the subtitle is hearing impaired
|
|
98
|
-
flagUrl: string;
|
|
99
|
-
media: string;
|
|
100
|
-
display: string;
|
|
101
|
-
language: string;
|
|
97
|
+
flagUrl: string; // Flag of the language
|
|
98
|
+
media: string; // Media name of the subtitle
|
|
99
|
+
display: string; // Actual name of the language
|
|
100
|
+
language: string; // ISO 3166 code
|
|
102
101
|
};
|
|
103
102
|
```
|
|
104
103
|
|